ESPHome 2026.6.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
10
12
21
23 public:
24 void setup() override;
25 void write_state(light::LightState *state) override;
26 float get_setup_priority() const override;
27
28 int32_t size() const override { return this->num_leds_; }
30 auto traits = light::LightTraits();
31 if (this->is_rgbw_ || this->is_wrgb_) {
32 traits.set_supported_color_modes({light::ColorMode::RGB_WHITE, light::ColorMode::WHITE});
33 } else {
34 traits.set_supported_color_modes({light::ColorMode::RGB});
35 }
36 return traits;
37 }
38
39 void set_pin(uint8_t pin) { this->pin_ = pin; }
40 void set_num_leds(uint16_t num_leds) { this->num_leds_ = num_leds; }
41 void set_is_rgbw(bool is_rgbw) { this->is_rgbw_ = is_rgbw; }
42 void set_is_wrgb(bool is_wrgb) { this->is_wrgb_ = is_wrgb; }
43
45 void set_max_refresh_rate(uint32_t interval_us) { this->max_refresh_rate_ = interval_us; }
46
47 void set_led_params(uint8_t bit0, uint8_t bit1, uint32_t spi_frequency);
48
49 void set_rgb_order(RGBOrder rgb_order) { this->rgb_order_ = rgb_order; }
50
51 void clear_effect_data() override {
52 for (int i = 0; i < this->size(); i++)
53 this->effect_data_[i] = 0;
54 }
55
56 void dump_config() override;
57
58 protected:
59 light::ESPColorView get_view_internal(int32_t index) const override;
60
61 size_t get_buffer_size_() const { return this->num_leds_ * (this->is_rgbw_ || this->is_wrgb_ ? 4 : 3); }
62
63 uint8_t *buf_{nullptr};
64 uint8_t *effect_data_{nullptr};
65 uint8_t *dma_buf_{nullptr};
66
67 uint8_t pin_;
68 uint16_t num_leds_;
71
73 uint8_t bit0_{0xE0};
74 uint8_t bit1_{0xFC};
76
78 optional<uint32_t> max_refresh_rate_{};
79};
80
81} // namespace esphome::beken_spi_led_strip
82
83#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 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:45
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