ESPHome 2025.5.0
Loading...
Searching...
No Matches
ds1307.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace 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)];
58};
59
60template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<DS1307Component> {
61 public:
62 void play(Ts... x) override { this->parent_->write_time(); }
63};
64
65template<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
Helper class to easily give an object a parent of type T.
Definition helpers.h:538
float get_setup_priority() const override
Definition ds1307.cpp:30
union esphome::ds1307::DS1307Component::DS1307Reg ds1307_
void play(Ts... x) override
Definition ds1307.h:67
void play(Ts... x) override
Definition ds1307.h:62
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
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::ds1307::DS1307Component::DS1307Reg::@75 reg