Skip to content

Commit d3bd832

Browse files
author
oclyke
committed
automatically update internal structures on setTime and setToCompilerTime
This allows the user to immediately access correct internal values (myRTC.weekday, myRTC.minute, etc...) ``` myRTC.setTime(23, 59, 59, 99, myRTC.dayOfMonth, myRTC.month, myRTC.year); previousDay = myRTC.weekday; ``` Updated Example3 to make use of this feature
1 parent 751ab8f commit d3bd832

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

libraries/RTC/examples/Example3_Test_RTC/Example3_Test_RTC.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ void setup()
1717
delay(10);
1818
Serial.println("Artemis RTC Testing");
1919

20-
// Manually set RTC date and time
21-
myRTC.setTime(23, 59, 59, 0, 1, 1, 20); // Set to 1 second before midnight
22-
myRTC.getTime();
20+
// Manually set RTC date and time to the start of 2020 so that myRTC contains valid times
21+
myRTC.setTime(23, 59, 59, 0, 1, 1, 20); // Set to 1 second before midnight Jan 1
2322
}
2423

2524
void loop()
2625
{
27-
myRTC.setTime(23, 59, 59, 99, myRTC.dayOfMonth, myRTC.month, myRTC.year); // Manually set RTC
28-
myRTC.getTime();
26+
myRTC.setTime(23, 59, 59, 99, myRTC.dayOfMonth, myRTC.month, myRTC.year); // Manually set RTC 1/100th of a second from the next day
2927
previousDay = myRTC.weekday;
3028
delay(11); //Allow us to roll from midnight the night before to the new day
3129

libraries/RTC/src/RTC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void APM3_RTC::setTime(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uin
6666
hal_time.ui32Hundredths = hund;
6767

6868
am_hal_rtc_time_set(&hal_time); //Initialize the RTC with this date/time
69+
getTime();
6970
}
7071

7172
//Takes the time from the last build and uses it as the current time
@@ -85,6 +86,7 @@ void APM3_RTC::setToCompilerTime()
8586
hal_time.ui32Hundredths = 00;
8687

8788
am_hal_rtc_time_set(&hal_time); //Initialize the RTC with this date/time
89+
getTime();
8890
}
8991

9092
void APM3_RTC::setEpoch(uint32_t ts)

0 commit comments

Comments
 (0)