ESPHome  2024.3.1
tlc59208f_output.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/helpers.h"
7 
8 namespace esphome {
9 namespace tlc59208f {
10 
11 // 0*: Group dimming, 1: Group blinking
12 extern const uint8_t TLC59208F_MODE2_DMBLNK;
13 // 0*: Output change on Stop command, 1: Output change on ACK
14 extern const uint8_t TLC59208F_MODE2_OCH;
15 // 0*: WDT disabled, 1: WDT enabled
16 extern const uint8_t TLC59208F_MODE2_WDTEN;
17 // WDT timeouts
18 extern const uint8_t TLC59208F_MODE2_WDT_5MS;
19 extern const uint8_t TLC59208F_MODE2_WDT_15MS;
20 extern const uint8_t TLC59208F_MODE2_WDT_25MS;
21 extern const uint8_t TLC59208F_MODE2_WDT_35MS;
22 
23 class TLC59208FOutput;
24 
25 class TLC59208FChannel : public output::FloatOutput, public Parented<TLC59208FOutput> {
26  public:
27  void set_channel(uint8_t channel) { channel_ = channel; }
28 
29  protected:
30  friend class TLC59208FOutput;
31 
32  void write_state(float state) override;
33 
34  uint8_t channel_;
35 };
36 
38 class TLC59208FOutput : public Component, public i2c::I2CDevice {
39  public:
40  TLC59208FOutput(uint8_t mode = TLC59208F_MODE2_OCH) : mode_(mode) {}
41 
42  void register_channel(TLC59208FChannel *channel);
43 
44  void setup() override;
45  void dump_config() override;
46  float get_setup_priority() const override { return setup_priority::HARDWARE; }
47  void loop() override;
48 
49  protected:
51 
52  void set_channel_value_(uint8_t channel, uint8_t value) {
53  if (this->pwm_amounts_[channel] != value)
54  this->update_ = true;
55  this->pwm_amounts_[channel] = value;
56  }
57 
58  uint8_t mode_;
59 
60  uint8_t min_channel_{0xFF};
61  uint8_t max_channel_{0x00};
62  uint8_t pwm_amounts_[256] = {
63  0,
64  };
65  bool update_{true};
66 };
67 
68 } // namespace tlc59208f
69 } // namespace esphome
void setup()
void loop()
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
const uint8_t TLC59208F_MODE2_WDT_5MS
const uint8_t TLC59208F_MODE2_WDT_15MS
void write_state(float state) override
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:151
float get_setup_priority() const override
const uint8_t TLC59208F_MODE2_WDTEN
TLC59208F float output component.
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition: component.cpp:18
const uint8_t TLC59208F_MODE2_WDT_25MS
const uint8_t TLC59208F_MODE2_OCH
const uint8_t TLC59208F_MODE2_DMBLNK
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
const uint8_t TLC59208F_MODE2_WDT_35MS
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 set_channel_value_(uint8_t channel, uint8_t value)
bool state
Definition: fan.h:34
TLC59208FOutput(uint8_t mode=TLC59208F_MODE2_OCH)