Closed
Description
The setAlarmCallback
method implementation uses "if / else if" so only the first field is used:
ArduinoCore-renesas/libraries/RTC/src/RTC.cpp
Lines 658 to 659 in b82e642
...
ArduinoCore-renesas/libraries/RTC/src/RTC.cpp
Lines 671 to 676 in b82e642
If you try, for example, to set an alarm for 09:10:04 it will fire every time the second is 4:
#include "RTC.h"
void setup() {
Serial.begin(115200);
RTC.begin();
RTCTime starttime(29, Month::SEPTEMBER, 2023, 14, 00, 00,
DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_INACTIVE);
RTC.setTime(starttime);
RTCTime alarme;
alarme.setHour(9);
alarme.setMinute(10);
alarme.setSecond(4);
AlarmMatch am;
am.addMatchHour();
am.addMatchMinute();
am.addMatchSecond();
if (!RTC.setAlarmCallback(alarm_cbk, alarme, am)) {
Serial.println("ERROR: alarm callback not set");
}
}
bool beep = false;
void alarm_cbk() {
beep = true;
}
void loop() {
if (beep) {
Serial.println("BEEP");
beep = false;
}
delay (100);
}
The setAlarmCallback
method could be implemented as follows:
at.min_match = m.isMatchingSecond();
at.sec_match = m.isMatchingMinute();
...