feat: DS3231 RTC read/set with lost-power detection
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user