ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
pcf85063.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::pcf85063 {
8
11inline uint8_t decode_hour(uint8_t units, uint8_t tens, bool twelve_hour) {
12 if (!twelve_hour)
13 return units + 10u * tens;
14 const uint8_t hour = units + 10u * (tens & 0x01);
15 if (hour == 0 || hour > 12)
16 return UINT8_MAX;
17 return hour % 12 + ((tens & 0x02) ? 12 : 0);
18}
19
21 public:
22 void setup() override;
23 void update() override;
24 void dump_config() override;
25 void read_time();
26 void write_time();
27
28 protected:
29 bool read_rtc_();
30 bool write_rtc_();
32 struct {
33 // Control_1 register
34 bool cap_12pf : 1;
35 bool am_pm : 1;
37 bool : 1;
38 bool soft_reset : 1;
39 bool stop : 1;
40 bool : 1;
41 bool ext_test : 1;
42
43 // Control_2 register
44 uint8_t clkout_control : 3;
45 bool timer_flag : 1;
47 bool minute_int : 1;
48 bool alarm_flag : 1;
49 bool alarm_int : 1;
50
51 // Offset register
52 uint8_t offset : 7;
53 bool coarse_mode : 1;
54
55 // nvRAM register
56 uint8_t nvram : 8;
57
58 // Seconds register
59 uint8_t second : 4;
60 uint8_t second_10 : 3;
61 bool osc_stop : 1;
62
63 // Minutes register
64 uint8_t minute : 4;
65 uint8_t minute_10 : 3;
66 uint8_t : 1;
67
68 // Hours register
69 uint8_t hour : 4;
70 uint8_t hour_10 : 2;
71 uint8_t : 2;
72
73 // Days register
74 uint8_t day : 4;
75 uint8_t day_10 : 2;
76 uint8_t : 2;
77
78 // Weekdays register
79 uint8_t weekday : 3;
80 uint8_t unused_3 : 5;
81
82 // Months register
83 uint8_t month : 4;
84 uint8_t month_10 : 1;
85 uint8_t : 3;
86
87 // Years register
88 uint8_t year : 4;
89 uint8_t year_10 : 4;
90 } reg;
91 mutable uint8_t raw[sizeof(reg)];
93};
94
95} // namespace esphome::pcf85063
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
union esphome::pcf85063::PCF85063Component::PCF85063Reg pcf85063_
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
uint8_t hour
uint8_t decode_hour(uint8_t units, uint8_t tens, bool twelve_hour)
Hour 0-23 from the hours register digits.
Definition pcf85063.h:11
struct esphome::pcf85063::PCF85063Component::PCF85063Reg::@157 reg