ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
esphome::light::BufferColorAccessor Class Reference

Base class for color accessors backed by a buffer whose layout is described by ChannelColors. More...

#include <esp_color_view.h>

Inheritance diagram for esphome::light::BufferColorAccessor:
esphome::light::ESPColorAccessor esphome::light::CorrectedBufferColorAccessor esphome::light::RawBufferColorAccessor

Public Member Functions

 BufferColorAccessor ()=default
 
 BufferColorAccessor (uint8_t *color_data, uint8_t *effect_data, ChannelColors channel_colors)
 
Color get_raw (int32_t index) const override
 
uint8_t get_channel_raw (int32_t index, uint8_t channel) const override
 
uint8_t get_effect_data (int32_t index) const override
 
void set_raw (int32_t index, Color raw_color) override
 
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
 
bool has_white_internal (int32_t index) const override
 
bool allocate (RAMAllocator< uint8_t > &allocator, size_t num_leds, size_t extra_bytes=0)
 Allocate a zeroed block of buffer_bytes() plus extra_bytes for the caller, which start at effect_data + num_leds, and pass it to set_buffer().
 
uint8_t * set_buffer (uint8_t *buffer, size_t num_leds)
 Use buffer for the color data of num_leds LEDs followed by their effect data, buffer_bytes() in all.
 
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.
 
- Public Member Functions inherited from esphome::light::ESPColorAccessor
virtual Color get (int32_t index) const =0
 
virtual uint8_t get_channel (int32_t index, uint8_t channel) const =0
 
virtual void set (int32_t index, Color color)=0
 
virtual void set_channel (int32_t index, uint8_t channel, uint8_t value)=0
 
virtual const ESPColorCorrection * get_color_correction_internal (int32_t index) const
 

Static Public Member Functions

static constexpr size_t buffer_bytes (size_t num_leds, uint8_t bytes_per_led)
 The color data of num_leds LEDs followed by one effect byte per LED.
 

Data Fields

uint8_t * color_data {nullptr}
 
uint8_t * effect_data {nullptr}
 
ChannelColors channel_colors {}
 

Detailed Description

Base class for color accessors backed by a buffer whose layout is described by ChannelColors.

Definition at line 65 of file esp_color_view.h.

Constructor & Destructor Documentation

◆ BufferColorAccessor() [1/2]

esphome::light::BufferColorAccessor::BufferColorAccessor ( )
default

◆ BufferColorAccessor() [2/2]

esphome::light::BufferColorAccessor::BufferColorAccessor ( uint8_t * color_data,
uint8_t * effect_data,
ChannelColors channel_colors )
inline

Definition at line 68 of file esp_color_view.h.

Member Function Documentation

◆ allocate()

bool esphome::light::BufferColorAccessor::allocate ( RAMAllocator< uint8_t > & allocator,
size_t num_leds,
size_t extra_bytes = 0 )
inline

Allocate a zeroed block of buffer_bytes() plus extra_bytes for the caller, which start at effect_data + num_leds, and pass it to set_buffer().

Returns false if it failed.

Definition at line 91 of file esp_color_view.h.

◆ buffer_bytes()

static constexpr size_t esphome::light::BufferColorAccessor::buffer_bytes ( size_t num_leds,
uint8_t bytes_per_led )
inlinestaticconstexpr

The color data of num_leds LEDs followed by one effect byte per LED.

Definition at line 102 of file esp_color_view.h.

◆ clear_effect_data()

void esphome::light::BufferColorAccessor::clear_effect_data ( size_t num_leds)
inline

Zero the effect data of the first num_leds LEDs; does nothing before the effect data is allocated.

Definition at line 115 of file esp_color_view.h.

◆ get_channel_raw()

uint8_t esphome::light::BufferColorAccessor::get_channel_raw ( int32_t index,
uint8_t channel ) const
inlineoverridevirtual

Implements esphome::light::ESPColorAccessor.

Definition at line 72 of file esp_color_view.h.

◆ get_effect_data()

uint8_t esphome::light::BufferColorAccessor::get_effect_data ( int32_t index) const
inlineoverridevirtual

Implements esphome::light::ESPColorAccessor.

Definition at line 75 of file esp_color_view.h.

◆ get_raw()

Color esphome::light::BufferColorAccessor::get_raw ( int32_t index) const
inlineoverridevirtual

Implements esphome::light::ESPColorAccessor.

Definition at line 71 of file esp_color_view.h.

◆ has_white_internal()

bool esphome::light::BufferColorAccessor::has_white_internal ( int32_t index) const
inlineoverridevirtual

Reimplemented from esphome::light::ESPColorAccessor.

Definition at line 86 of file esp_color_view.h.

◆ set_buffer()

uint8_t * esphome::light::BufferColorAccessor::set_buffer ( uint8_t * buffer,
size_t num_leds )
inline

Use buffer for the color data of num_leds LEDs followed by their effect data, buffer_bytes() in all.

Returns the first byte after the effect data.

Definition at line 108 of file esp_color_view.h.

◆ set_channel_raw()

void esphome::light::BufferColorAccessor::set_channel_raw ( int32_t index,
uint8_t channel,
uint8_t raw_value )
inlineoverridevirtual

Implements esphome::light::ESPColorAccessor.

Definition at line 80 of file esp_color_view.h.

◆ set_effect_data()

void esphome::light::BufferColorAccessor::set_effect_data ( int32_t index,
uint8_t value )
inlineoverridevirtual

Implements esphome::light::ESPColorAccessor.

Definition at line 83 of file esp_color_view.h.

◆ set_raw()

void esphome::light::BufferColorAccessor::set_raw ( int32_t index,
Color raw_color )
inlineoverridevirtual

Implements esphome::light::ESPColorAccessor.

Definition at line 77 of file esp_color_view.h.

Field Documentation

◆ channel_colors

ChannelColors esphome::light::BufferColorAccessor::channel_colors {}

Definition at line 123 of file esp_color_view.h.

◆ color_data

uint8_t* esphome::light::BufferColorAccessor::color_data {nullptr}

Definition at line 121 of file esp_color_view.h.

◆ effect_data

uint8_t* esphome::light::BufferColorAccessor::effect_data {nullptr}

Definition at line 122 of file esp_color_view.h.


The documentation for this class was generated from the following file: