ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
cw2017.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::cw2017 {
8
9static constexpr uint8_t PROFILE_SIZE = 80;
10
11class CW2017 : public PollingComponent, public i2c::I2CDevice {
12 public:
13 explicit CW2017(const uint8_t *profile) : profile_(profile) {}
14
17
18 void setup() override;
19 void update() override;
20 void dump_config() override;
21
22 protected:
23 void init_();
24 void init_failed_(const LogString *reason);
25 bool read_profile_matches_(bool &matches);
26 bool upload_profile_();
27 void restart_();
28 void restart_step_(uint8_t step);
29 void wait_ready_(uint8_t attempt);
30
31 const uint8_t *profile_;
34 bool ready_{false};
35 bool restart_pending_{false};
36 uint8_t init_attempts_{0};
37};
38
39} // namespace esphome::cw2017
This class simplifies creating components that periodically check a state.
Definition component.h:519
void init_failed_(const LogString *reason)
Definition cw2017.cpp:69
sensor::Sensor * battery_level_sensor_
Definition cw2017.h:32
void restart_step_(uint8_t step)
Definition cw2017.cpp:132
void set_battery_level_sensor(sensor::Sensor *sensor)
Definition cw2017.h:15
void set_battery_voltage_sensor(sensor::Sensor *sensor)
Definition cw2017.h:16
sensor::Sensor * battery_voltage_sensor_
Definition cw2017.h:33
const uint8_t * profile_
Definition cw2017.h:31
void wait_ready_(uint8_t attempt)
Definition cw2017.cpp:145
void update() override
Definition cw2017.cpp:162
CW2017(const uint8_t *profile)
Definition cw2017.h:13
void setup() override
Definition cw2017.cpp:66
void dump_config() override
Definition cw2017.cpp:188
bool read_profile_matches_(bool &matches)
Definition cw2017.cpp:49
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
Base-class for all sensors.
Definition sensor.h:47