Timer added
This commit is contained in:
parent
b0829cba6b
commit
c6871fc401
@ -16,6 +16,7 @@
|
|||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "RunningMedian.h"
|
#include "RunningMedian.h"
|
||||||
|
#include <arduino-timer.h>
|
||||||
|
|
||||||
const unsigned long TEMPREADCYCLE = 30000; /**< Check temperature all half minutes */
|
const unsigned long TEMPREADCYCLE = 30000; /**< Check temperature all half minutes */
|
||||||
|
|
||||||
@ -66,6 +67,9 @@ int readCounter = 0;
|
|||||||
int mButtonClicks = 0;
|
int mButtonClicks = 0;
|
||||||
bool mConfigured = false;
|
bool mConfigured = false;
|
||||||
|
|
||||||
|
|
||||||
|
auto wait4sleep = timer_create_default(); // create a timer with default settings
|
||||||
|
|
||||||
RTC_DATA_ATTR int gBootCount = 0;
|
RTC_DATA_ATTR int gBootCount = 0;
|
||||||
RTC_DATA_ATTR int gCurrentPlant = 0; /**< Value Range: 1 ... 7 (0: no plant needs water) */
|
RTC_DATA_ATTR int gCurrentPlant = 0; /**< Value Range: 1 ... 7 (0: no plant needs water) */
|
||||||
|
|
||||||
@ -105,9 +109,10 @@ long getCurrentTime(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//wait till homie flushed mqtt ect.
|
//wait till homie flushed mqtt ect.
|
||||||
void prepareSleep() {
|
bool prepareSleep(void *) {
|
||||||
//FIXME wait till pending mqtt is done, then start sleep via event or whatever
|
//FIXME wait till pending mqtt is done, then start sleep via event or whatever
|
||||||
//Homie.prepareToSleep();
|
//Homie.prepareToSleep();
|
||||||
|
return true; // repeat? true there is something in the queue to be done
|
||||||
}
|
}
|
||||||
|
|
||||||
void mode2MQTT(){
|
void mode2MQTT(){
|
||||||
@ -128,7 +133,8 @@ void mode2MQTT(){
|
|||||||
/* let the ESP sleep qickly, as nothing must be done */
|
/* let the ESP sleep qickly, as nothing must be done */
|
||||||
if ((millis() >= (MIN_TIME_RUNNING * MS_TO_S)) && (deepSleepTime.get() > 0)) {
|
if ((millis() >= (MIN_TIME_RUNNING * MS_TO_S)) && (deepSleepTime.get() > 0)) {
|
||||||
Serial << "No Water for pumps" << endl;
|
Serial << "No Water for pumps" << endl;
|
||||||
t.after(50, prepareSleep);
|
/* in 500 microseconds */
|
||||||
|
wait4sleep.in(500, prepareSleep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +162,7 @@ void mode2MQTT(){
|
|||||||
|
|
||||||
bool lipoTempWarning = abs(temp[1] - temp[2]) > 5;
|
bool lipoTempWarning = abs(temp[1] - temp[2]) > 5;
|
||||||
if(lipoTempWarning){
|
if(lipoTempWarning){
|
||||||
t.after(50, prepareSleep);
|
wait4sleep.in(500, prepareSleep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user