added json, more pump code, bugs

This commit is contained in:
2023-04-14 20:39:11 +02:00
parent 08f14424af
commit d22e0bc752
10 changed files with 322 additions and 55 deletions
+23 -4
View File
@@ -4,7 +4,6 @@
class Pump {
public:
static const uint16_t blinkTime = 1000;
enum State {
Off,
On,
@@ -13,7 +12,7 @@ class Pump {
Error
};
Pump(uint8_t pumpPin, uint8_t pressurePin, uint8_t flowPin, uint8_t errorLedPin);
Pump(uint8_t pumpPin, uint8_t pressurePin, uint8_t flowPin, uint8_t ledPin);
void loop();
@@ -24,20 +23,40 @@ class Pump {
uint16_t getPressure();
uint32_t getRunningTime();
uint16_t getFlow();
uint16_t getStatus();
State getState() { return this->state; }
private:
void checkSensors();
static const uint8_t delayCheckSensor = 50;
static const uint16_t blinkTime = 1000;
static const uint16_t maxPressure = 1000;
static const uint16_t maxMaxPressureTime = 30000;
static const uint16_t delayTimer = 1000;
bool checkSensors();
void handlePins(bool state);
void changeState(State state);
void stateTimer();
void stateStandby();
void stateError();
State state = State::Off;
bool ledState = false;
bool timerStandby = false;
uint8_t pumpPin;
uint8_t pressurePin;
uint8_t flowPin;
uint8_t errorLedPin;
uint8_t ledPin;
uint16_t delayTimer = 1000;
uint16_t flow;
uint16_t pressure;
uint32_t startTime;
uint32_t duration;
uint32_t lastMillisTimer = 0;
uint32_t lastMillisCheckSensor = 0;
uint32_t maxPressureStart = 0;
};