5#ifdef USE_RX8111_TIMESTAMP
18#ifdef USE_BINARY_SENSOR
19PROGMEM_STRING_TABLE(StatusSensorNames,
"Voltage low flag",
"Alarm flag",
"Timer flag",
"Oscillation stop flag",
20 "Event flag",
"Battery low",
"EVIN");
22#ifdef USE_RX8111_TIMESTAMP
25PROGMEM_STRING_TABLE(BootFailureNames,
"RX8111 battery configuration failed",
"RX8111 FOUT configuration failed",
26 "RX8111 EVIN configuration failed", ESP_LOG_MSG_COMM_FAIL, ESP_LOG_MSG_COMM_FAIL);
28static constexpr uint8_t RX8111_REG_SEC = 0x10;
29static constexpr uint8_t RX8111_REG_MIN_ALARM = 0x17;
30static constexpr uint8_t RX8111_REG_EXTENSION = 0x1D;
31static constexpr uint8_t RX8111_REG_FLAG = 0x1E;
32static constexpr uint8_t RX8111_REG_TIMER0 = 0x1A;
33static constexpr uint8_t RX8111_REG_CONTROL = 0x1F;
34static constexpr uint8_t RX8111_REG_SEC_ALARM = 0x2C;
35static constexpr uint8_t RX8111_REG_TIMER_CONTROL = 0x2D;
36static constexpr uint8_t RX8111_REG_POWER_SWITCH = 0x32;
37static constexpr uint8_t RX8111_REG_TIMESTAMP_CONTROL = 0x34;
38#ifdef USE_RX8111_TIMESTAMP
39static constexpr uint8_t RX8111_REG_TIMESTAMP_STATUS = 0x36;
40static constexpr uint8_t RX8111_REG_TIMESTAMP_LATEST = 0x20;
41static constexpr uint8_t RX8111_REG_TIMESTAMP_BUFFER = 0x40;
42static constexpr uint8_t RX8111_TIMESTAMP_RAM = 0x01;
43static constexpr uint8_t RX8111_TIMESTAMP_CLEAR = 0x02;
44static constexpr uint8_t RX8111_TIMESTAMP_EMPTY = 0x08;
45static constexpr uint8_t RX8111_TIMESTAMP_FULL = 0x10;
46static constexpr uint8_t RX8111_EVIN_OVERWRITE = 0x02;
48static constexpr uint8_t RX8111_TIMESTAMP_EISEL = 0x04;
49static constexpr uint8_t RX8111_REG_EVIN = 0x2B;
50static constexpr uint8_t RX8111_EXTENSION_ETS = 0x04;
51static constexpr uint8_t RX8111_CONTROL_EIE = 0x04;
52static constexpr uint8_t RX8111_FLAG_EVF = 0x04;
53static constexpr uint8_t RX8111_POWER_CHGEN = 0x80;
54static constexpr uint8_t RX8111_POWER_INIEN = 0x40;
55static constexpr uint8_t RX8111_POWER_SWSEL = 0x0C;
56static constexpr uint8_t RX8111_POWER_VDD_ONLY = 0x08;
57static constexpr uint8_t RX8111_FOUT_FSEL = 0xC0;
58static constexpr uint8_t RX8111_TIMER_TMPIN = 0x02;
59static constexpr uint8_t RX8111_TIMER_MODE = 0x0F;
60static constexpr uint8_t RX8111_ALARM_DISABLED = 0x80;
61static constexpr uint8_t RX8111_EXTENSION_WADA = 0x08;
62static constexpr uint8_t RX8111_CONTROL_AIE = 0x08;
63static constexpr uint8_t RX8111_CONTROL_TIE = 0x10;
64static constexpr uint8_t RX8111_EXTENSION_TE = 0x10;
65static constexpr uint8_t RX8111_EXTENSION_TSEL = 0x03;
66static constexpr uint8_t RX8111_FLAG_TF = 0x10;
67static constexpr uint8_t RX8111_FLAG_AF = 0x08;
68static constexpr uint8_t RX8111_FLAG_POR = 0x80;
69static constexpr uint8_t RX8111_FLAG_VLF = 0x02;
70static constexpr uint8_t RX8111_FLAG_XST = 0x01;
71#ifdef USE_BINARY_SENSOR
72static constexpr uint8_t RX8111_REG_STATUS = 0x33;
73static constexpr uint8_t RX8111_STATUS_VLOW = 0x02;
74static constexpr uint8_t RX8111_STATUS_EVIN = 0x40;
75static constexpr uint8_t STATUS_SENSOR_MASKS[] PROGMEM = {
76 RX8111_FLAG_VLF, RX8111_FLAG_AF, RX8111_FLAG_TF, RX8111_FLAG_XST,
77 RX8111_FLAG_EVF, RX8111_STATUS_VLOW, RX8111_STATUS_EVIN,
81static constexpr uint8_t RX8111_CTRL_STOP = 0x01;
83static constexpr uint8_t RX8111_KEEP_EVENT_FLAGS = 0x3C;
84static constexpr uint32_t RX8111_EVENT_INTERVAL_ID = 0;
85static constexpr uint32_t RX8111_BOOT_ALARM_RETRY_ID = 1;
86static constexpr uint32_t RX8111_BOOT_TIMER_RETRY_ID = 2;
87static constexpr uint32_t RX8111_BOOT_BATTERY_RETRY_ID = 3;
88static constexpr uint32_t RX8111_BOOT_FOUT_RETRY_ID = 4;
89static constexpr uint32_t RX8111_BOOT_EVENT_RETRY_ID = 5;
90static constexpr uint32_t RX8111_DEFERRED_UPDATE_ID = 6;
91static constexpr uint32_t RX8111_DEFERRED_STATUS_ID = 7;
92static constexpr uint8_t RX8111_BOOT_MAX_ATTEMPTS = 3;
95static bool mask_bcd_calendar(uint8_t *calendar) {
96 static constexpr uint8_t MASKS[7] PROGMEM = {0x7F, 0x7F, 0x3F, 0x00, 0x3F, 0x1F, 0xFF};
98 for (
size_t i = 0; i <
sizeof(MASKS); i++) {
102 valid =
valid && (calendar[i] & 0x0F) <= 9 && (calendar[i] >> 4) <= 9;
113#ifdef USE_RX8111_TIMESTAMP
121#ifdef USE_RX8111_TIMESTAMP
129#ifdef USE_BINARY_SENSOR
142#ifdef USE_RX8111_TIMESTAMP
159#ifdef USE_RX8111_TIMESTAMP
166#ifdef USE_RX8111_TIMESTAMP
170 if (!this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, 0) ||
171 !this->
read_byte(RX8111_REG_TIMESTAMP_CONTROL, &control))
174 const uint8_t
mode = buffered ? RX8111_TIMESTAMP_RAM : 0;
176 if (buffered && !(control & RX8111_TIMESTAMP_RAM))
177 control |= RX8111_TIMESTAMP_CLEAR;
178 control = (control & ~(RX8111_TIMESTAMP_RAM | RX8111_TIMESTAMP_EISEL)) |
mode;
181 this->
write_byte(RX8111_REG_TIMESTAMP_CONTROL, control) &&
184 this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, RX8111_EXTENSION_ETS);
189 return this->
update_register(RX8111_REG_CONTROL, RX8111_CONTROL_EIE, 0);
193 this->
update_register(RX8111_REG_TIMESTAMP_CONTROL, RX8111_TIMESTAMP_EISEL, 0) &&
194 this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, RX8111_EXTENSION_ETS) &&
195 this->
update_register(RX8111_REG_CONTROL, RX8111_CONTROL_EIE, RX8111_CONTROL_EIE);
200 if (!this->
write_byte(RX8111_REG_FLAG,
static_cast<uint8_t
>(~RX8111_FLAG_EVF))) {
212 const uint8_t
value = RX8111_POWER_VDD_ONLY | (this->
battery_backup_ ? RX8111_POWER_INIEN : 0) |
216 RX8111_POWER_INIEN | RX8111_POWER_CHGEN | RX8111_POWER_SWSEL,
value));
221 uint8_t timer_control;
222 bool success = this->
read_byte(RX8111_REG_TIMER_CONTROL, &timer_control);
223 if (success && this->
fout_frequency_ != 3 && (timer_control & RX8111_TIMER_TMPIN)) {
224 ESP_LOGW(TAG,
"FOUT is routed to the wake-up timer (TMPIN); cannot configure clock output");
226 }
else if (success) {
262 this->
set_warning_(config.warning, BootFailureNames::get_log_str(feature, BootFailureNames::LAST_INDEX));
263 if (attempts < RX8111_BOOT_MAX_ATTEMPTS) {
264 this->
set_timeout(config.retry_id, this->boot_retry_delay_ms_,
265 [
this, configure = config.configure]() { (this->*configure)(); });
286 success = this->
read_byte(RX8111_REG_CONTROL, &control);
288 this->
alarm_armed_ = (control & RX8111_CONTROL_AIE) != 0;
307 uint8_t extension, control;
322 this->
cancel_timeout(alarm ? RX8111_BOOT_ALARM_RETRY_ID : RX8111_BOOT_TIMER_RETRY_ID);
400 ESP_LOGCONFIG(TAG,
"RX8111:");
401 LOG_I2C_DEVICE(
this);
402#ifdef USE_BINARY_SENSOR
405 log_binary_sensor(TAG,
" ", LOG_STR_ARG(StatusSensorNames::get_log_str(i, StatusSensorNames::LAST_INDEX)),
410#ifdef USE_RX8111_TIMESTAMP
413 ESP_LOGCONFIG(TAG,
" Timestamp record mode: %s",
414 LOG_STR_ARG(TimestampModeNames::get_log_str(this->
timestamp_mode_, TimestampModeNames::LAST_INDEX)));
418 ESP_LOGCONFIG(TAG,
" Battery backup: %s, charging: %s", ONOFF(this->
battery_backup_),
422 ESP_LOGCONFIG(TAG,
" FOUT: %s", LOG_STR_ARG(FoutNames::get_log_str(this->
fout_frequency_, FoutNames::LAST_INDEX)));
425 ESP_LOGCONFIG(TAG,
" EVIN interrupt: %s", ONOFF(this->
event_enabled_));
427#ifdef USE_RX8111_TIMESTAMP
432 TAG,
" EVIN: %s, filter: %u, pull: %s",
433 (this->
evin_settings_ & 0x80) ? LOG_STR_LITERAL(
"high") : LOG_STR_LITERAL(
"low"),
435 LOG_STR_ARG(EvinPullNames::get_log_str((this->
evin_settings_ >> 2) & 7, EvinPullNames::LAST_INDEX)));
439 " Alarm interrupt: %s\n"
440 " Wake-up timer: %s",
443 ESP_LOGCONFIG(TAG,
" Count: %" PRIu32
", clock: %s", this->
timer_count_,
444 LOG_STR_ARG(TimerClockNames::get_log_str(this->
timer_clock_, TimerClockNames::LAST_INDEX)));
446 RealTimeClock::dump_config();
458 ESP_LOGD(TAG,
"Read UTC time: %04d-%02d-%02d %02d:%02d:%02d", rtc_time.
year, rtc_time.
month, rtc_time.
day_of_month,
476 if (
flags !=
nullptr)
478 if (!this->
read_bytes(RX8111_REG_FLAG, regs,
sizeof(regs))) {
482 if (
flags !=
nullptr)
484 if (regs[1] & RX8111_CTRL_STOP) {
488 if (regs[0] & (RX8111_FLAG_VLF | RX8111_FLAG_XST | RX8111_FLAG_POR)) {
489 ESP_LOGW(TAG,
"RTC time invalidated by power loss or oscillator stop; write trusted time");
496 if (!this->
read_bytes(RX8111_REG_SEC, buf,
sizeof(buf))) {
501 bool valid = mask_bcd_calendar(buf);
502 const uint8_t onehot = buf[3];
503 valid =
valid && onehot != 0 && onehot <= 0x40 && (onehot & (onehot - 1)) == 0;
505 rtc_time = time::decode_bcd_calendar<time::EPSON_BCD_CALENDAR>(buf);
510 ESP_LOGW(TAG,
"Invalid RTC time, not syncing to system clock");
521 ESP_LOGE(TAG,
"Invalid system time, not syncing to RTC");
530 time::encode_bcd_calendar<time::EPSON_BCD_CALENDAR>(
now, buf);
532 const bool calendar_written = this->
write_bytes(RX8111_REG_SEC, buf,
sizeof(buf));
542 if (!calendar_written) {
557 return this->
update_register(RX8111_REG_CONTROL, RX8111_CTRL_STOP, stop ? RX8111_CTRL_STOP : 0);
561 return this->
update_register(RX8111_REG_CONTROL, RX8111_CONTROL_AIE, enabled ? RX8111_CONTROL_AIE : 0);
567 if (!this->
read_byte(RX8111_REG_EXTENSION, &extension))
570 extension &= ~RX8111_EXTENSION_WADA;
572 extension |= RX8111_EXTENSION_WADA;
575 const uint8_t fields[] = {
581 : RX8111_ALARM_DISABLED,
593 if (!this->
write_byte(RX8111_REG_SEC_ALARM, fields[0]) || !this->
write_bytes(RX8111_REG_MIN_ALARM, &fields[1], 3) ||
594 !this->
write_byte(RX8111_REG_EXTENSION, extension))
604 ESP_LOGE(TAG,
"Alarm interrupt disabled; set alarm_enabled: true");
609 (weekday != unset && (weekday < 1 || weekday > 7)) || (
day != unset && (
day < 1 || day > 31)) ||
610 (weekday != unset &&
day != unset) ||
611 (
second == unset &&
minute == unset &&
hour == unset && weekday == unset &&
day == unset)) {
612 ESP_LOGE(TAG,
"Invalid alarm fields");
627 if (!this->
alarm_enabled_ || seconds == 0 || seconds >= 28U * 86400U) {
628 ESP_LOGE(TAG,
"Relative alarm requires alarm_enabled and a duration of 1 second to less than 28 days");
633 ESP_LOGE(TAG,
"Cannot read valid RTC time for relative alarm");
637 if (!target.is_valid() || target.year > 2099) {
638 ESP_LOGE(TAG,
"Relative alarm target is outside RTC year range");
652 static constexpr uint8_t DISABLED_FIELDS[3] = {RX8111_ALARM_DISABLED, RX8111_ALARM_DISABLED, RX8111_ALARM_DISABLED};
653 if (!this->
write_byte(RX8111_REG_SEC_ALARM, RX8111_ALARM_DISABLED) ||
654 !this->
write_bytes(RX8111_REG_MIN_ALARM, DISABLED_FIELDS,
sizeof(DISABLED_FIELDS))) {
663 if (!this->
write_byte(RX8111_REG_FLAG,
static_cast<uint8_t
>(~RX8111_FLAG_AF))) {
674 return this->
read_byte(RX8111_REG_EXTENSION, &extension) &&
675 this->
write_byte(RX8111_REG_EXTENSION, extension & ~RX8111_EXTENSION_TE) &&
676 this->
read_byte(RX8111_REG_CONTROL, &control) &&
677 this->
write_byte(RX8111_REG_CONTROL, control & ~RX8111_CONTROL_TIE);
689 if (!this->
update_register(RX8111_REG_TIMER_CONTROL, RX8111_TIMER_MODE, 0))
696 (extension & ~(RX8111_EXTENSION_TE | RX8111_EXTENSION_TSEL)) | this->
timer_clock_) ||
698 !this->
write_byte(RX8111_REG_CONTROL, control | RX8111_CONTROL_TIE))
701 (extension & ~RX8111_EXTENSION_TSEL) | this->
timer_clock_ | RX8111_EXTENSION_TE);
706 ESP_LOGW(TAG,
"Cannot start timer without a valid timer_count");
713 uint8_t extension, control;
728 if (!this->
write_byte(RX8111_REG_FLAG,
static_cast<uint8_t
>(~RX8111_FLAG_TF))) {
740 uint8_t extension, control;
752 bool flags_valid =
false;
753 switch (snapshot.
state) {
764 bool success = flags_valid;
765#ifdef USE_BINARY_SENSOR
769 const bool status_valid = !monitor_requested || this->
read_byte(RX8111_REG_STATUS, &
status);
770 success = success && status_valid;
779 const bool event_active = (
flags & RX8111_FLAG_EVF) != 0;
780 const bool event_rising =
784 const bool alarm_active = flags_valid && (
flags & RX8111_FLAG_AF) != 0;
785 const bool timer_active = flags_valid && (
flags & RX8111_FLAG_TF) != 0;
791 const bool timer_rising = timer_active && !this->
timer_flag_seen_ && timer_watched;
795 if (flags_valid && this->alarm_armed_)
798 if (flags_valid && timer_watched)
801 this->timer_retained_event_pending_ =
false;
802#ifdef USE_BINARY_SENSOR
807 if (this->
status_sensors_[i] !=
nullptr && (uses_flags ? flags_valid : status_valid)) {
813#ifdef USE_RX8111_TIMESTAMP
834#ifdef USE_RX8111_TIMESTAMP
850 if (!buffered &&
count != 0) {
854 for (uint8_t i = 0; i <
count; i++)
860 const uint8_t offset = buffered ? 1 : 2;
861 uint8_t calendar[7] = {
raw[offset],
raw[offset + 1],
raw[offset + 2], 1,
862 raw[buffered ? 4 : 6],
raw[buffered ? 5 : 7],
raw[buffered ? 6 : 8]};
864 const bool valid = mask_bcd_calendar(calendar) && (
raw[buffered ? 7 : 9] & 2) == 0;
865 const auto captured = time::decode_bcd_calendar<time::EPSON_BCD_CALENDAR>(calendar);
866 if (!
valid || !captured.is_valid(
true,
false) || captured.second > 59) {
867 ESP_LOGW(TAG,
"Skipping invalid RTC timestamp record");
870 const uint16_t fraction = buffered ?
raw[0] * 4 :
raw[1] * 4 + (
raw[0] & 3);
872 const unsigned milliseconds = fraction * 1000U / 1024U;
875 std::snprintf(
value,
sizeof(
value),
"%04u-%02u-%02uT%02u:%02u:%02u.%03uZ", captured.year, captured.month,
876 captured.day_of_month, captured.hour, captured.minute, captured.second, milliseconds);
882 if (!this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, RX8111_EXTENSION_ETS))
887 uint8_t records[64]{};
890 if (!this->
read_bytes(RX8111_REG_TIMESTAMP_LATEST, records, 10))
895 if (!startup && buffered) {
899 if (
status & RX8111_TIMESTAMP_EMPTY)
903 if (!this->
read_byte(RX8111_REG_EXTENSION, &extension))
905 const bool restore = (extension & RX8111_EXTENSION_ETS) != 0;
908 (flags & (RX8111_FLAG_POR | RX8111_FLAG_VLF | RX8111_FLAG_XST)) == 0 && ((
flags & RX8111_FLAG_EVF) || restore);
911 if (restore && !this->
write_byte(RX8111_REG_EXTENSION, extension & ~RX8111_EXTENSION_ETS)) {
924 }
else if (!buffered) {
925 success = this->
read_bytes(RX8111_REG_TIMESTAMP_LATEST, records, 10);
927 const bool publish_latest =
930 count = publish_latest ? 1 : 0;
934 if (success && !(
status & RX8111_TIMESTAMP_EMPTY)) {
935 const uint8_t latest =
status & 7;
936 const uint8_t available = (
status & RX8111_TIMESTAMP_FULL) ? 8 : latest + 1;
937 const uint8_t first = available == 8 ? (latest + 1) & 7 : 0;
938 for (uint8_t i = 0; i < available && success; i++)
939 success = this->
read_bytes(RX8111_REG_TIMESTAMP_BUFFER + (((first + i) & 7) * 8), records + i * 8, 8);
945 success = this->
update_register(RX8111_REG_TIMESTAMP_CONTROL, RX8111_TIMESTAMP_CLEAR, RX8111_TIMESTAMP_CLEAR);
967 if (!this->
update_register(RX8111_REG_TIMESTAMP_CONTROL, RX8111_TIMESTAMP_CLEAR, RX8111_TIMESTAMP_CLEAR))
976 const bool restored = !restore || this->
write_byte(RX8111_REG_EXTENSION, extension);
978 success = success && restored;
BedjetMode mode
BedJet operating mode.
void status_set_warning()
bool cancel_interval(const char *name)
Cancel an interval function.
bool cancel_timeout(const char *name)
Cancel a timeout function.
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
void defer(const char *name, std::function< void()> &&f)
Defer a callback to the next loop() call with a const char* name.
void set_interval(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a const char* name.
bool cancel_defer(const char *name)
Cancel a defer callback using the specified name, name must not be empty.
void status_clear_warning()
void publish_state(bool new_state)
Publish a new state to the front-end.
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
bool update_register(uint8_t a_register, uint8_t mask, uint8_t value)
Read a register, replace the bits in mask with those of value and write it back.
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void deliver_timestamps_(const uint8_t *records, uint8_t count, bool buffered)
static constexpr uint8_t ALARM_FIELD_UNSET
bool set_alarm(uint16_t second, uint16_t minute, uint16_t hour, uint16_t weekday, uint16_t day)
LazyCallbackManager< void()> alarm_callbacks_
uint8_t boot_attempts_[BOOT_FEATURE_COUNT]
bool timestamp_clear_pending_
bool program_alarm_(uint8_t second, uint8_t minute, uint8_t hour, uint8_t weekday, uint8_t day, bool boot=false)
void dump_config() override
void publish_staged_timestamps_()
bool poll_event_flags_(FlagSnapshot snapshot={})
bool disable_timer_(uint8_t &extension, uint8_t &control)
bool read_calendar_(ESPTime &rtc_time, FlagSnapshot *flags=nullptr)
void start_event_polling_()
void configure_boot_alarm_()
bool alarm_explicitly_configured_
void publish_timestamp_(const uint8_t *raw, bool buffered)
bool schedule_alarm_in(uint32_t seconds)
bool capture_restore_pending_
binary_sensor::BinarySensor * status_sensors_[STATUS_SENSOR_COUNT]
void read_time_(FlagSnapshot &flags)
bool configure_timer_(bool clear_stale_flag=false)
bool event_polling_started_
bool deferred_update_running_
bool boot_alarm_event_seen_
bool has_status_sensor_() const
void run_deferred_update_(bool status_only)
bool retained_latest_qualified_
bool set_alarm_interrupt_(bool enabled)
TimestampMode timestamp_mode_
void retry_fout_after_timer_start_()
bool timer_retained_event_pending_
text_sensor::TextSensor * timestamp_sensor_
bool finish_time_write_(bool calendar_written)
bool retained_flags_seen_
void cancel_boot_retry_(bool alarm)
uint32_t event_poll_interval_
uint8_t staged_timestamps_[64]
void boot_config_result_(BootFeature feature, bool success)
bool set_stop_bit_(bool stop)
void clear_warning_(uint16_t bit)
void check_event_flags_(FlagSnapshot flags={})
void configure_boot_event_()
bool retained_evidence_seen_
uint8_t last_timestamp_[10]
void configure_boot_battery_()
void set_warning_(uint16_t bit, const LogString *message)
bool publish_timestamps_(uint8_t flags, bool buffered, bool startup=false)
LazyCallbackManager< void()> event_callbacks_
LazyCallbackManager< void()> timer_callbacks_
void configure_boot_fout_()
void configure_boot_timer_()
void publish_state(const std::string &state)
ESPTime now()
Get the time in the currently defined timezone.
ESPTime utcnow()
Get the time without any time zone or DST corrections.
LazyCallbackManager< void()> time_sync_callback_
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
const LogString * message
@ TIMESTAMP_MODE_OVERWRITE
ESPHOME_LOG_TAG(TAG, "rx8111")
@ STATUS_SENSOR_BATTERY_LOW
@ STATUS_SENSOR_FIRST_MONITOR
PROGMEM_STRING_TABLE(TimerClockNames, "4096 Hz", "64 Hz", "1 Hz", "1/60 Hz")
constexpr uint8_t uint8_to_bcd(uint8_t value)
Encode a value from 0 to 99 as a two-digit packed BCD byte, e.g. 59 to 0x59.
void progmem_memcpy(void *dst, const void *src, size_t len)
uint8_t progmem_read_byte(const uint8_t *addr)
A more user-friendly version of struct tm from time.h.
uint8_t minute
minutes after the hour [0-59]
uint8_t second
seconds after the minute [0-60]
uint8_t hour
hours since midnight [0-23]
time_t timestamp
unix epoch time (seconds since UTC Midnight January 1, 1970)
bool is_valid(bool check_day_of_week=true, bool check_day_of_year=true) const
Check if this ESPTime is valid (year >= 2019 and the requested fields are in range).
static ESPTime from_epoch_utc(time_t epoch)
Convert an UTC epoch timestamp to a UTC time ESPTime instance.
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]