ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
led_strip.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_BK72XX
4
11
13
15 public:
16 void setup() override;
17 void write_state(light::LightState *state) override;
18 float get_setup_priority() const override;
19
20 int32_t size() const override { return this->num_leds_; }
22 auto traits = light::LightTraits();
23 if (this->channel_colors_.has_white()) {
24 traits.set_supported_color_modes({light::ColorMode::RGB_WHITE, light::ColorMode::WHITE});
25 } else {
26 traits.set_supported_color_modes({light::ColorMode::RGB});
27 }
28 return traits;
29 }
30
31 void set_pin(uint8_t pin) { this->pin_ = pin; }
32 void set_num_leds(uint16_t num_leds) { this->num_leds_ = num_leds; }
33 void set_channel_colors(light::ChannelColors channel_colors) { this->channel_colors_ = channel_colors; }
34
36 void set_max_refresh_rate(uint32_t interval_us) { this->max_refresh_rate_ = interval_us; }
37
38 void set_led_params(uint8_t bit0, uint8_t bit1, uint32_t spi_frequency);
39
40 void clear_effect_data() override {
41 for (int i = 0; i < this->size(); i++)
42 this->effect_data_[i] = 0;
43 }
44
45 void dump_config() override;
46
47 protected:
48 light::ESPColorView get_view_internal(int32_t index) const override;
49
50 size_t get_buffer_size_() const { return this->num_leds_ * this->channel_colors_.bytes_per_led(); }
51
52 uint8_t *buf_{nullptr};
53 uint8_t *effect_data_{nullptr};
54 uint8_t *dma_buf_{nullptr};
55
56 uint8_t pin_;
57 uint16_t num_leds_;
58
60 uint8_t bit0_{0xE0};
61 uint8_t bit1_{0xFC};
63
65 optional<uint32_t> max_refresh_rate_{};
66};
67
68} // namespace esphome::beken_spi_led_strip
69
70#endif // USE_BK72XX
void set_led_params(uint8_t bit0, uint8_t bit1, uint32_t spi_frequency)
light::ESPColorView get_view_internal(int32_t index) const override
void set_channel_colors(light::ChannelColors channel_colors)
Definition led_strip.h:33
void write_state(light::LightState *state) override
void set_max_refresh_rate(uint32_t interval_us)
Set a maximum refresh rate in µs as some lights do not like being updated too often.
Definition led_strip.h:36
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:93
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
bool state
Definition fan.h:2
@ RGB_WHITE
RGB color output and a separate white output.
@ RGB
RGB color output.
@ WHITE
White output only (use only if the light also has another color mode such as RGB).
static void uint32_t
Which byte of an addressable LED's data carries each colour.
static constexpr uint8_t NO_WHITE
Value of w for a strip that only has red, green and blue channels.