From a83002ca104662c1a5290fe54e14bbdb1e52b711 Mon Sep 17 00:00:00 2001 From: Woody Date: Thu, 26 Oct 2023 23:36:29 +0200 Subject: [PATCH] closes Aircoookie/WLED#984 Implements option to show clock overlay only if all LEDs are solid black --- wled00/cfg.cpp | 2 ++ wled00/data/settings_time.htm | 1 + wled00/overlay.cpp | 9 +++++++++ wled00/set.cpp | 1 + wled00/wled.h | 1 + wled00/xml.cpp | 1 + 6 files changed, 15 insertions(+) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 4234d9b0..8d7458b9 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -496,6 +496,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(analogClock12pixel, ol[F("o12pix")]); CJSON(analogClock5MinuteMarks, ol[F("o5m")]); CJSON(analogClockSecondsTrail, ol[F("osec")]); + CJSON(analogClockSolidBlack, ol[F("osb")]); //timed macro rules JsonObject tm = doc[F("timers")]; @@ -954,6 +955,7 @@ void serializeConfig() { ol[F("o12pix")] = analogClock12pixel; ol[F("o5m")] = analogClock5MinuteMarks; ol[F("osec")] = analogClockSecondsTrail; + ol[F("osb")] = analogClockSolidBlack; JsonObject timers = doc.createNestedObject(F("timers")); diff --git a/wled00/data/settings_time.htm b/wled00/data/settings_time.htm index c14884a1..041177fd 100644 --- a/wled00/data/settings_time.htm +++ b/wled00/data/settings_time.htm @@ -210,6 +210,7 @@ 12h LED:
Show 5min marks:
Seconds (as trail):
+ Show clock overlay only if all LEDs are solid black:
Countdown Mode:
Countdown Goal:
diff --git a/wled00/overlay.cpp b/wled00/overlay.cpp index cfee7e81..d76399e6 100644 --- a/wled00/overlay.cpp +++ b/wled00/overlay.cpp @@ -89,6 +89,15 @@ void _overlayAnalogCountdown() void handleOverlayDraw() { usermods.handleOverlayDraw(); + if (analogClockSolidBlack) { + Segment* segments = strip.getSegments(); + for (uint8_t i = 0; i < strip.getActiveSegmentsNum(); i++) { + Segment segment = segments[i]; + if (segment.mode > 0 || segment.colors[0] > 0) { + return; + } + } + } if (overlayCurrent == 1) _overlayAnalogClock(); } diff --git a/wled00/set.cpp b/wled00/set.cpp index 744c0eee..d2aab39a 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -409,6 +409,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) analogClock12pixel = request->arg(F("OM")).toInt(); analogClock5MinuteMarks = request->hasArg(F("O5")); analogClockSecondsTrail = request->hasArg(F("OS")); + analogClockSolidBlack = request->hasArg(F("OB")); countdownMode = request->hasArg(F("CE")); countdownYear = request->arg(F("CY")).toInt(); diff --git a/wled00/wled.h b/wled00/wled.h index ad051893..797eae50 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -482,6 +482,7 @@ WLED_GLOBAL byte overlayMin _INIT(0), overlayMax _INIT(DEFAULT_LED_COUNT - 1); WLED_GLOBAL byte analogClock12pixel _INIT(0); // The pixel in your strip where "midnight" would be WLED_GLOBAL bool analogClockSecondsTrail _INIT(false); // Display seconds as trail of LEDs instead of a single pixel WLED_GLOBAL bool analogClock5MinuteMarks _INIT(false); // Light pixels at every 5-minute position +WLED_GLOBAL bool analogClockSolidBlack _INIT(false); // Show clock overlay only if all LEDs are solid black (effect is 0 and color is black) WLED_GLOBAL bool countdownMode _INIT(false); // Clock will count down towards date WLED_GLOBAL byte countdownYear _INIT(20), countdownMonth _INIT(1); // Countdown target date, year is last two digits diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 23de8179..aac1217a 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -597,6 +597,7 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',SET_F("OM"),analogClock12pixel); sappend('c',SET_F("OS"),analogClockSecondsTrail); sappend('c',SET_F("O5"),analogClock5MinuteMarks); + sappend('c',SET_F("OB"),analogClockSolidBlack); sappend('c',SET_F("CE"),countdownMode); sappend('v',SET_F("CY"),countdownYear);