ESPHome 2026.11.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_; }
21 light::LightTraits get_traits() override { return this->channel_colors_.traits(); }
22
23 void set_pin(uint8_t pin) { this->pin_ = pin; }
24 void set_num_leds(uint16_t num_leds) { this->num_leds_ = num_leds; }
25 void set_channel_colors(light::ChannelColors channel_colors) { this->channel_colors_ = channel_colors; }
26
28 void set_max_refresh_rate(uint32_t interval_us) { this->max_refresh_rate_ = interval_us; }
29
30 void set_led_params(uint8_t bit0, uint8_t bit1, uint32_t spi_frequency);
31
32 void clear_effect_data() override {
33 if (this->effect_data_ != nullptr)
34 memset(this->effect_data_, 0, this->num_leds_);
35 }
36
37 void dump_config() override;
38
39 protected:
40 light::ESPColorView get_view_internal(int32_t index) const override {
41 return this->channel_colors_.view(this->buf_, this->effect_data_, index, &this->correction_);
42 }
43
44 size_t get_buffer_size_() const { return this->num_leds_ * this->channel_colors_.bytes_per_led(); }
45
46 uint8_t *buf_{nullptr};
47 uint8_t *effect_data_{nullptr};
48 uint8_t *dma_buf_{nullptr};
49
50 uint8_t pin_;
51 uint16_t num_leds_;
52
54 uint8_t bit0_{0xE0};
55 uint8_t bit1_{0xFC};
57
60};
61
62} // namespace esphome::beken_spi_led_strip
63
64#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
Definition led_strip.h:40
void set_channel_colors(light::ChannelColors channel_colors)
Definition led_strip.h:25
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:28
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:68
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
bool state
Definition fan.h:2
static void uint32_t
Which byte of an addressable LED's data carries each colour.
ESPColorView view(uint8_t *buf, uint8_t *effect_data, int32_t index, const ESPColorCorrection *correction) const
View of LED index in buf; a scratch pixel while buf or effect_data is unallocated (failed setup()).
static constexpr uint8_t NO_WHITE
Value of w for a strip that only has red, green and blue channels.
LightTraits traits() const
Colour modes of a strip with this channel order.