feat: DS3231 RTC read/set with lost-power detection

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 19:55:47 +07:00
co-authored by Claude Opus 4.8
parent d042a94378
commit 2d52fcd851
3 changed files with 43 additions and 3 deletions
+20
View File
@@ -0,0 +1,20 @@
#include <RTClib.h>
#include "rtc_time.h"
static RTC_DS3231 rtc;
bool rtcBegin() { return rtc.begin(); }
bool rtcLostPower() { return rtc.lostPower(); }
RtcTime rtcNow() {
DateTime n = rtc.now();
return RtcTime{ n.year(), n.month(), n.day(), n.hour(), n.minute(), n.second() };
}
void rtcSet(const RtcTime& t) {
rtc.adjust(DateTime(t.year, t.month, t.day, t.hour, t.minute, t.second));
}
uint32_t rtcEpoch() {
return rtc.now().unixtime();
}