File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ void loop(void)
102102 tm.Minute = Serial.parseInt ();
103103 tm.Second = Serial.parseInt ();
104104 t = makeTime (tm);
105- RTC.write (tm);
105+ RTC.set (t); // use the time_t value to ensure correct weekday is set
106106 setTime (t);
107107 Serial << F (" RTC set to: " );
108108 printDateTime (t);
Original file line number Diff line number Diff line change @@ -29,12 +29,13 @@ void setup(void)
2929 delay (2000 );
3030 Serial . begin(9600 );
3131
32- tm. Hour = 23 ; // set the tm structure to 23h31m30s on 13Feb2009
32+ tm. Hour = 23 ; // set the tm structure to 23h31m30s on Fri 13Feb2009
3333 tm. Minute = 31 ;
3434 tm. Second = 30 ;
3535 tm. Year = 2009 - 1970 ; // tmElements_t.Year is the offset from 1970.
3636 tm. Month = 2 ;
3737 tm. Day = 13 ;
38+ tm. Wday = dowFriday; // See enum in Time.h: Sun=1, Mon=2, ... Sat=7
3839 RTC . write(tm); // set the RTC from the tm structure
3940}
4041
Original file line number Diff line number Diff line change @@ -72,9 +72,9 @@ void readCommand()
7272 tmSet. Hour = 10 * (cmd[15 ] - ' 0' ) + cmd[16 ] - ' 0' ;
7373 tmSet. Minute = 10 * (cmd[18 ] - ' 0' ) + cmd[19 ] - ' 0' ;
7474 tmSet. Second = 10 * (cmd[21 ] - ' 0' ) + cmd[22 ] - ' 0' ;
75- tSet = makeTime(tmSet); // convert to time_t
76- setTime(tSet); // set the system time
77- RTC . set(now()); // set the rtc
75+ tSet = makeTime(tmSet); // convert to time_t
76+ setTime(tSet); // set the system time
77+ RTC . set(now()); // set the rtc
7878 Serial . println(" RTC set!" );
7979 flushInput(); // discard any extraneous trailing characters
8080 }
You can’t perform that action at this time.
0 commit comments