26 virtual uint8_t
get_channel(int32_t index, uint8_t channel)
const = 0;
30 virtual void set(int32_t index,
Color color) = 0;
33 virtual void set_channel_raw(int32_t index, uint8_t channel, uint8_t raw_value) = 0;
36#if defined(USE_LIGHT_PARTITION) && defined(USE_LIGHT_POWER_ESTIMATION)
47 Color get(int32_t index)
const override {
return {}; }
49 uint8_t
get_channel(int32_t index, uint8_t channel)
const override {
return 0; }
50 uint8_t
get_channel_raw(int32_t index, uint8_t channel)
const override {
return 0; }
53 void set(int32_t index,
Color color)
override {}
56 void set_channel_raw(int32_t index, uint8_t channel, uint8_t raw_value)
override {}
76 void set_channel_raw(int32_t index, uint8_t channel, uint8_t raw_value)
override {
85 const size_t total_bytes = color_bytes + num_leds + extra_bytes;
86 uint8_t *buf = allocator.
allocate(total_bytes);
89 memset(buf, 0, total_bytes);
118 void set_channel(int32_t index, uint8_t channel, uint8_t raw_value)
override {
139 uint8_t
get_channel(int32_t index, uint8_t channel)
const override {
148#if defined(USE_LIGHT_PARTITION) && defined(USE_LIGHT_POWER_ESTIMATION)
176 void set_rgb(uint8_t red, uint8_t green, uint8_t blue) {
184 void set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { this->
set(
Color(red, green, blue, white)); }
186 ESPDEPRECATED(
"Use set_hsv(hsv_color) instead. Removed in 2027.5.0.",
"2026.11.0")
258#if defined(USE_LIGHT_PARTITION) && defined(USE_LIGHT_POWER_ESTIMATION)
An STL allocator that uses SPI or internal RAM.
Base class for color accessors backed by a buffer whose layout is described by ChannelColors.
uint8_t get_effect_data(int32_t index) const override
void set_raw(int32_t index, Color raw_color) override
void clear_effect_data(size_t num_leds)
Zero the effect data of the first num_leds LEDs; does nothing before the effect data is allocated.
void set_channel_raw(int32_t index, uint8_t channel, uint8_t raw_value) override
Color get_raw(int32_t index) const override
ChannelColors channel_colors
uint8_t get_channel_raw(int32_t index, uint8_t channel) const override
void set_effect_data(int32_t index, uint8_t value) override
BufferColorAccessor()=default
bool allocate(RAMAllocator< uint8_t > &allocator, size_t num_leds, size_t extra_bytes=0)
Allocate the color and effect data for num_leds LEDs as one zeroed block, followed by extra_bytes mor...
BufferColorAccessor(uint8_t *color_data, uint8_t *effect_data, ChannelColors channel_colors)
Color accessor backed by a buffer whose contents have color correction applied.
void set_channel(int32_t index, uint8_t channel, uint8_t value) override
Color get(int32_t index) const override
const ESPColorCorrection * get_color_correction_internal(int32_t index) const override
const ESPColorCorrection * color_correction
uint8_t get_channel(int32_t index, uint8_t channel) const override
void set(int32_t index, Color color) override
CorrectedBufferColorAccessor()=default
CorrectedBufferColorAccessor(uint8_t *color_data, uint8_t *effect_data, ChannelColors channel_colors, const ESPColorCorrection *color_correction)
Abstract interface for accessing color and effect data for an addressable light by index.
virtual Color get_raw(int32_t index) const =0
virtual void set_raw(int32_t index, Color raw_color)=0
virtual uint8_t get_effect_data(int32_t index) const =0
virtual uint8_t get_channel_raw(int32_t index, uint8_t channel) const =0
virtual void set(int32_t index, Color color)=0
virtual const ESPColorCorrection * get_color_correction_internal(int32_t index) const
virtual void set_channel(int32_t index, uint8_t channel, uint8_t value)=0
virtual void set_effect_data(int32_t index, uint8_t value)=0
virtual uint8_t get_channel(int32_t index, uint8_t channel) const =0
virtual Color get(int32_t index) const =0
virtual void set_channel_raw(int32_t index, uint8_t channel, uint8_t raw_value)=0
uint8_t color_correct_channel(uint8_t channel, uint8_t value) const ESPHOME_ALWAYS_INLINE
uint8_t color_uncorrect_blue(uint8_t raw_blue) const ESPHOME_ALWAYS_INLINE
Color color_correct(Color color) const ESPHOME_ALWAYS_INLINE
uint8_t color_uncorrect_white(uint8_t raw_white) const ESPHOME_ALWAYS_INLINE
uint8_t color_uncorrect_channel(uint8_t channel, uint8_t raw_value) const
uint8_t color_uncorrect_red(uint8_t raw_red) const ESPHOME_ALWAYS_INLINE
uint8_t color_uncorrect_green(uint8_t raw_green) const ESPHOME_ALWAYS_INLINE
Abstract interface that supports setting colors and effect data.
void set_red(uint8_t red) ESPHOME_ALWAYS_INLINE
virtual void set_channel(uint8_t channel, uint8_t value)=0
void set_hsv(ESPHSVColor hsv_color)
void set_rgb(uint8_t red, uint8_t green, uint8_t blue)
void set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white)
virtual void darken(uint8_t delta)=0
virtual void lighten(uint8_t delta)=0
virtual void fade_to_white(uint8_t amnt)=0
virtual void set(Color color)=0
void set_green(uint8_t green) ESPHOME_ALWAYS_INLINE
void set_blue(uint8_t blue) ESPHOME_ALWAYS_INLINE
virtual void set_effect_data(uint8_t value)=0
ESPDEPRECATED("Use set_hsv(hsv_color) instead. Removed in 2027.5.0.", "2026.11.0") void set(ESPHSVColor hsv_color)
void set_white(uint8_t white) ESPHOME_ALWAYS_INLINE
virtual void fade_to_black(uint8_t amnt)=0
Gets or sets the color or effect data at a specific index within an color accessor.
void set_effect_data(uint8_t value) override
uint8_t get_effect_data() const
void set_channel(uint8_t channel, uint8_t value) override
uint8_t get_channel(uint8_t channel) const
uint8_t get_red() const ESPHOME_ALWAYS_INLINE
void set_red_raw(uint8_t raw_red) ESPHOME_ALWAYS_INLINE
uint8_t get_blue() const ESPHOME_ALWAYS_INLINE
void fade_to_black(uint8_t amnt) override
ESPColorAccessor *const accessor_
void fade_to_white(uint8_t amnt) override
const ESPColorCorrection * get_color_correction_internal() const
void darken(uint8_t delta) override
uint8_t get_blue_raw() const ESPHOME_ALWAYS_INLINE
void set_white_raw(uint8_t raw_white) ESPHOME_ALWAYS_INLINE
void set_channel_raw(uint8_t channel, uint8_t raw_value)
uint8_t get_white() const ESPHOME_ALWAYS_INLINE
ESPColorView(ESPColorAccessor *accessor, int32_t index)
void set(Color color) override
ESPColorView & operator=(ESPHSVColor hsv_color)
uint8_t get_white_raw() const ESPHOME_ALWAYS_INLINE
void set_blue_raw(uint8_t raw_blue) ESPHOME_ALWAYS_INLINE
uint8_t get_red_raw() const ESPHOME_ALWAYS_INLINE
ESPColorView & operator=(const ESPColorView &other)
uint8_t get_green() const ESPHOME_ALWAYS_INLINE
uint8_t get_channel_raw(uint8_t channel) const
ESPColorView(const ESPColorView &)=default
uint8_t get_green_raw() const ESPHOME_ALWAYS_INLINE
void lighten(uint8_t delta) override
ESPColorView & operator=(Color color)
void set_raw(Color raw_color)
void set_green_raw(uint8_t raw_green) ESPHOME_ALWAYS_INLINE
Color accessor that is completely at peace with the void of nothingness.
void set_raw(int32_t index, Color raw_color) override
Color get_raw(int32_t index) const override
uint8_t get_channel_raw(int32_t index, uint8_t channel) const override
uint8_t get_channel(int32_t index, uint8_t channel) const override
void set_channel(int32_t index, uint8_t channel, uint8_t value) override
Color get(int32_t index) const override
void set(int32_t index, Color color) override
uint8_t get_effect_data(int32_t index) const override
static NullColorAccessor instance
Singleton instance of this accessor.
void set_channel_raw(int32_t index, uint8_t channel, uint8_t raw_value) override
void set_effect_data(int32_t index, uint8_t value) override
Color accessor backed by a buffer whose contents have no color correction applied.
Color get(int32_t index) const override
void set_channel(int32_t index, uint8_t channel, uint8_t raw_value) override
RawBufferColorAccessor(uint8_t *color_data, uint8_t *effect_data, ChannelColors channel_colors)
void set(int32_t index, Color color) override
uint8_t get_channel(int32_t index, uint8_t channel) const override
RawBufferColorAccessor()=default
Which byte of an addressable LED's data carries each colour.
void set_channel(uint8_t *color_data, int32_t index, uint8_t channel, uint8_t value) const
size_t bytes_per_led() const
Color get(const uint8_t *color_data, int32_t index) const ESPHOME_ALWAYS_INLINE
void set(uint8_t *color_data, int32_t index, Color color) const
uint8_t get_channel(const uint8_t *color_data, int32_t index, uint8_t channel) const