9static const uint8_t RX8130_REG_SEC = 0x10;
10static const uint8_t RX8130_REG_MIN = 0x11;
11static const uint8_t RX8130_REG_HOUR = 0x12;
12static const uint8_t RX8130_REG_WDAY = 0x13;
13static const uint8_t RX8130_REG_MDAY = 0x14;
14static const uint8_t RX8130_REG_MONTH = 0x15;
15static const uint8_t RX8130_REG_YEAR = 0x16;
16static const uint8_t RX8130_REG_EXTEN = 0x1C;
17static const uint8_t RX8130_REG_FLAG = 0x1D;
18static const uint8_t RX8130_REG_CTRL0 = 0x1E;
19static const uint8_t RX8130_REG_CTRL1 = 0x1F;
20static const uint8_t RX8130_REG_DIG_OFFSET = 0x30;
21static const uint8_t RX8130_BIT_CTRL_STOP = 0x40;
22static const uint8_t RX8130_BAT_FLAGS = 0x30;
23static const uint8_t RX8130_CLEAR_FLAGS = 0x00;
25static const char *
const TAG =
"rx8130";
63 ESP_LOGCONFIG(TAG,
"RX8130:");
65 RealTimeClock::dump_config();
75 .second =
bcd2dec(date[0] & 0x7f),
76 .minute =
bcd2dec(date[1] & 0x7f),
77 .hour =
bcd2dec(date[2] & 0x3f),
78 .day_of_week =
bcd2dec(date[3] & 0x7f),
79 .day_of_month =
bcd2dec(date[4] & 0x3f),
81 .month =
bcd2dec(date[5] & 0x1f),
82 .year =
static_cast<uint16_t
>(
bcd2dec(date[6]) + 2000),
87 if (!rtc_time.is_valid()) {
88 ESP_LOGE(TAG,
"Invalid RTC time, not syncing to system clock.");
91 ESP_LOGD(TAG,
"Read UTC time: %04d-%02d-%02d %02d:%02d:%02d", rtc_time.year, rtc_time.month, rtc_time.day_of_month,
92 rtc_time.hour, rtc_time.minute, rtc_time.second);
99 ESP_LOGE(TAG,
"Invalid system time, not syncing to RTC.");
121 const uint8_t
data =
stop ? RX8130_BIT_CTRL_STOP : RX8130_CLEAR_FLAGS;
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len) const
writes an array of bytes to a specific register in the I²C device
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
void dump_config() override
ESPTime now()
Get the time in the currently defined timezone.
ESPTime utcnow()
Get the time without any time zone or DST corrections.
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
@ ERROR_OK
No error found during execution of method.
constexpr uint8_t dec2bcd(uint8_t val)
constexpr uint8_t bcd2dec(uint8_t val)
Providing packet encoding functions for exchanging data with a remote host.
A more user-friendly version of struct tm from time.h.
uint8_t minute
minutes after the hour [0-59]
void recalc_timestamp_utc(bool use_day_of_year=true)
Recalculate the timestamp field from the other fields of this ESPTime instance (must be UTC).
uint8_t second
seconds after the minute [0-60]
uint8_t hour
hours since midnight [0-23]
bool is_valid() const
Check if this ESPTime is valid (all fields in range and year is greater than 2018)
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]
uint8_t day_of_week
day of the week; sunday=1 [1-7]