Merge branch 'main' of git.kleiax.de:kleiax/Bewaesserung-Arduino

This commit is contained in:
2023-07-03 17:48:22 +02:00
2 changed files with 17 additions and 34 deletions
+9 -26
View File
@@ -36,6 +36,9 @@ void Pump::loop() {
case State::Error : case State::Error :
this->stateError(); this->stateError();
break; break;
default :
break;
} }
} }
@@ -74,32 +77,8 @@ uint16_t Pump::getFlow() {
return 0; return 0;
} }
uint16_t Pump::getStatus() { uint8_t Pump::getStatus() {
switch (this->state) { return (uint8_t) this->state;
case State::Off :
return 0;
break;
case State::On :
return 1;
break;
case State::Timer :
return 2;
break;
case State::Standby :
return 3;
break;
case State::Error :
return -1;
break;
default:
return -2;
break;
}
} }
bool Pump::checkSensors() { bool Pump::checkSensors() {
@@ -171,6 +150,10 @@ void Pump::changeState(State state) {
this->handlePins(false); this->handlePins(false);
break; break;
case State::OnStupid :
this->handlePins(true);
break;
default: default:
break; break;
} }
+8 -8
View File
@@ -4,12 +4,13 @@
class Pump { class Pump {
public: public:
enum State { enum State : uint8_t {
Off, Off = 0,
On, On = 1,
Timer, Timer = 2,
Standby, Standby = 3,
Error Error = 100,
OnStupid = 200
}; };
Pump(uint8_t pumpPin, uint8_t pressurePin, uint8_t flowPin, uint8_t ledPin); Pump(uint8_t pumpPin, uint8_t pressurePin, uint8_t flowPin, uint8_t ledPin);
@@ -23,7 +24,7 @@ class Pump {
uint16_t getPressure(); uint16_t getPressure();
uint32_t getRunningTime(); uint32_t getRunningTime();
uint16_t getFlow(); uint16_t getFlow();
uint16_t getStatus(); uint8_t getStatus();
State getState() { return this->state; } State getState() { return this->state; }
@@ -32,7 +33,6 @@ class Pump {
static const uint16_t blinkTime = 1000; static const uint16_t blinkTime = 1000;
static const uint16_t maxPressure = 1000; static const uint16_t maxPressure = 1000;
static const uint16_t maxMaxPressureTime = 30000; static const uint16_t maxMaxPressureTime = 30000;
static const uint16_t delayTimer = 1000;
bool checkSensors(); bool checkSensors();
void handlePins(bool state); void handlePins(bool state);