ESPHome 2026.8.0
Loading...
Searching...
No Matches
channel_colors.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace esphome::light {
6
14 static constexpr uint8_t NO_WHITE = 0xFF;
15
16 uint8_t r;
17 uint8_t g;
18 uint8_t b;
19 uint8_t w;
20
21 bool has_white() const { return this->w != NO_WHITE; }
22
23 uint8_t bytes_per_led() const { return this->has_white() ? 4 : 3; }
24
29 const char *to_string(char *buf) const {
30 buf[this->r] = 'R';
31 buf[this->g] = 'G';
32 buf[this->b] = 'B';
33 if (this->has_white()) {
34 buf[this->w] = 'W';
35 }
36 buf[this->bytes_per_led()] = '\0';
37 return buf;
38 }
39};
40
41} // namespace esphome::light
Which byte of an addressable LED's data carries each colour.
static constexpr uint8_t NO_WHITE
Value of w for a strip that only has red, green and blue channels.
const char * to_string(char *buf) const
Write the order back out as text, e.g.