ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::light::ChannelColors Struct Reference

Which byte of an addressable LED's data carries each colour. More...

#include <channel_colors.h>

Public Member Functions

constexpr ChannelColors ()
 
constexpr ChannelColors (uint8_t r_offset, uint8_t g_offset, uint8_t b_offset)
 
constexpr ChannelColors (uint8_t r_offset, uint8_t g_offset, uint8_t b_offset, uint8_t w_offset)
 
bool has_white () const
 
size_t bytes_per_led () const
 
Color get (const uint8_t *color_data, int32_t index) const ESPHOME_ALWAYS_INLINE
 
uint8_t get_channel (const uint8_t *color_data, int32_t index, uint8_t channel) const
 
void set (uint8_t *color_data, int32_t index, Color color) const
 
void set_channel (uint8_t *color_data, int32_t index, uint8_t channel, uint8_t value) const
 
const char * to_string (char *buf) const
 Write the order back out as text, e.g.
 
LightTraits traits () const
 Colour modes of a strip with this channel order.
 

Data Fields

union { 
 
   struct { 
 
      uint8_t   r 
 
      uint8_t   g 
 
      uint8_t   b 
 
      uint8_t   w 
 
   }  
 
   uint8_t   raw [4] 
 
};  
 

Static Public Attributes

static constexpr uint8_t NO_WHITE = 0xFF
 Value of w for an RGB LED strip that uses 3 bytes per led.
 
static constexpr uint8_t RESERVED_WHITE = 0xFE
 Value of w for an RGB LED strip that uses 4 bytes per led where the 4th byte is reserved.
 

Detailed Description

Which byte of an addressable LED's data carries each colour.

Built from a configuration string such as "GRB" or "WRGB": every field holds the position that colour occupies in the bytes the strip expects. w is NO_WHITE when the strip has no separate white channel.

Definition at line 18 of file channel_colors.h.

Constructor & Destructor Documentation

◆ ChannelColors() [1/3]

esphome::light::ChannelColors::ChannelColors ( )
inlineconstexpr

Definition at line 24 of file channel_colors.h.

◆ ChannelColors() [2/3]

esphome::light::ChannelColors::ChannelColors ( uint8_t r_offset,
uint8_t g_offset,
uint8_t b_offset )
inlineconstexpr

Definition at line 25 of file channel_colors.h.

◆ ChannelColors() [3/3]

esphome::light::ChannelColors::ChannelColors ( uint8_t r_offset,
uint8_t g_offset,
uint8_t b_offset,
uint8_t w_offset )
inlineconstexpr

Definition at line 27 of file channel_colors.h.

Member Function Documentation

◆ bytes_per_led()

size_t esphome::light::ChannelColors::bytes_per_led ( ) const
inline

Definition at line 42 of file channel_colors.h.

◆ get()

Color esphome::light::ChannelColors::get ( const uint8_t * color_data,
int32_t index ) const
inline

Definition at line 44 of file channel_colors.h.

◆ get_channel()

uint8_t esphome::light::ChannelColors::get_channel ( const uint8_t * color_data,
int32_t index,
uint8_t channel ) const
inline

Definition at line 51 of file channel_colors.h.

◆ has_white()

bool esphome::light::ChannelColors::has_white ( ) const
inline

Definition at line 40 of file channel_colors.h.

◆ set()

void esphome::light::ChannelColors::set ( uint8_t * color_data,
int32_t index,
Color color ) const
inline

Definition at line 56 of file channel_colors.h.

◆ set_channel()

void esphome::light::ChannelColors::set_channel ( uint8_t * color_data,
int32_t index,
uint8_t channel,
uint8_t value ) const
inline

Definition at line 70 of file channel_colors.h.

◆ to_string()

const char * esphome::light::ChannelColors::to_string ( char * buf) const
inline

Write the order back out as text, e.g.

"GRBW".

buf must have room for at least 5 characters. Returns buf so the result can be passed straight to a log call.

Definition at line 80 of file channel_colors.h.

◆ traits()

LightTraits esphome::light::ChannelColors::traits ( ) const
inline

Colour modes of a strip with this channel order.

Definition at line 93 of file channel_colors.h.

Field Documentation

◆ [union]

◆ b

uint8_t esphome::light::ChannelColors::b

Definition at line 34 of file channel_colors.h.

◆ g

uint8_t esphome::light::ChannelColors::g

Definition at line 33 of file channel_colors.h.

◆ NO_WHITE

uint8_t esphome::light::ChannelColors::NO_WHITE = 0xFF
staticconstexpr

Value of w for an RGB LED strip that uses 3 bytes per led.

Definition at line 20 of file channel_colors.h.

◆ r

uint8_t esphome::light::ChannelColors::r

Definition at line 32 of file channel_colors.h.

◆ raw

uint8_t esphome::light::ChannelColors::raw[4]

Definition at line 37 of file channel_colors.h.

◆ RESERVED_WHITE

uint8_t esphome::light::ChannelColors::RESERVED_WHITE = 0xFE
staticconstexpr

Value of w for an RGB LED strip that uses 4 bytes per led where the 4th byte is reserved.

Definition at line 22 of file channel_colors.h.

◆ w

uint8_t esphome::light::ChannelColors::w

Definition at line 35 of file channel_colors.h.


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