Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5960,10 +5960,16 @@ uint16_t mode_2Dscrollingtext(void) {
else if (!strncmp_P(text,PSTR("#DDMM"),5)) sprintf_P(text, zero?PSTR("%02d.%02d") :PSTR("%d.%d"), day(localTime), month(localTime));
else if (!strncmp_P(text,PSTR("#MMDD"),5)) sprintf_P(text, zero?PSTR("%02d/%02d") :PSTR("%d/%d"), month(localTime), day(localTime));
else if (!strncmp_P(text,PSTR("#TIME"),5)) sprintf_P(text, zero?PSTR("%02d:%02d%s") :PSTR("%2d:%02d%s"), AmPmHour, minute(localTime), sec);
else if (!strncmp_P(text,PSTR("#HHMM"),5)) sprintf_P(text, zero?PSTR("%02d:%02d") :PSTR("%d:%02d"), AmPmHour, minute(localTime));
else if (!strncmp_P(text,PSTR("#HH"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), AmPmHour);
Copy link
Copy Markdown
Member

@softhack007 softhack007 Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove #HHMM and #HH ?
Some user might have them in their preset. We should stay backwards-compatible.

else if (!strncmp_P(text,PSTR("#MM"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), minute(localTime));
Copy link
Copy Markdown
Member

@softhack007 softhack007 Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem here - changing the meaning of #MM from "minutes" to "month" is not backwards-compatible either.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is an unacceptable change.

}
else if (!strncmp_P(text,PSTR("#hhmm"),5)) sprintf_P(text, zero?PSTR("%02d:%02d") :PSTR("%d:%02d"), AmPmHour, minute(localTime));
else if (!strncmp_P(text,PSTR("#DD"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), day(localTime));
else if (!strncmp_P(text,PSTR("#MMM"),4)) sprintf_P(text, zero?PSTR("%s") :PSTR("%s"), monthShortStr(month(localTime)));
else if (!strncmp_P(text,PSTR("#MM"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), month(localTime));
else if (!strncmp_P(text,PSTR("#YYYY"),5)) sprintf_P(text, zero?PSTR("%04d") :PSTR("%d"), year(localTime));
else if (!strncmp_P(text,PSTR("#YY"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), year(localTime)-2000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a better way is year(localTime)%100 instead of subtracting 2000.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on %100 way and keeping it backwards-compatible. I dont get the upper case part.
So keep #HH, #MM and add #MON, #MONTH, #SS, #YY, #YEAR ?

else if (!strncmp_P(text,PSTR("#hh"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), AmPmHour);
else if (!strncmp_P(text,PSTR("#mm"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), minute(localTime));
else if (!strncmp_P(text,PSTR("#ss"),3)) sprintf_P(text, zero?PSTR("%s") :PSTR("%s"), &sec[1]);
}

const int numberOfLetters = strlen(text);
const unsigned long now = millis(); // reduce millis() calls
Expand Down