Files
Arduino/WeatherPredictor/rtc_time.cpp
T
2026-07-17 19:55:47 +07:00

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();
}