ESPHome 2026.3.0-dev
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 void read_time();
16 void write_time();
17
18 protected:
19 bool read_rtc_();
20 bool write_rtc_();
21 union DS1307Reg {
22 struct {
23 uint8_t second : 4;
24 uint8_t second_10 : 3;
25 bool ch : 1;
26
27 uint8_t minute : 4;
28 uint8_t minute_10 : 3;
29 uint8_t unused_1 : 1;
30
31 uint8_t hour : 4;
32 uint8_t hour_10 : 2;
33 uint8_t unused_2 : 2;
34
35 uint8_t weekday : 3;
36 uint8_t unused_3 : 5;
37
38 uint8_t day : 4;
39 uint8_t day_10 : 2;
40 uint8_t unused_4 : 2;
41
42 uint8_t month : 4;
43 uint8_t month_10 : 1;
44 uint8_t unused_5 : 3;
45
46 uint8_t year : 4;
47 uint8_t year_10 : 4;
48
49 uint8_t rs : 2;
50 uint8_t unused_6 : 2;
51 bool sqwe : 1;
52 uint8_t unused_7 : 2;
53 bool out : 1;
54 } reg;
55 mutable uint8_t raw[sizeof(reg)];
57};
58
59template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<DS1307Component> {
60 public:
61 void play(const Ts &...x) override { this->parent_->write_time(); }
62};
63
64template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<DS1307Component> {
65 public:
66 void play(const Ts &...x) override { this->parent_->read_time(); }
67};
68} // namespace ds1307
69} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:1618
union esphome::ds1307::DS1307Component::DS1307Reg ds1307_
void play(const Ts &...x) override
Definition ds1307.h:66
void play(const Ts &...x) override
Definition ds1307.h:61
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
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::@76 reg