ESPHome 2026.2.4
Loading...
Searching...
No Matches
pcf8563.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace pcf8563 {
9
11 public:
12 void setup() override;
13 void update() override;
14 void dump_config() override;
15 void read_time();
16 void write_time();
17
18 protected:
19 bool read_rtc_();
20 bool write_rtc_();
21 union PCF8563Reg {
22 struct {
23 // Control_1 register
24 bool : 3;
26 bool : 1;
27 bool stop : 1;
28 bool : 1;
29 bool ext_test : 1;
30
31 // Control_2 register
32 bool time_int : 1;
33 bool alarm_int : 1;
34 bool timer_flag : 1;
35 bool alarm_flag : 1;
37 bool : 3;
38
39 // Seconds register
40 uint8_t second : 4;
41 uint8_t second_10 : 3;
42 bool clock_int : 1;
43
44 // Minutes register
45 uint8_t minute : 4;
46 uint8_t minute_10 : 3;
47 uint8_t : 1;
48
49 // Hours register
50 uint8_t hour : 4;
51 uint8_t hour_10 : 2;
52 uint8_t : 2;
53
54 // Days register
55 uint8_t day : 4;
56 uint8_t day_10 : 2;
57 uint8_t : 2;
58
59 // Weekdays register
60 uint8_t weekday : 3;
61 uint8_t unused_3 : 5;
62
63 // Months register
64 uint8_t month : 4;
65 uint8_t month_10 : 1;
66 uint8_t : 2;
67 uint8_t century : 1;
68
69 // Years register
70 uint8_t year : 4;
71 uint8_t year_10 : 4;
72
73 // Minute Alarm register
74 uint8_t minute_alarm : 4;
75 uint8_t minute_alarm_10 : 3;
77
78 // Hour Alarm register
79 uint8_t hour_alarm : 4;
80 uint8_t hour_alarm_10 : 2;
81 uint8_t : 1;
83
84 // Day Alarm register
85 uint8_t day_alarm : 4;
86 uint8_t day_alarm_10 : 2;
87 uint8_t : 1;
89
90 // Weekday Alarm register
91 uint8_t weekday_alarm : 3;
92 uint8_t : 4;
94
95 // CLKout control register
96 uint8_t frequency_output : 2;
97 uint8_t : 5;
98 uint8_t clkout_enabled : 1;
99
100 // Timer control register
102 uint8_t : 5;
103 uint8_t timer_enabled : 1;
104
105 // Timer register
106 uint8_t countdown_period : 8;
107
109 mutable uint8_t raw[sizeof(reg)];
111};
112
113template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<PCF8563Component> {
114 public:
115 void play(const Ts &...x) override { this->parent_->write_time(); }
116};
117
118template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<PCF8563Component> {
119 public:
120 void play(const Ts &...x) override { this->parent_->read_time(); }
121};
122} // namespace pcf8563
123} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:1471
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
union esphome::pcf8563::PCF8563Component::PCF8563Reg pcf8563_
void play(const Ts &...x) override
Definition pcf8563.h:120
void play(const Ts &...x) override
Definition pcf8563.h:115
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5
struct esphome::pcf8563::PCF8563Component::PCF8563Reg::@146 reg