10#ifndef M5_UNIT_RTC_UNIT_PCF8563_TYPES_HPP
11#define M5_UNIT_RTC_UNIT_PCF8563_TYPES_HPP
30 rtc_time_t(int8_t hours_ = -1, int8_t minutes_ = -1, int8_t seconds_ = -1)
31 : hours{hours_}, minutes{minutes_}, seconds{seconds_}
34 rtc_time_t(
const tm& t) : hours{(int8_t)t.tm_hour}, minutes{(int8_t)t.tm_min}, seconds{(int8_t)t.tm_sec}
55inline bool operator==(
const rtc_time_t& lhs,
const rtc_time_t& rhs)
57 return lhs.hours == rhs.hours && lhs.minutes == rhs.minutes && lhs.seconds == rhs.seconds;
59inline bool operator!=(
const rtc_time_t& lhs,
const rtc_time_t& rhs)
63inline bool operator<(
const rtc_time_t& lhs,
const rtc_time_t& rhs)
65 return std::tie(lhs.hours, lhs.minutes, lhs.seconds) < std::tie(rhs.hours, rhs.minutes, rhs.seconds);
67inline bool operator<=(
const rtc_time_t& lhs,
const rtc_time_t& rhs)
71inline bool operator>(
const rtc_time_t& lhs,
const rtc_time_t& rhs)
75inline bool operator>=(
const rtc_time_t& lhs,
const rtc_time_t& rhs)
95 rtc_date_t(int16_t year_ = 2000, int8_t month_ = 1, int8_t date_ = -1, int8_t weekDay_ = -1)
96 : year{year_}, month{month_}, date{date_}, weekDay{weekDay_}
99 rtc_date_t(
const tm& t)
100 : year{(int16_t)(t.tm_year + 1900)},
101 month{(int8_t)(t.tm_mon + 1)},
102 date{(int8_t)t.tm_mday},
103 weekDay{(int8_t)t.tm_wday}
115 t.tm_year = year - 1900;
116 t.tm_mon = month - 1;
125inline bool operator==(
const rtc_date_t& lhs,
const rtc_date_t& rhs)
127 return lhs.year == rhs.year && lhs.month == rhs.month && lhs.date == rhs.date;
129inline bool operator!=(
const rtc_date_t& lhs,
const rtc_date_t& rhs)
131 return !(lhs == rhs);
133inline bool operator<(
const rtc_date_t& lhs,
const rtc_date_t& rhs)
135 return std::tie(lhs.year, lhs.month, lhs.date) < std::tie(rhs.year, rhs.month, rhs.date);
137inline bool operator<=(
const rtc_date_t& lhs,
const rtc_date_t& rhs)
141inline bool operator>(
const rtc_date_t& lhs,
const rtc_date_t& rhs)
145inline bool operator>=(
const rtc_date_t& lhs,
const rtc_date_t& rhs)
174 explicit inline operator tm()
const
187 t.tm_year = date.year - 1900;
188 t.tm_mon = date.month - 1;
189 t.tm_mday = date.date;
190 t.tm_wday = date.weekDay;
191 t.tm_hour = time.hours;
192 t.tm_min = time.minutes;
193 t.tm_sec = time.seconds;
201inline bool operator==(
const rtc_datetime_t& lhs,
const rtc_datetime_t& rhs)
203 return lhs.date == rhs.date && lhs.time == rhs.time;
205inline bool operator!=(
const rtc_datetime_t& lhs,
const rtc_datetime_t& rhs)
207 return !(lhs == rhs);
209inline bool operator<(
const rtc_datetime_t& lhs,
const rtc_datetime_t& rhs)
211 if (lhs.date != rhs.date) {
212 return lhs.date < rhs.date;
214 return lhs.time < rhs.time;
216inline bool operator<=(
const rtc_datetime_t& lhs,
const rtc_datetime_t& rhs)
220inline bool operator>(
const rtc_datetime_t& lhs,
const rtc_datetime_t& rhs)
224inline bool operator>=(
const rtc_datetime_t& lhs,
const rtc_datetime_t& rhs)
Calendar date (year, month, day, weekday)
Definition unit_PCF8563_types.hpp:85
tm to_tm() const
Convert to struct tm (only date fields are set)
Definition unit_PCF8563_types.hpp:112
static rtc_date_t from_tm(const tm &t)
Construct from struct tm (date fields only)
Definition unit_PCF8563_types.hpp:107
Combined date and time.
Definition unit_PCF8563_types.hpp:155
tm to_tm() const
Convert to struct tm.
Definition unit_PCF8563_types.hpp:184
static rtc_datetime_t from_tm(const tm &t)
Construct from struct tm.
Definition unit_PCF8563_types.hpp:179
rtc_datetime_t & operator=(const tm &t)
Assign from struct tm.
Definition unit_PCF8563_types.hpp:167
Time of day (hours, minutes, seconds)
Definition unit_PCF8563_types.hpp:25
tm to_tm() const
Convert to struct tm (only time fields are set)
Definition unit_PCF8563_types.hpp:43
static rtc_time_t from_tm(const tm &t)
Construct from struct tm (time fields only)
Definition unit_PCF8563_types.hpp:38
ClockOutput
CLKOUT pin output frequency (register 0x0D)
Definition unit_PCF8563_types.hpp:245
@ Hz32768
32.768 kHz (FE=1, FD=00)
@ None
CLKOUT disabled (high-impedance)
@ Hz32
32 Hz (FE=1, FD=10)
@ Hz1024
1.024 kHz (FE=1, FD=01)
TimerClock
Timer clock source for PCF8563 countdown timer.
Definition unit_PCF8563_types.hpp:234
@ Hz64
64 Hz (~15.6ms resolution)
@ HzPM
1/60 Hz (1 minute resolution)
@ Hz1
1 Hz (1 second resolution)
@ Hz4096
4.096 kHz (~244us resolution)