From 6a42e477aa0b4e32b1b8aeefde480e4cddad852b Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 8 Aug 2022 19:56:09 +0200 Subject: [PATCH] Empty name Scrolling tex bugfix. --- wled00/FX.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index a66b836e..6f13bd4f 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5846,11 +5846,11 @@ uint16_t mode_2Dscrollingtext(void) { const int letterWidth = SEGMENT.custom2 > 128 ? 6 : 5; const int letterHeight = 8; const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2; - const char *text = nullptr; - if (SEGMENT.name && strlen(SEGMENT.name)) text = SEGMENT.name; + char text[33] = {'\0'}; + if (SEGMENT.name && strlen(SEGMENT.name)) for (int i=0,j=0; i63 && SEGMENT.name[i]<128) text[j++] = SEGMENT.name[i]; - char lineBuffer[17], sec[3]; - if (!text) { // fallback if empty segment name: display date and time + if (!strlen(text) || !strncmp_P(text,PSTR("#DATE"),5) || !strncmp_P(text,PSTR("#TIME"),5)) { // fallback if empty segment name: display date and time + char sec[5]; byte AmPmHour = hour(localTime); boolean isitAM = true; if (useAMPM) { @@ -5859,8 +5859,9 @@ uint16_t mode_2Dscrollingtext(void) { } if (useAMPM) sprintf_P(sec, PSTR(" %2s"), (isitAM ? "AM" : "PM")); else sprintf_P(sec, PSTR(":%02d"), second(localTime)); - sprintf_P(lineBuffer,PSTR("%s %2d %2d:%02d%s"), monthShortStr(month(localTime)), day(localTime), AmPmHour, minute(localTime), sec); - text = lineBuffer; + if (!strncmp_P(text,PSTR("#DATE"),5)) sprintf_P(text, PSTR("%d.%d.%d"), day(localTime), month(localTime), year(localTime)); + else if (!strncmp_P(text,PSTR("#TIME"),5)) sprintf_P(text, PSTR("%2d:%02d%s"), AmPmHour, minute(localTime), sec); + else sprintf_P(text, PSTR("%s %d, %d %2d:%02d%s"), monthShortStr(month(localTime)), day(localTime), year(localTime), AmPmHour, minute(localTime), sec); } const int numberOfLetters = strlen(text);