ESPHome
2024.12.2
|
This class represents the color state for a light object. More...
#include <light_color_values.h>
Public Member Functions | |
LightColorValues () | |
Construct the LightColorValues with all attributes enabled, but state set to off. More... | |
LightColorValues (ColorMode color_mode, float state, float brightness, float color_brightness, float red, float green, float blue, float white, float color_temperature, float cold_white, float warm_white) | |
void | normalize_color () |
Normalize the color (RGB/W) component. More... | |
void | as_binary (bool *binary) const |
Convert these light color values to a binary representation and write them to binary. More... | |
void | as_brightness (float *brightness, float gamma=0) const |
Convert these light color values to a brightness-only representation and write them to brightness. More... | |
void | as_rgb (float *red, float *green, float *blue, float gamma=0, bool color_interlock=false) const |
Convert these light color values to an RGB representation and write them to red, green, blue. More... | |
void | as_rgbw (float *red, float *green, float *blue, float *white, float gamma=0, bool color_interlock=false) const |
Convert these light color values to an RGBW representation and write them to red, green, blue, white. More... | |
void | as_rgbww (float *red, float *green, float *blue, float *cold_white, float *warm_white, float gamma=0, bool constant_brightness=false) const |
Convert these light color values to an RGBWW representation with the given parameters. More... | |
void | as_rgbct (float color_temperature_cw, float color_temperature_ww, float *red, float *green, float *blue, float *color_temperature, float *white_brightness, float gamma=0) const |
Convert these light color values to an RGB+CT+BR representation with the given parameters. More... | |
void | as_cwww (float *cold_white, float *warm_white, float gamma=0, bool constant_brightness=false) const |
Convert these light color values to an CWWW representation with the given parameters. More... | |
void | as_ct (float color_temperature_cw, float color_temperature_ww, float *color_temperature, float *white_brightness, float gamma=0) const |
Convert these light color values to a CT+BR representation with the given parameters. More... | |
bool | operator== (const LightColorValues &rhs) const |
Compare this LightColorValues to rhs, return true if and only if all attributes match. More... | |
bool | operator!= (const LightColorValues &rhs) const |
ColorMode | get_color_mode () const |
Get the color mode of these light color values. More... | |
void | set_color_mode (ColorMode color_mode) |
Set the color mode of these light color values. More... | |
float | get_state () const |
Get the state of these light color values. In range from 0.0 (off) to 1.0 (on) More... | |
bool | is_on () const |
Get the binary true/false state of these light color values. More... | |
void | set_state (float state) |
Set the state of these light color values. In range from 0.0 (off) to 1.0 (on) More... | |
void | set_state (bool state) |
Set the state of these light color values as a binary true/false. More... | |
float | get_brightness () const |
Get the brightness property of these light color values. In range 0.0 to 1.0. More... | |
void | set_brightness (float brightness) |
Set the brightness property of these light color values. In range 0.0 to 1.0. More... | |
float | get_color_brightness () const |
Get the color brightness property of these light color values. In range 0.0 to 1.0. More... | |
void | set_color_brightness (float brightness) |
Set the color brightness property of these light color values. In range 0.0 to 1.0. More... | |
float | get_red () const |
Get the red property of these light color values. In range 0.0 to 1.0. More... | |
void | set_red (float red) |
Set the red property of these light color values. In range 0.0 to 1.0. More... | |
float | get_green () const |
Get the green property of these light color values. In range 0.0 to 1.0. More... | |
void | set_green (float green) |
Set the green property of these light color values. In range 0.0 to 1.0. More... | |
float | get_blue () const |
Get the blue property of these light color values. In range 0.0 to 1.0. More... | |
void | set_blue (float blue) |
Set the blue property of these light color values. In range 0.0 to 1.0. More... | |
float | get_white () const |
Get the white property of these light color values. In range 0.0 to 1.0. More... | |
void | set_white (float white) |
Set the white property of these light color values. In range 0.0 to 1.0. More... | |
float | get_color_temperature () const |
Get the color temperature property of these light color values in mired. More... | |
void | set_color_temperature (float color_temperature) |
Set the color temperature property of these light color values in mired. More... | |
float | get_color_temperature_kelvin () const |
Get the color temperature property of these light color values in kelvin. More... | |
void | set_color_temperature_kelvin (float color_temperature) |
Set the color temperature property of these light color values in kelvin. More... | |
float | get_cold_white () const |
Get the cold white property of these light color values. In range 0.0 to 1.0. More... | |
void | set_cold_white (float cold_white) |
Set the cold white property of these light color values. In range 0.0 to 1.0. More... | |
float | get_warm_white () const |
Get the warm white property of these light color values. In range 0.0 to 1.0. More... | |
void | set_warm_white (float warm_white) |
Set the warm white property of these light color values. In range 0.0 to 1.0. More... | |
Static Public Member Functions | |
static LightColorValues | lerp (const LightColorValues &start, const LightColorValues &end, float completion) |
Linearly interpolate between the values in start to the values in end. More... | |
Protected Attributes | |
ColorMode | color_mode_ |
float | state_ |
ON / OFF, float for transition. More... | |
float | brightness_ |
float | color_brightness_ |
float | red_ |
float | green_ |
float | blue_ |
float | white_ |
float | color_temperature_ |
Color Temperature in Mired. More... | |
float | cold_white_ |
float | warm_white_ |
This class represents the color state for a light object.
The representation of the color state is dependent on the active color mode. A color mode consists of multiple color capabilities, and each color capability has its own representation in this class. The fields available are as follows:
Always:
For ON_OFF capability:
For BRIGHTNESS capability:
For RGB capability:
For WHITE capability:
For COLOR_TEMPERATURE capability:
For COLD_WARM_WHITE capability:
All values (except color temperature) are represented using floats in the range 0.0 (off) to 1.0 (on), and are automatically clamped to this range. Properties not used in the current color mode can still have (invalid) values and must not be accessed by the light output.
Definition at line 45 of file light_color_values.h.
|
inline |
Construct the LightColorValues with all attributes enabled, but state set to off.
Definition at line 48 of file light_color_values.h.
|
inline |
Definition at line 61 of file light_color_values.h.
|
inline |
Convert these light color values to a binary representation and write them to binary.
Definition at line 130 of file light_color_values.h.
|
inline |
Convert these light color values to a brightness-only representation and write them to brightness.
Definition at line 133 of file light_color_values.h.
|
inline |
Convert these light color values to a CT+BR representation with the given parameters.
Definition at line 199 of file light_color_values.h.
|
inline |
Convert these light color values to an CWWW representation with the given parameters.
Definition at line 175 of file light_color_values.h.
|
inline |
Convert these light color values to an RGB representation and write them to red, green, blue.
Definition at line 138 of file light_color_values.h.
|
inline |
Convert these light color values to an RGB+CT+BR representation with the given parameters.
Definition at line 168 of file light_color_values.h.
|
inline |
Convert these light color values to an RGBW representation and write them to red, green, blue, white.
Definition at line 150 of file light_color_values.h.
|
inline |
Convert these light color values to an RGBWW representation with the given parameters.
Definition at line 161 of file light_color_values.h.
|
inline |
Get the blue property of these light color values. In range 0.0 to 1.0.
Definition at line 255 of file light_color_values.h.
|
inline |
Get the brightness property of these light color values. In range 0.0 to 1.0.
Definition at line 235 of file light_color_values.h.
|
inline |
Get the cold white property of these light color values. In range 0.0 to 1.0.
Definition at line 285 of file light_color_values.h.
|
inline |
Get the color brightness property of these light color values. In range 0.0 to 1.0.
Definition at line 240 of file light_color_values.h.
|
inline |
Get the color mode of these light color values.
Definition at line 221 of file light_color_values.h.
|
inline |
Get the color temperature property of these light color values in mired.
Definition at line 265 of file light_color_values.h.
|
inline |
Get the color temperature property of these light color values in kelvin.
Definition at line 270 of file light_color_values.h.
|
inline |
Get the green property of these light color values. In range 0.0 to 1.0.
Definition at line 250 of file light_color_values.h.
|
inline |
Get the red property of these light color values. In range 0.0 to 1.0.
Definition at line 245 of file light_color_values.h.
|
inline |
Get the state of these light color values. In range from 0.0 (off) to 1.0 (on)
Definition at line 226 of file light_color_values.h.
|
inline |
Get the warm white property of these light color values. In range 0.0 to 1.0.
Definition at line 290 of file light_color_values.h.
|
inline |
Get the white property of these light color values. In range 0.0 to 1.0.
Definition at line 260 of file light_color_values.h.
|
inline |
Get the binary true/false state of these light color values.
Definition at line 228 of file light_color_values.h.
|
inlinestatic |
Linearly interpolate between the values in start to the values in end.
This function linearly interpolates the color value by just interpolating every attribute independently.
start | The interpolation start values. |
end | The interpolation end values. |
completion | The completion value. 0 -> start, 1 -> end. |
Definition at line 86 of file light_color_values.h.
|
inline |
Normalize the color (RGB/W) component.
Divides all color attributes by the maximum attribute, so effectively set at least one attribute to 1. For example: r=0.3, g=0.5, b=0.4 => r=0.6, g=1.0, b=0.8.
Note that this does NOT retain the brightness information from the color attributes.
traits | Used for determining which attributes to consider. |
Definition at line 111 of file light_color_values.h.
|
inline |
Definition at line 218 of file light_color_values.h.
|
inline |
Compare this LightColorValues to rhs, return true if and only if all attributes match.
Definition at line 212 of file light_color_values.h.
|
inline |
Set the blue property of these light color values. In range 0.0 to 1.0.
Definition at line 257 of file light_color_values.h.
|
inline |
Set the brightness property of these light color values. In range 0.0 to 1.0.
Definition at line 237 of file light_color_values.h.
|
inline |
Set the cold white property of these light color values. In range 0.0 to 1.0.
Definition at line 287 of file light_color_values.h.
|
inline |
Set the color brightness property of these light color values. In range 0.0 to 1.0.
Definition at line 242 of file light_color_values.h.
|
inline |
Set the color mode of these light color values.
Definition at line 223 of file light_color_values.h.
|
inline |
Set the color temperature property of these light color values in mired.
Definition at line 267 of file light_color_values.h.
|
inline |
Set the color temperature property of these light color values in kelvin.
Definition at line 277 of file light_color_values.h.
|
inline |
Set the green property of these light color values. In range 0.0 to 1.0.
Definition at line 252 of file light_color_values.h.
|
inline |
Set the red property of these light color values. In range 0.0 to 1.0.
Definition at line 247 of file light_color_values.h.
|
inline |
Set the state of these light color values. In range from 0.0 (off) to 1.0 (on)
Definition at line 230 of file light_color_values.h.
|
inline |
Set the state of these light color values as a binary true/false.
Definition at line 232 of file light_color_values.h.
|
inline |
Set the warm white property of these light color values. In range 0.0 to 1.0.
Definition at line 292 of file light_color_values.h.
|
inline |
Set the white property of these light color values. In range 0.0 to 1.0.
Definition at line 262 of file light_color_values.h.
|
protected |
Definition at line 301 of file light_color_values.h.
|
protected |
Definition at line 297 of file light_color_values.h.
|
protected |
Definition at line 304 of file light_color_values.h.
|
protected |
Definition at line 298 of file light_color_values.h.
|
protected |
Definition at line 295 of file light_color_values.h.
|
protected |
Color Temperature in Mired.
Definition at line 303 of file light_color_values.h.
|
protected |
Definition at line 300 of file light_color_values.h.
|
protected |
Definition at line 299 of file light_color_values.h.
|
protected |
ON / OFF, float for transition.
Definition at line 296 of file light_color_values.h.
|
protected |
Definition at line 305 of file light_color_values.h.
|
protected |
Definition at line 302 of file light_color_values.h.