ESPHome  2024.4.0
ds1307.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace ds1307 {
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 DS1307Reg {
23  struct {
24  uint8_t second : 4;
25  uint8_t second_10 : 3;
26  bool ch : 1;
27 
28  uint8_t minute : 4;
29  uint8_t minute_10 : 3;
30  uint8_t unused_1 : 1;
31 
32  uint8_t hour : 4;
33  uint8_t hour_10 : 2;
34  uint8_t unused_2 : 2;
35 
36  uint8_t weekday : 3;
37  uint8_t unused_3 : 5;
38 
39  uint8_t day : 4;
40  uint8_t day_10 : 2;
41  uint8_t unused_4 : 2;
42 
43  uint8_t month : 4;
44  uint8_t month_10 : 1;
45  uint8_t unused_5 : 3;
46 
47  uint8_t year : 4;
48  uint8_t year_10 : 4;
49 
50  uint8_t rs : 2;
51  uint8_t unused_6 : 2;
52  bool sqwe : 1;
53  uint8_t unused_7 : 2;
54  bool out : 1;
55  } reg;
56  mutable uint8_t raw[sizeof(reg)];
57  } ds1307_;
58 };
59 
60 template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<DS1307Component> {
61  public:
62  void play(Ts... x) override { this->parent_->write_time(); }
63 };
64 
65 template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<DS1307Component> {
66  public:
67  void play(Ts... x) override { this->parent_->read_time(); }
68 };
69 } // namespace ds1307
70 } // namespace esphome
The RealTimeClock class exposes common timekeeping functions via the device&#39;s local real-time clock...
uint16_t x
Definition: tt21100.cpp:17
void dump_config() override
Definition: ds1307.cpp:21
union esphome::ds1307::DS1307Component::DS1307Reg ds1307_
float get_setup_priority() const override
Definition: ds1307.cpp:30
struct esphome::ds1307::DS1307Component::DS1307Reg::@74 reg
void play(Ts... x) override
Definition: ds1307.h:67
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
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:515
void play(Ts... x) override
Definition: ds1307.h:62