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