21 lines
460 B
C++
21 lines
460 B
C++
#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();
|
|
}
|