Skip to content

Commit 4f61d4d

Browse files
committed
Fix midnight to show 12 instead of 0
1 parent 8d2ed24 commit 4f61d4d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

wordclock/wordclock.ino

+7-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ void setup() {
5858
if (now < compiled) {
5959
Serial.println("RTC is older than compile time! (Updating DateTime)");
6060
Rtc.SetDateTime(compiled);
61-
display.showTextScroll("RTC is older than compile time! (Updating DateTime)");
61+
display.showText("RTC is older than compile time! (Updating DateTime)");
62+
delay(1000);
6263
} else if (now > compiled) {
6364
Serial.println("RTC is newer than compile time. (this is expected)");
6465
} else if (now == compiled) {
@@ -94,6 +95,9 @@ void populateTimeString(const RtcDateTime& dt) {
9495
if (hour > 12) {
9596
hour -= 12;
9697
}
98+
if (hour == 0) {
99+
hour = 12;
100+
}
97101
snprintf_P(dateTimeString,
98102
countof(dateTimeString),
99103
PSTR("%02u:%02u %s"),
@@ -141,12 +145,12 @@ void populateTimeString2(const RtcDateTime& dt) {
141145
// I should math the shit out of this
142146
while (len < BUFFER_SIZE && numSpace < NUM_DIGITS) {
143147
numSpace++;
144-
len+=2;
148+
len += 2;
145149
}
146150
// Serial.print("oldlen: "); Serial.println(strlen(temp));
147151
// Serial.print("newlen: "); Serial.println(len);
148152
// Serial.print("numspace: "); Serial.println(numSpace);
149-
// Clear the final destination; copy the temporary string into the right
153+
// Clear the final destination; copy the temporary string into the right
150154
// spot, then fix the end-of-string marker.
151155
memset(dateTimeString, ' ', BUFFER_SIZE);
152156
strcpy(&dateTimeString[numSpace], temp);

0 commit comments

Comments
 (0)