From 18868a5bd6771820e001451ea2511a99f05bba5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Fri, 31 Dec 2021 14:09:48 +0100 Subject: [PATCH] Date controlled timed presets. (#2447) * Date controlled timed presets. * C/P fix for sunset. * Fixed % escape character * Date range support * Date logic fix Co-authored-by: cschwinne --- wled00/cfg.cpp | 22 +- wled00/data/settings_time.htm | 149 +-- wled00/data/style.css | 2 - wled00/html_settings.h | 89 +- wled00/html_ui.h | 1592 ++++++++++++++++----------------- wled00/ntp.cpp | 32 +- wled00/playlist.cpp | 2 +- wled00/set.cpp | 22 +- wled00/wled.h | 16 +- wled00/xml.cpp | 8 +- 10 files changed, 1018 insertions(+), 916 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index a0021337..86c8c687 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -366,7 +366,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(timerMinutes[it], timer["min"]); CJSON(timerMacro[it], timer["macro"]); - byte dowPrev = timerWeekday[it]; + byte dowPrev = timerWeekday[it]; //note: act is currently only 0 or 1. //the reason we are not using bool is that the on-disk type in 0.11.0 was already int int actPrev = timerWeekday[it] & 0x01; @@ -376,7 +376,17 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { int act = timer["en"] | actPrev; if (act) timerWeekday[it]++; } - + if (it<8) { + JsonObject start = timer["start"]; + byte startm = start["mon"]; + if (startm) timerMonth[it] = (startm << 4); + CJSON(timerDay[it], start["day"]); + JsonObject end = timer["end"]; + CJSON(timerDayEnd[it], end["day"]); + byte endm = end["mon"]; + if (startm) timerMonth[it] += endm & 0x0F; + if (!(timerMonth[it] & 0x0F)) timerMonth[it] += 12; //default end month to 12 + } it++; } @@ -742,6 +752,14 @@ void serializeConfig() { timers_ins0["min"] = timerMinutes[i]; timers_ins0["macro"] = timerMacro[i]; timers_ins0[F("dow")] = timerWeekday[i] >> 1; + if (i<8) { + JsonObject start = timers_ins0.createNestedObject("start"); + start["mon"] = (timerMonth[i] >> 4) & 0xF; + start["day"] = timerDay[i]; + JsonObject end = timers_ins0.createNestedObject("end"); + end["mon"] = timerMonth[i] & 0xF; + end["day"] = timerDayEnd[i]; + } } JsonObject ota = doc.createNestedObject("ota"); diff --git a/wled00/data/settings_time.htm b/wled00/data/settings_time.htm index ffe82924..8ca8851c 100644 --- a/wled00/data/settings_time.htm +++ b/wled00/data/settings_time.htm @@ -6,9 +6,11 @@ Time Settings