diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 0085256..0bd8464 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -11,7 +11,7 @@ #ifndef CONTROLLER_CONFIG_H #define CONTROLLER_CONFIG_H -#define FIRMWARE_VERSION "1.0.3" +#define FIRMWARE_VERSION "1.0.4" #define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095) #define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc) * 3.3 * (multi)) / 4095) diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 55acb48..5b4cf52 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -70,7 +70,16 @@ public: void init(void); + /** @fn bool isInCooldown(long sinceLastActivation) + * @brief determine, if the plant was recently casted + * @param sinceLastActivation timestamp of last time + */ bool isInCooldown(long sinceLastActivation) { + /* if the time difference is greater than one month, we know these are initial values */ + if (sinceLastActivation > (60 * 60 * 24 * 30)) { + return false; + } + return (this->mSetting->pPumpCooldownInHours->get() > sinceLastActivation / 3600); } diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 7d4513f..a3d0ebb 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -120,10 +120,12 @@ bool prepareSleep(void *) { return true; // repeat? true there is something in the queue to be done } -void espDeepSleepFor(long seconds){ +void espDeepSleepFor(long seconds, bool activatePump = false){ delay(1500); gpio_deep_sleep_hold_en(); - gpio_hold_en(GPIO_NUM_13); //pump pwr + if (activatePump) { + gpio_hold_en(GPIO_NUM_13); //pump pwr + } //gpio_hold_en(GPIO_NUM_23); //p0 //FIXME fix for outher outputs @@ -216,7 +218,7 @@ void mode2MQTT(){ }else { gotoMode2AfterThisTimestamp = 0; Serial.println("Running pump, watering deepsleep"); - espDeepSleepFor(wateringDeepSleep.get()); + espDeepSleepFor(wateringDeepSleep.get(), true); } }