Handle default value of cooldown
This commit is contained in:
parent
80ce95d5d6
commit
8f21f58950
@ -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)
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
if (activatePump) {
|
||||||
gpio_hold_en(GPIO_NUM_13); //pump pwr
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user