mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-25 06:46:10 +02:00
configurable offset for tickMidnight
This commit is contained in:
parent
b6a41506b6
commit
8342851ead
3 changed files with 13 additions and 2 deletions
|
@ -193,7 +193,7 @@ void app::tickNtpUpdate(void) {
|
||||||
if(mConfig->inst.rstValsNotAvail)
|
if(mConfig->inst.rstValsNotAvail)
|
||||||
everyMin(std::bind(&app::tickMinute, this), "tMin");
|
everyMin(std::bind(&app::tickMinute, this), "tMin");
|
||||||
if(mConfig->inst.rstYieldMidNight) {
|
if(mConfig->inst.rstYieldMidNight) {
|
||||||
uint32_t midTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
|
uint32_t midTrig = mTimestamp - ((mTimestamp + MIDNIGHTTICKER_OFFSET) % 86400) + 86400; // next midnight
|
||||||
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
|
onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ void app::tickMinute(void) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::tickMidnight(void) {
|
void app::tickMidnight(void) {
|
||||||
// only triggered if 'reset values at midnight is enabled'
|
// only triggered if 'reset values at midnight is enabled'
|
||||||
uint32_t nxtTrig = mTimestamp - ((mTimestamp - 1) % 86400) + 86400; // next midnight
|
uint32_t nxtTrig = mTimestamp - ((mTimestamp + MIDNIGHTTICKER_OFFSET) % 86400) + 86400; // next midnight
|
||||||
onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2");
|
onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2");
|
||||||
|
|
||||||
Inverter<> *iv;
|
Inverter<> *iv;
|
||||||
|
|
|
@ -122,6 +122,13 @@
|
||||||
// reconnect delay
|
// reconnect delay
|
||||||
#define MQTT_RECONNECT_DELAY 5000
|
#define MQTT_RECONNECT_DELAY 5000
|
||||||
|
|
||||||
|
// Offset for midnight Ticker
|
||||||
|
// relative to UTC
|
||||||
|
// may be negative for later in the next day or positive for earlier in previous day
|
||||||
|
// may contain variable like mCalculatedTimezoneOffset
|
||||||
|
// must be in parentheses
|
||||||
|
#define MIDNIGHTTICKER_OFFSET (-1)
|
||||||
|
|
||||||
#if __has_include("config_override.h")
|
#if __has_include("config_override.h")
|
||||||
#include "config_override.h"
|
#include "config_override.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#define DEF_RF24_IRQ_PIN 16
|
#define DEF_RF24_IRQ_PIN 16
|
||||||
|
|
||||||
|
|
||||||
|
// Offset for midnight Ticker Example: 1 second before midnight (local time)
|
||||||
|
#undef MIDNIGHTTICKER_OFFSET
|
||||||
|
#define MIDNIGHTTICKER_OFFSET (mCalculatedTimezoneOffset + 1)
|
||||||
|
|
||||||
// To enable the json endpoint at /json
|
// To enable the json endpoint at /json
|
||||||
// #define ENABLE_JSON_EP
|
// #define ENABLE_JSON_EP
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue