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_LN882X
4
5#include <cstddef>
6#include <cstdint>
7
12
14
16 public:
19 LN882xSPILEDStripLightOutput(uint8_t pin, uint16_t num_leds, light::ChannelColors channel_colors, uint8_t prescaler,
20 uint8_t bit0_high_bits, uint8_t bit1_high_bits, uint16_t reset_bytes);
21
22 void setup() override;
23 void dump_config() override;
24 float get_setup_priority() const override;
25
26 light::LightTraits get_traits() override { return this->channel_colors_.traits(); }
27 int32_t size() const override { return this->num_leds_; }
28 void clear_effect_data() override {
29 if (this->effect_data_ != nullptr)
30 memset(this->effect_data_, 0, this->num_leds_);
31 }
32 void write_state(light::LightState *state) override;
33
35 void set_max_refresh_rate(uint32_t interval_us) { this->max_refresh_rate_ = interval_us; }
36
37 protected:
38 light::ESPColorView get_view_internal(int32_t index) const override {
39 return this->channel_colors_.view(this->color_data_, this->effect_data_, index, &this->correction_);
40 }
41
42 const size_t color_data_bytes_;
43 const size_t dma_data_bytes_;
44 uint8_t *color_data_{nullptr};
45 uint8_t *effect_data_{nullptr};
46 uint8_t *dma_data_{nullptr};
49
51 const uint16_t num_leds_;
52 const uint8_t pin_;
53 const uint8_t prescaler_;
54 const uint8_t bit0_high_bits_;
55 const uint8_t bit1_high_bits_;
56};
57
58} // namespace esphome::ln882x_spi_led_strip
59
60#endif // USE_LN882X
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
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:35
LN882xSPILEDStripLightOutput(uint8_t pin, uint16_t num_leds, light::ChannelColors channel_colors, uint8_t prescaler, uint8_t bit0_high_bits, uint8_t bit1_high_bits, uint16_t reset_bytes)
The SPI encoding comes from light.py: SPI clock APB0 / 2^prescaler, the number of high SPI bits for a...
Definition led_strip.cpp:89
light::ESPColorView get_view_internal(int32_t index) const override
Definition led_strip.h:38
void write_state(light::LightState *state) override
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()).
LightTraits traits() const
Colour modes of a strip with this channel order.