8
8
#define numberOfDigits 16
9
9
const byte dataPin = A4;
10
10
const byte clockPin = A5;
11
- const byte loadPin = A2;
12
11
13
12
LEDDisplayDriver display (dataPin, clockPin, true , numberOfDigits);
14
- DISPLAY_INTR (display)
15
13
16
- char dateTimeString[50 ];
14
+ char dateTimeString[32 ];
17
15
18
16
ThreeWire myWire (9 , 8 , 10 ); // IO, SCLK, CE
19
17
RtcDS1302<ThreeWire> Rtc (myWire);
@@ -56,6 +54,7 @@ void setup() {
56
54
Serial.println (dateTimeString);
57
55
if (now < compiled) {
58
56
Serial.println (" RTC is older than compile time! (Updating DateTime)" );
57
+ display.showTextScroll (" RTC is older than compile time! (Updating DateTime)" );
59
58
Rtc.SetDateTime (compiled);
60
59
} else if (now > compiled) {
61
60
Serial.println (" RTC is newer than compile time. (this is expected)" );
@@ -71,10 +70,10 @@ void loop() {
71
70
// Common Causes:
72
71
// 1) the battery on the device is low or even missing and the power line was disconnected
73
72
Serial.println (" RTC lost confidence in the DateTime!" );
74
- display.showText (" CLOCK BAD!?" );
73
+ display.showTextScroll (" CLOCK BAD!?" );
75
74
} else {
76
75
populateTimeString (now);
77
- display.showText (dateTimeString);
76
+ display.showTextScroll (dateTimeString);
78
77
delay (2000 );
79
78
populateTimeString2 (now);
80
79
display.showTextScroll (dateTimeString);
@@ -106,15 +105,15 @@ void populateTimeString2(const RtcDateTime& dt) {
106
105
hour -= 12 ;
107
106
}
108
107
int minute = dt.Minute ();
108
+ if (minute >= 33 ) {
109
+ hour++;
110
+ }
109
111
const char *separator = " " ;
110
112
const char *hourStr = getHour (hour);
111
113
const char *minuteStr = getMinute (minute);
112
- if (minute >= 33 ) {
113
- hourStr = getHour (hour + 1 );
114
- }
115
114
116
115
if (minute >= 58 || minute <= 3 ) {
117
- if (hour == 0 || hour == 12 ) {
116
+ if (hour == 0 || hour == 12 || hour == 24 ) {
118
117
// don't show "noon o'clock"
119
118
minuteStr = " " ;
120
119
separator = " " ;
@@ -161,7 +160,7 @@ const char *getMinute(int minute) {
161
160
case 28 : case 29 : case 30 : case 31 : case 32 : return " Half Past" ;
162
161
case 33 : case 34 : case 35 : case 36 : return " Twenty five to" ;
163
162
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" ;
165
164
case 47 : case 48 : case 49 : case 50 : case 51 : case 52 : return " Ten to" ;
166
165
case 53 : case 54 : case 55 : case 56 : case 57 : return " Five to" ;
167
166
}
0 commit comments