Skip to content

Commit 2656e07

Browse files
author
oclyke
committed
standardize RTC api for setTime and setAlarm
In v1.x.x we are using (hh, mm, ss, hund, dom, mon, year) Planning to change api in v2.0.0 to (hund, mm, ss, hh, dom, mon, year)
1 parent a2279ed commit 2656e07

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

libraries/RTC/examples/Example1_Get_Time/Example1_Get_Time.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void setup()
2525
myRTC.setToCompilerTime();
2626

2727
// Manually set RTC date and time
28-
//myRTC.setTime(0, 50, 59, 12, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
28+
//myRTC.setTime(12, 59, 50, 0, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
2929
}
3030

3131
void loop()

libraries/RTC/examples/Example2_Set_Alarms/Example2_Set_Alarms.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ void setup()
2828
//myRTC.setToCompilerTime();
2929

3030
// Manually set RTC date and time
31-
myRTC.setTime(0, 50, 59, 12, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
31+
myRTC.setTime(12, 59, 50, 0, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
3232

3333
// Set the RTC's alarm
34-
myRTC.setAlarm(0, 0, 0, 13, 3, 6); // 13:00:00.000, June 3rd (hund, ss, mm, hh, dd, mm). Note: No year alarm register
35-
34+
myRTC.setAlarm(13, 0, 0, 0, 3, 6); // 13:00:00.000, June 3rd (hund, ss, mm, hh, dd, mm). Note: No year alarm register
3635
// Set the RTC alarm mode
3736
/*
3837
0: Alarm interrupt disabled

libraries/RTC/examples/Example3_Test_RTC/Example3_Test_RTC.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ void setup()
1818
Serial.println("Artemis RTC Testing");
1919

2020
// Manually set RTC date and time
21-
myRTC.setTime(0, 59, 59, 23, 1, 1, 20); // Set to 1 second before midnight
21+
myRTC.setTime(23, 59, 59, 0, 1, 1, 20); // Set to 1 second before midnight
2222
}
2323

2424
void loop()
2525
{
2626
printArtemisTime();
2727

2828
myRTC.getTime();
29-
myRTC.setTime(99, 59, 59, 23, myRTC.dayOfMonth, myRTC.month, myRTC.year); // Manually set RTC
29+
myRTC.setTime(23, 59, 59, 99, myRTC.dayOfMonth, myRTC.month, myRTC.year); // Manually set RTC
3030
delay(11); //Allow us to roll from midnight the night before to the new day
3131
}
3232

libraries/RTC/examples/Example5_Rolling_Alarms/Example5_Rolling_Alarms.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ void setup()
2828
//myRTC.setToCompilerTime();
2929

3030
// Manually set RTC date and time
31-
myRTC.setTime(0, 50, 59, 12, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
31+
myRTC.setTime(12, 59, 50, 0, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
3232

3333
// Set the RTC's alarm
34-
myRTC.setAlarm(0, 0, 0, 13, 3, 6); // 13:00:00.000, June 3rd (hund, ss, mm, hh, dd, mm). Note: No year alarm register
34+
myRTC.setAlarm(13, 0, 0, 0, 3, 6); // 13:00:00.000, June 3rd (hund, ss, mm, hh, dd, mm). Note: No year alarm register
3535

3636
// Set the RTC alarm mode
3737
/*
@@ -63,9 +63,10 @@ void loop()
6363
alarmFlag = false;
6464

6565
// Set the RTC's rolling alarm
66-
myRTC.setAlarm(0, (myRTC.seconds + alarmSeconds) % 60,
66+
myRTC.setAlarm((myRTC.hour + alarmHours) % 24,
6767
(myRTC.minute + alarmMinutes) % 60,
68-
(myRTC.hour + alarmHours) % 24,
68+
(myRTC.seconds + alarmSeconds) % 60,
69+
0,
6970
myRTC.dayOfMonth,
7071
myRTC.month);
7172
myRTC.setAlarmMode(6);

libraries/RTC/examples/Example6_LowPower_Alarm/Example6_LowPower_Alarm.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ void setup()
2424
//myRTC.setToCompilerTime();
2525

2626
// Manually set RTC date and time
27-
myRTC.setTime(0, 50, 59, 12, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
27+
myRTC.setTime(12, 59, 50, 0, 3, 6, 20); // 12:59:50.000, June 3rd, 2020 (hund, ss, mm, hh, dd, mm, yy)
2828

2929
// Set the RTC's alarm
30-
myRTC.setAlarm(0, 0, 0, 13, 3, 6); // 13:00:00.000, June 3rd (hund, ss, mm, hh, dd, mm). Note: No year alarm register
30+
myRTC.setAlarm(13, 0, 0, 0, 3, 6); // 13:00:00.000, June 3rd (hund, ss, mm, hh, dd, mm). Note: No year alarm register
3131

3232
// Set the RTC alarm mode
3333
/*

libraries/RTC/src/RTC.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ APM3_RTC::APM3_RTC()
5454

5555
// Note: Order of parameters to change in v2.0.0.
5656
void APM3_RTC::setTime(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month, uint16_t year)
57-
57+
{
5858
hal_time.ui32Weekday = am_util_time_computeDayofWeek(2000 + year, month, dayOfMonth); //computeDayofWeek is expecting 1 to 12 months
5959
hal_time.ui32Century = 0;
6060
hal_time.ui32Year = year;
@@ -157,7 +157,8 @@ void APM3_RTC::getAlarm()
157157
alarmHundredths = alm_time.ui32Hundredths;
158158
}
159159

160-
void APM3_RTC::setAlarm(uint8_t hund, uint8_t sec, uint8_t min, uint8_t hour, uint8_t dayOfMonth, uint8_t month)
160+
// Note: Order of parameters to change in v2.0.0.
161+
void APM3_RTC::setAlarm(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month)
161162
{
162163
alm_time.ui32Weekday = 0; // WIP
163164
alm_time.ui32Month = month;

libraries/RTC/src/RTC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class APM3_RTC
1717
void setEpoch(uint32_t ts); //Set current time to provided UNIX Epoch time
1818

1919
void getAlarm(); //Query the RTC for the current alarm time/date
20-
void setAlarm(uint8_t hund, uint8_t sec, uint8_t min, uint8_t hour, uint8_t dayOfMonth, uint8_t month); //Set alarm time to provided hundredths/seconds/etc
20+
void setAlarm(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month); //Set alarm time to provided hundredths/seconds/etc
2121
void setAlarmMode(uint8_t mode); //Set the RTC alarm repeat interval
2222
void attachInterrupt(); //Attach the RTC alarm interrupt
2323
void detachInterrupt(); //Detach the RTC alarm interrupt

0 commit comments

Comments
 (0)