4 #ifndef __M5_RTC8563_CLASS_H__
5 #define __M5_RTC8563_CLASS_H__
11 #if __has_include(<sys/time.h>)
26 rtc_time_t(std::int8_t hours_ = -1, std::int8_t minutes_ = -1, std::int8_t seconds_ = -1)
28 , minutes { minutes_ }
29 , seconds { seconds_ }
32 rtc_time_t(
const tm& t)
33 : hours { (int8_t)t.tm_hour }
34 , minutes { (int8_t)t.tm_min }
35 , seconds { (int8_t)t.tm_sec }
53 rtc_date_t(std::int16_t year_ = 2000, std::int8_t month_ = 1, std::int8_t date_ = -1, std::int8_t weekDay_ = -1)
57 , weekDay { weekDay_ }
60 rtc_date_t(
const tm& t)
61 : year { (int16_t)(t.tm_year + 1900) }
62 , month { (int8_t )(t.tm_mon + 1 ) }
63 , date { (int8_t ) t.tm_mday }
64 , weekDay { (int8_t ) t.tm_wday }
72 rtc_datetime_t() =
default;
73 rtc_datetime_t(
const rtc_date_t& d,
const rtc_time_t& t) : date { d }, time { t } {};
74 rtc_datetime_t(
const tm& t) : date { t }, time { t } {}
75 tm get_tm(
void)
const;
76 void set_tm(tm& time);
77 void set_tm(tm* t) {
if (t) set_tm(*t); }
93 bool getTime(rtc_time_t* time)
const;
94 bool getDate(rtc_date_t* date)
const;
97 void setTime(
const rtc_time_t &time);
100 void setDate(
const rtc_date_t &date);
109 rtc_datetime_t dt { *datetime };
121 int setAlarmIRQ(
const rtc_date_t &date,
const rtc_time_t &time);
bool begin(I2C_Class *i2c=nullptr)
void setDateTime(const tm *const datetime)
void setDateTime(const rtc_datetime_t &datetime)
RTC8563_Class(std::uint8_t i2c_addr=DEFAULT_ADDRESS, std::uint32_t freq=400000, I2C_Class *i2c=&In_I2C)
void setDate(const rtc_date_t *const date)
void setSystemTimeFromRtc(struct timezone *tz=nullptr)
static constexpr std::uint8_t DEFAULT_ADDRESS
rtc_date_t getDate(void) const
void setDateTime(const rtc_datetime_t *const datetime)
rtc_time_t getTime(void) const
rtc_datetime_t getDateTime(void) const
void setTime(const rtc_time_t *const time)
void setDate(const rtc_date_t &date)
void setTime(const rtc_time_t &time)
int setAlarmIRQ(int afterSeconds)
struct __attribute__((packed)) rtc_time_t
I2C_Class In_I2C
for internal I2C device