Few Cronixie fixes

This commit is contained in:
cschwinne 2020-01-01 01:04:54 +01:00
parent 51fb981d24
commit 4dfc1631af
3 changed files with 14 additions and 11 deletions

View File

@ -622,6 +622,10 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
//cronixie //cronixie
#ifndef WLED_DISABLE_CRONIXIE #ifndef WLED_DISABLE_CRONIXIE
//mode, 1 countdown
pos = req.indexOf("NM=");
if (pos > 0) countdownMode = (req.charAt(pos+3) != '0');
pos = req.indexOf("NX="); //sets digits to code pos = req.indexOf("NX="); //sets digits to code
if (pos > 0) { if (pos > 0) {
strlcpy(cronixieDisplay, req.substring(pos + 3, pos + 9).c_str(), 6); strlcpy(cronixieDisplay, req.substring(pos + 3, pos + 9).c_str(), 6);
@ -636,9 +640,6 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
overlayRefreshedTime = 0; overlayRefreshedTime = 0;
} }
#endif #endif
//mode, 1 countdown
pos = req.indexOf("NM=");
if (pos > 0) countdownMode = (req.charAt(pos+3) != '0');
pos = req.indexOf("U0="); //user var 0 pos = req.indexOf("U0="); //user var 0
if (pos > 0) { if (pos > 0) {

View File

@ -163,13 +163,16 @@ void setCountdown()
//returns true if countdown just over //returns true if countdown just over
bool checkCountdown() bool checkCountdown()
{ {
long diff = countdownTime - now(); unsigned long n = now();
local = abs(diff); local = countdownTime - n;
if (diff <0 && !countdownOverTriggered) if (n > countdownTime) {
{ local = n - countdownTime;
if (macroCountdown != 0) applyMacro(macroCountdown); if (!countdownOverTriggered)
countdownOverTriggered = true; {
return true; if (macroCountdown != 0) applyMacro(macroCountdown);
countdownOverTriggered = true;
return true;
}
} }
return false; return false;
} }

View File

@ -147,7 +147,6 @@ void _overlayCronixie()
{ {
if (countdownMode) checkCountdown(); if (countdownMode) checkCountdown();
#ifndef WLED_DISABLE_CRONIXIE #ifndef WLED_DISABLE_CRONIXIE
byte h = hour(local); byte h = hour(local);
byte h0 = h; byte h0 = h;
byte m = minute(local); byte m = minute(local);