diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index 68f1a22..5a1808d 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -51,10 +51,14 @@ void Plant::init(void) return (candidate >= 0); }); - this->mSetting->pPumpDuration->setDefaultValue(5); + this->mSetting->pPumpDuration->setDefaultValue(30); this->mSetting->pPumpDuration->setValidator([](long candidate) { return ((candidate >= 0) && (candidate <= 1000)); }); + this->mSetting->pPumpMl->setDefaultValue(0); + this->mSetting->pPumpMl->setValidator([](long candidate) { + return ((candidate >= 0) && (candidate <= 5000)); + }); this->mSetting->pPumpPowerLevel->setDefaultValue(100); this->mSetting->pPumpPowerLevel->setValidator([](long candidate) { return ((candidate >= 0) && (candidate <= 100)); diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 2f39f71..9565308 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -601,6 +601,7 @@ void pumpActiveLoop() } #ifdef FLOWMETER_PIN + int16_t pulses; pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_7); esp_err_t result = pcnt_get_counter_value(unit, &pulses); @@ -627,8 +628,10 @@ void pumpActiveLoop() mPlants[pumpToRun].setProperty("waterusage").send(String(pumped)); } } +#endif - long duration = pumpTarget - millis(); + long pumpStarted = pumpTarget - (mPlants[pumpToRun].getPumpDuration() * 1000); + long duration = millis()-pumpStarted; if (millis() > pumpTarget) { mPlants[pumpToRun].setProperty("watertime").send(String(duration)); @@ -639,11 +642,8 @@ void pumpActiveLoop() mPlants[pumpToRun].setProperty("watertime").send(String(duration)); } -#endif - if (targetReached) { - //disable all digitalWrite(OUTPUT_ENABLE_PUMP, LOW); for (int i = 0; i < MAX_PLANTS; i++) @@ -660,7 +660,7 @@ void pumpActiveLoop() void safeSetup() { - throw std::runtime_error("Shit happened"); + //throw std::runtime_error("Shit happened"); /* reduce power consumption */ setCpuFrequencyMhz(80);