Handle default value of cooldown

This commit is contained in:
c3ma 2020-10-23 16:47:40 +02:00
parent 80ce95d5d6
commit 8f21f58950
3 changed files with 15 additions and 4 deletions

View File

@ -11,7 +11,7 @@
#ifndef CONTROLLER_CONFIG_H #ifndef CONTROLLER_CONFIG_H
#define 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(adc) ((adc) * 3.3 ) / 4095)
#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc) * 3.3 * (multi)) / 4095) #define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc) * 3.3 * (multi)) / 4095)

View File

@ -70,7 +70,16 @@ public:
void init(void); 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) { 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); return (this->mSetting->pPumpCooldownInHours->get() > sinceLastActivation / 3600);
} }

View File

@ -120,10 +120,12 @@ bool prepareSleep(void *) {
return true; // repeat? true there is something in the queue to be done 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); delay(1500);
gpio_deep_sleep_hold_en(); 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 //gpio_hold_en(GPIO_NUM_23); //p0
//FIXME fix for outher outputs //FIXME fix for outher outputs
@ -216,7 +218,7 @@ void mode2MQTT(){
}else { }else {
gotoMode2AfterThisTimestamp = 0; gotoMode2AfterThisTimestamp = 0;
Serial.println("Running pump, watering deepsleep"); Serial.println("Running pump, watering deepsleep");
espDeepSleepFor(wateringDeepSleep.get()); espDeepSleepFor(wateringDeepSleep.get(), true);
} }
} }