From 9bfe27dd5e12aa8d0dfeca240b3d59efcd2e2813 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 12 Apr 2021 21:53:22 +0200 Subject: [PATCH] Sunrise and sunset calculation and sunrise/sunset triggered presets. --- wled00/cfg.cpp | 11 +- wled00/data/settings_time.htm | 15 +- wled00/fcn_declare.h | 1 + wled00/html_settings.h | 44 +- wled00/html_ui.h | 1340 ++++++++++++++++----------------- wled00/ntp.cpp | 129 +++- wled00/set.cpp | 7 +- wled00/wled.h | 12 +- wled00/xml.cpp | 12 +- 9 files changed, 862 insertions(+), 709 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 4955eec1..6c33dfd1 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -306,6 +306,8 @@ void deserializeConfig() { CJSON(currentTimezone, if_ntp[F("tz")]); CJSON(utcOffsetSecs, if_ntp[F("offset")]); CJSON(useAMPM, if_ntp[F("ampm")]); + CJSON(longitude, if_ntp[F("ln")]); + CJSON(latitude, if_ntp[F("lt")]); JsonObject ol = doc[F("ol")]; CJSON(overlayDefault ,ol[F("clock")]); // 0 @@ -334,7 +336,8 @@ void deserializeConfig() { JsonArray timers = tm[F("ins")]; uint8_t it = 0; for (JsonObject timer : timers) { - if (it > 7) break; + if (it > 9) break; + if (it<8 && timer[F("hour")]==255) it=8; // hour==255 -> sunrise/sunset CJSON(timerHours[it], timer[F("hour")]); CJSON(timerMinutes[it], timer[F("min")]); CJSON(timerMacro[it], timer[F("macro")]); @@ -617,6 +620,8 @@ void serializeConfig() { if_ntp[F("tz")] = currentTimezone; if_ntp[F("offset")] = utcOffsetSecs; if_ntp[F("ampm")] = useAMPM; + if_ntp[F("ln")] = longitude; + if_ntp[F("lt")] = latitude; JsonObject ol = doc.createNestedObject("ol"); ol[F("clock")] = overlayDefault; @@ -638,8 +643,8 @@ void serializeConfig() { JsonArray timers_ins = timers.createNestedArray("ins"); - for (byte i = 0; i < 8; i++) { - if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue; + for (byte i = 0; i < 10; i++) { + if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue; // sunrise/sunset get saved always (timerHours=255) JsonObject timers_ins0 = timers_ins.createNestedObject(); timers_ins0["en"] = (timerWeekday[i] & 0x01); timers_ins0[F("hour")] = timerHours[i]; diff --git a/wled00/data/settings_time.htm b/wled00/data/settings_time.htm index 9924530f..f8a0d9f1 100644 --- a/wled00/data/settings_time.htm +++ b/wled00/data/settings_time.htm @@ -49,19 +49,23 @@ ih+=""; for (j=1;j<8;j++) ih+=""; } + ih+="Sunrise"; + for (j=1;j<8;j++) ih+=""; + ih+="Sunset"; + for (j=1;j<8;j++) ih+=""; gId("TMT").innerHTML=ih; } function FC() { for(j=0;j<8;j++) { - for(i=0;i<8;i++) gId("W"+i+j).checked=gId("W"+i).value>>j&1; + for(i=0;i<10;i++) gId("W"+i+j).checked=gId("W"+i).value>>j&1; } } function Wd() { - a=[0,0,0,0,0,0,0,0]; - for(i=0;i<8;i++) + a=[0,0,0,0,0,0,0,0,0,0]; + for(i=0;i<10;i++) { m=1; for(j=0;j<8;j++) @@ -111,7 +115,10 @@
UTC offset: seconds (max. 18 hours)
- Current local time is unknown. + Current local time is unknown.
+ Latitude (N): + Longitude (E): +

Clock

Clock Overlay:
+Button type:
Infrared remote: