Skip to content

Commit 34393bb

Browse files
committed
Fixed the "Noon O'clock" bug, again...
1 parent 258ed73 commit 34393bb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

wordclock/wordclock.ino

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
#define numberOfDigits 16
99
const byte dataPin = A4;
1010
const byte clockPin = A5;
11-
const byte loadPin = A2;
1211

1312
LEDDisplayDriver display(dataPin, clockPin, true, numberOfDigits);
14-
DISPLAY_INTR(display)
1513

16-
char dateTimeString[50];
14+
char dateTimeString[32];
1715

1816
ThreeWire myWire(9, 8, 10); // IO, SCLK, CE
1917
RtcDS1302<ThreeWire> Rtc(myWire);
@@ -56,6 +54,7 @@ void setup() {
5654
Serial.println(dateTimeString);
5755
if (now < compiled) {
5856
Serial.println("RTC is older than compile time! (Updating DateTime)");
57+
display.showTextScroll("RTC is older than compile time! (Updating DateTime)");
5958
Rtc.SetDateTime(compiled);
6059
} else if (now > compiled) {
6160
Serial.println("RTC is newer than compile time. (this is expected)");
@@ -71,10 +70,10 @@ void loop() {
7170
// Common Causes:
7271
// 1) the battery on the device is low or even missing and the power line was disconnected
7372
Serial.println("RTC lost confidence in the DateTime!");
74-
display.showText("CLOCK BAD!?");
73+
display.showTextScroll("CLOCK BAD!?");
7574
} else {
7675
populateTimeString(now);
77-
display.showText(dateTimeString);
76+
display.showTextScroll(dateTimeString);
7877
delay(2000);
7978
populateTimeString2(now);
8079
display.showTextScroll(dateTimeString);
@@ -106,15 +105,15 @@ void populateTimeString2(const RtcDateTime& dt) {
106105
hour -= 12;
107106
}
108107
int minute = dt.Minute();
108+
if (minute >= 33) {
109+
hour++;
110+
}
109111
const char *separator = " ";
110112
const char *hourStr = getHour(hour);
111113
const char *minuteStr = getMinute(minute);
112-
if (minute >= 33) {
113-
hourStr = getHour(hour + 1);
114-
}
115114

116115
if (minute >= 58 || minute <= 3) {
117-
if (hour == 0 || hour == 12) {
116+
if (hour == 0 || hour == 12 || hour == 24) {
118117
// don't show "noon o'clock"
119118
minuteStr = "";
120119
separator = "";
@@ -161,7 +160,7 @@ const char *getMinute(int minute) {
161160
case 28: case 29: case 30: case 31: case 32: return "Half Past";
162161
case 33: case 34: case 35: case 36: return "Twenty five to";
163162
case 37: case 38: case 39: case 40: case 41: case 42: case 43: return "Twenty to";
164-
case 44: case 45: case 46: return "A Quarter to";
163+
case 44: case 45: case 46: return "Quarter to";
165164
case 47: case 48: case 49: case 50: case 51: case 52: return "Ten to";
166165
case 53: case 54: case 55: case 56: case 57: return "Five to";
167166
}

0 commit comments

Comments
 (0)