Add alarms to example
This commit is contained in:
parent
7e8a6b0dad
commit
a83671bda5
@ -1 +1 @@
|
||||
Subproject commit 2a90cdee18579b8897c572f6cd110efbc1c82f02
|
||||
Subproject commit dfd2289aefcf71238e55344084716943033e5101
|
@ -218,6 +218,9 @@
|
||||
<Compile Include="clock.hpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ds3231\alarms.hpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ds3231\ds3231.hpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
|
@ -137,6 +137,16 @@ int main()
|
||||
ds3231.init();
|
||||
serial.init();
|
||||
|
||||
ds3231.clearAlarm1();
|
||||
ds3231.clearAlarm2();
|
||||
|
||||
rtc::DateTime alarmTime;
|
||||
alarmTime.second = 17;
|
||||
alarmTime.minute = 54;
|
||||
|
||||
ds3231.setAlarm1(alarmTime, rtc::Alarm1Rate::WHEN_S_MATCH);
|
||||
ds3231.setAlarm2(alarmTime, rtc::Alarm2Rate::WHEN_M_MATCH);
|
||||
|
||||
auto oldDate = ds3231.getDateTime();
|
||||
|
||||
while (true) {
|
||||
@ -147,6 +157,16 @@ int main()
|
||||
printLocalTime(date);
|
||||
}
|
||||
|
||||
if (ds3231.checkAlarm1()) {
|
||||
serial << F("Alarm1!\r\n");
|
||||
ds3231.clearAlarm1();
|
||||
}
|
||||
|
||||
if (ds3231.checkAlarm2()) {
|
||||
serial << F("Alarm2!\r\n");
|
||||
ds3231.clearAlarm2();
|
||||
}
|
||||
|
||||
uint8_t receivedByte;
|
||||
|
||||
if (serial.rxByte(receivedByte)) {
|
||||
|
Loading…
Reference in New Issue
Block a user