6 #ifndef ACE_TIME_DS3231_CLOCK_H
7 #define ACE_TIME_DS3231_CLOCK_H
11 #include "../hw/DS3231.h"
12 #include "../hw/HardwareDateTime.h"
23 template<
typename T_WIREI>
28 mDS3231(wireInterface)
36 mDS3231.readDateTime(&hardwareDateTime);
37 return toDateTime(hardwareDateTime).toEpochSeconds();
40 void setNow(acetime_t epochSeconds)
override {
43 LocalDateTime now = LocalDateTime::forEpochSeconds(epochSeconds);
44 mDS3231.setDateTime(toHardwareDateTime(now));
53 return LocalDateTime::forComponents(
80 const hw::DS3231<T_WIREI> mDS3231;
Abstract base class for objects that provide and store time.
static const acetime_t kInvalidSeconds
Error value returned by getNow() and other methods when this object is not yet initialized.
An implementation of Clock that uses a DS3231 RTC chip.
acetime_t getNow() const override
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).
void setup()
Setup that currently does nothing.
DS3231Clock(const T_WIREI &wireInterface)
Constructor.
void setNow(acetime_t epochSeconds) override
Set the time to the indicated seconds.
The date (year, month, day) and time (hour, minute, second) fields supported by the DS3231 RTC chip.
static const int16_t kBaseYear
Base year of the DS3231 chip.
uint8_t year
[00, 99], year - 2000