From fc4ed1c50bae3c4f6817178d5e5e7c695fcab23a Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Tue, 12 Sep 2023 16:48:32 +0200 Subject: [PATCH] Fix for #3369 --- wled00/FX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 517f77e3..9fed2779 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5909,7 +5909,6 @@ uint16_t mode_2Dscrollingtext(void) { char text[WLED_MAX_SEGNAME_LEN+1] = {'\0'}; if (SEGMENT.name) for (size_t i=0,j=0; i31 && SEGMENT.name[i]<128) text[j++] = SEGMENT.name[i]; const bool zero = strchr(text, '0') != nullptr; - const int numberOfLetters = strlen(text); char sec[5]; int AmPmHour = hour(localTime); @@ -5922,7 +5921,7 @@ uint16_t mode_2Dscrollingtext(void) { sprintf_P(sec, PSTR(":%02d"), second(localTime)); } - if (!numberOfLetters) { // fallback if empty segment name: display date and time + if (!strlen(text)) { // fallback if empty segment name: display date and time sprintf_P(text, PSTR("%s %d, %d %d:%02d%s"), monthShortStr(month(localTime)), day(localTime), year(localTime), AmPmHour, minute(localTime), sec); } else { if (!strncmp_P(text,PSTR("#DATE"),5)) sprintf_P(text, zero?PSTR("%02d.%02d.%04d"):PSTR("%d.%d.%d"), day(localTime), month(localTime), year(localTime)); @@ -5932,6 +5931,7 @@ uint16_t mode_2Dscrollingtext(void) { else if (!strncmp_P(text,PSTR("#HHMM"),5)) sprintf_P(text, zero?PSTR("%02d:%02d") :PSTR("%d:%02d"), AmPmHour, minute(localTime)); } + const int numberOfLetters = strlen(text); const unsigned long now = millis(); // reduce millis() calls int width = (numberOfLetters * rotLW); int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-rotLH)/2;