make a lot of things better

This commit is contained in:
2023-07-05 02:38:18 +02:00
parent e4c5ddb9ab
commit ac995522db
6 changed files with 62 additions and 33 deletions
+7 -3
View File
@@ -1,7 +1,7 @@
#include "valve.h"
Valve::Valve() {
Valve::Valve(uint8_t maxOpen) {
this->maxOpen = maxOpen;
}
void Valve::loop() {
@@ -37,6 +37,10 @@ void Valve::open(uint8_t valveNumber, uint8_t minutes) {
if (valveNumber >= this->valveCount)
return;
if (this->getNumOfOpen() >= this->maxOpen) {
return;
}
this->valves[valveNumber].duration = minutes;
this->valves[valveNumber].startTime = millis();
this->setValve(valveNumber, true);
@@ -60,7 +64,7 @@ void Valve::closeAll() {
this->close(i);
}
uint8_t Valve::getNumOfOpen() {
uint8_t Valve::getNumOfOpen() const {
uint8_t res = 0;
for (uint8_t i = 0; i < this->valveCount; i++)
if (this->valves[i].duration)