make a lot of things better
This commit is contained in:
+7
-3
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user