ESPHome  2024.10.2
pcf85063.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace pcf85063 {
9 
11  public:
12  void setup() override;
13  void update() override;
14  void dump_config() override;
15  float get_setup_priority() const override;
16  void read_time();
17  void write_time();
18 
19  protected:
20  bool read_rtc_();
21  bool write_rtc_();
22  union PCF85063Reg {
23  struct {
24  // Control_1 register
25  bool cap_12pf : 1;
26  bool am_pm : 1;
28  bool : 1;
29  bool soft_reset : 1;
30  bool stop : 1;
31  bool : 1;
32  bool ext_test : 1;
33 
34  // Control_2 register
35  uint8_t clkout_control : 3;
36  bool timer_flag : 1;
37  bool halfminute_int : 1;
38  bool minute_int : 1;
39  bool alarm_flag : 1;
40  bool alarm_int : 1;
41 
42  // Offset register
43  uint8_t offset : 7;
44  bool coarse_mode : 1;
45 
46  // nvRAM register
47  uint8_t nvram : 8;
48 
49  // Seconds register
50  uint8_t second : 4;
51  uint8_t second_10 : 3;
52  bool osc_stop : 1;
53 
54  // Minutes register
55  uint8_t minute : 4;
56  uint8_t minute_10 : 3;
57  uint8_t : 1;
58 
59  // Hours register
60  uint8_t hour : 4;
61  uint8_t hour_10 : 2;
62  uint8_t : 2;
63 
64  // Days register
65  uint8_t day : 4;
66  uint8_t day_10 : 2;
67  uint8_t : 2;
68 
69  // Weekdays register
70  uint8_t weekday : 3;
71  uint8_t unused_3 : 5;
72 
73  // Months register
74  uint8_t month : 4;
75  uint8_t month_10 : 1;
76  uint8_t : 3;
77 
78  // Years register
79  uint8_t year : 4;
80  uint8_t year_10 : 4;
81  } reg;
82  mutable uint8_t raw[sizeof(reg)];
83  } pcf85063_;
84 };
85 
86 template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<PCF85063Component> {
87  public:
88  void play(Ts... x) override { this->parent_->write_time(); }
89 };
90 
91 template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<PCF85063Component> {
92  public:
93  void play(Ts... x) override { this->parent_->read_time(); }
94 };
95 } // namespace pcf85063
96 } // namespace esphome
void play(Ts... x) override
Definition: pcf85063.h:93
The RealTimeClock class exposes common timekeeping functions via the device&#39;s local real-time clock...
uint16_t x
Definition: tt21100.cpp:17
void play(Ts... x) override
Definition: pcf85063.h:88
float get_setup_priority() const override
Definition: pcf85063.cpp:30
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
struct esphome::pcf85063::PCF85063Component::PCF85063Reg::@126 reg
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
Helper class to easily give an object a parent of type T.
Definition: helpers.h:521
union esphome::pcf85063::PCF85063Component::PCF85063Reg pcf85063_