Merge pull request #3489 from WoodyLetsCode/clock-overlay

Show clock overlay only if all LEDs are solid black
This commit is contained in:
Blaž Kristan 2024-02-01 16:54:26 +01:00 committed by GitHub
commit fee32622f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 0 deletions

View File

@ -507,6 +507,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")];
@ -973,6 +974,7 @@ void serializeConfig() {
ol[F("o12pix")] = analogClock12pixel;
ol[F("o5m")] = analogClock5MinuteMarks;
ol[F("osec")] = analogClockSecondsTrail;
ol[F("osb")] = analogClockSolidBlack;
JsonObject timers = root.createNestedObject(F("timers"));

View File

@ -212,6 +212,7 @@
12h LED: <input name="OM" type="number" min="0" max="255" required><br>
Show 5min marks: <input type="checkbox" name="O5"><br>
Seconds (as trail): <input type="checkbox" name="OS"><br>
Show clock overlay only if all LEDs are solid black: <input type="checkbox" name="OB"><br>
</div>
Countdown Mode: <input type="checkbox" name="CE"><br>
Countdown Goal:<br>

View File

@ -89,6 +89,16 @@ void _overlayAnalogCountdown()
void handleOverlayDraw() {
usermods.handleOverlayDraw();
if (analogClockSolidBlack) {
const Segment* segments = strip.getSegments();
for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) {
const Segment& segment = segments[i];
if (!segment.isActive()) continue;
if (segment.mode > 0 || segment.colors[0] > 0) {
return;
}
}
}
if (overlayCurrent == 1) _overlayAnalogClock();
}

View File

@ -440,6 +440,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();

View File

@ -494,6 +494,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

View File

@ -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);