ESPHome  2024.11.0
tlc5947.h
Go to the documentation of this file.
1 #pragma once
2 // TLC5947 24-Channel, 12-Bit PWM LED Driver
3 // https://www.ti.com/lit/ds/symlink/tlc5947.pdf
4 
5 #include <vector>
8 #include "esphome/core/hal.h"
9 
10 namespace esphome {
11 namespace tlc5947 {
12 
13 class TLC5947 : public Component {
14  public:
15  const uint8_t N_CHANNELS_PER_CHIP = 24;
16 
17  void set_data_pin(GPIOPin *data_pin) { data_pin_ = data_pin; }
18  void set_clock_pin(GPIOPin *clock_pin) { clock_pin_ = clock_pin; }
19  void set_lat_pin(GPIOPin *lat_pin) { lat_pin_ = lat_pin; }
20  void set_outenable_pin(GPIOPin *outenable_pin) { outenable_pin_ = outenable_pin; }
21  void set_num_chips(uint8_t num_chips) { num_chips_ = num_chips; }
22 
23  void setup() override;
24 
25  void dump_config() override;
26 
27  float get_setup_priority() const override { return setup_priority::HARDWARE; }
28 
30  void loop() override;
31 
32  void set_channel_value(uint16_t channel, uint16_t value);
33 
34  protected:
39  uint8_t num_chips_;
40 
41  std::vector<uint16_t> pwm_amounts_;
42  bool update_{true};
43 };
44 
45 } // namespace tlc5947
46 } // namespace esphome
std::vector< uint16_t > pwm_amounts_
Definition: tlc5947.h:41
void setup() override
Definition: tlc5947.cpp:9
void set_data_pin(GPIOPin *data_pin)
Definition: tlc5947.h:17
void set_outenable_pin(GPIOPin *outenable_pin)
Definition: tlc5947.h:20
void set_clock_pin(GPIOPin *clock_pin)
Definition: tlc5947.h:18
void set_num_chips(uint8_t num_chips)
Definition: tlc5947.h:21
const uint8_t N_CHANNELS_PER_CHIP
Definition: tlc5947.h:15
void set_channel_value(uint16_t channel, uint16_t value)
Definition: tlc5947.cpp:63
float get_setup_priority() const override
Definition: tlc5947.h:27
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition: component.cpp:18
void dump_config() override
Definition: tlc5947.cpp:25
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_lat_pin(GPIOPin *lat_pin)
Definition: tlc5947.h:19
void loop() override
Send new values if they were updated.
Definition: tlc5947.cpp:34
GPIOPin * outenable_pin_
Definition: tlc5947.h:38