|
ESPHome 2026.3.0-dev
|
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. | |
| 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. | |
| void | as_binary (bool *binary) const |
| Convert these light color values to a binary representation and write them to binary. | |
| void | as_brightness (float *brightness) const |
| Convert these light color values to a brightness-only representation and write them to brightness. | |
| void | as_rgb (float *red, float *green, float *blue) const |
| Convert these light color values to an RGB representation and write them to red, green, blue. | |
| void | as_rgbw (float *red, float *green, float *blue, float *white) const |
| Convert these light color values to an RGBW representation and write them to red, green, blue, white. | |
| void | as_rgbww (float *red, float *green, float *blue, float *cold_white, float *warm_white, bool constant_brightness=false) const |
| Convert these light color values to an RGBWW representation with the given parameters. | |
| void | as_rgbct (float color_temperature_cw, float color_temperature_ww, float *red, float *green, float *blue, float *color_temperature, float *white_brightness) const |
| Convert these light color values to an RGB+CT+BR representation with the given parameters. | |
| void | as_cwww (float *cold_white, float *warm_white, bool constant_brightness=false) const |
| Convert these light color values to an CWWW representation with the given parameters. | |
| void | as_ct (float color_temperature_cw, float color_temperature_ww, float *color_temperature, float *white_brightness) const |
| Convert these light color values to a CT+BR representation with the given parameters. | |
| bool | operator== (const LightColorValues &rhs) const |
| Compare this LightColorValues to rhs, return true if and only if all attributes match. | |
| bool | operator!= (const LightColorValues &rhs) const |
| ColorMode | get_color_mode () const |
| Get the color mode of these light color values. | |
| void | set_color_mode (ColorMode color_mode) |
| Set the color mode of these light color values. | |
| float | get_state () const |
| Get the state of these light color values. In range from 0.0 (off) to 1.0 (on) | |
| bool | is_on () const |
| Get the binary true/false state of these light color values. | |
| void | set_state (float state) |
| Set the state of these light color values. In range from 0.0 (off) to 1.0 (on) | |
| void | set_state (bool state) |
| Set the state of these light color values as a binary true/false. | |
| float | get_brightness () const |
| Get the brightness property of these light color values. In range 0.0 to 1.0. | |
| void | set_brightness (float brightness) |
| Set the brightness property of these light color values. In range 0.0 to 1.0. | |
| float | get_color_brightness () const |
| Get the color brightness property of these light color values. In range 0.0 to 1.0. | |
| void | set_color_brightness (float brightness) |
| Set the color brightness property of these light color values. In range 0.0 to 1.0. | |
| float | get_red () const |
| Get the red property of these light color values. In range 0.0 to 1.0. | |
| void | set_red (float red) |
| Set the red property of these light color values. In range 0.0 to 1.0. | |
| float | get_green () const |
| Get the green property of these light color values. In range 0.0 to 1.0. | |
| void | set_green (float green) |
| Set the green property of these light color values. In range 0.0 to 1.0. | |
| float | get_blue () const |
| Get the blue property of these light color values. In range 0.0 to 1.0. | |
| void | set_blue (float blue) |
| Set the blue property of these light color values. In range 0.0 to 1.0. | |
| float | get_white () const |
| Get the white property of these light color values. In range 0.0 to 1.0. | |
| void | set_white (float white) |
| Set the white property of these light color values. In range 0.0 to 1.0. | |
| float | get_color_temperature () const |
| Get the color temperature property of these light color values in mired. | |
| void | set_color_temperature (float color_temperature) |
| Set the color temperature property of these light color values in mired. | |
| float | get_color_temperature_kelvin () const |
| Get the color temperature property of these light color values in kelvin. | |
| void | set_color_temperature_kelvin (float color_temperature) |
| Set the color temperature property of these light color values in kelvin. | |
| float | get_cold_white () const |
| Get the cold white property of these light color values. In range 0.0 to 1.0. | |
| void | set_cold_white (float cold_white) |
| Set the cold white property of these light color values. In range 0.0 to 1.0. | |
| float | get_warm_white () const |
| Get the warm white property of these light color values. In range 0.0 to 1.0. | |
| void | set_warm_white (float warm_white) |
| Set the warm white property of these light color values. In range 0.0 to 1.0. | |
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. | |
Protected Attributes | |
| float | state_ |
| ON / OFF, float for transition. | |
| float | brightness_ |
| float | color_brightness_ |
| float | red_ |
| float | green_ |
| float | blue_ |
| float | white_ |
| float | color_temperature_ |
| Color Temperature in Mired. | |
| float | cold_white_ |
| float | warm_white_ |
| ColorMode | color_mode_ |
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 44 of file light_color_values.h.
|
inline |
Construct the LightColorValues with all attributes enabled, but state set to off.
Definition at line 47 of file light_color_values.h.
|
inline |
Definition at line 60 of file light_color_values.h.
|
inline |
Convert these light color values to a binary representation and write them to binary.
Definition at line 115 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 118 of file light_color_values.h.
|
inline |
Convert these light color values to a CT+BR representation with the given parameters.
Definition at line 181 of file light_color_values.h.
|
inline |
Convert these light color values to an CWWW representation with the given parameters.
Definition at line 157 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 121 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 150 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 133 of file light_color_values.h.
|
inline |
Convert these light color values to an RGBWW representation with the given parameters.
Definition at line 143 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 237 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 217 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 267 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 222 of file light_color_values.h.
|
inline |
Get the color mode of these light color values.
Definition at line 203 of file light_color_values.h.
|
inline |
Get the color temperature property of these light color values in mired.
Definition at line 247 of file light_color_values.h.
|
inline |
Get the color temperature property of these light color values in kelvin.
Definition at line 252 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 232 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 227 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 208 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 272 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 242 of file light_color_values.h.
|
inline |
Get the binary true/false state of these light color values.
Definition at line 210 of file light_color_values.h.
|
static |
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 10 of file light_color_values.cpp.
|
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 96 of file light_color_values.h.
|
inline |
Definition at line 200 of file light_color_values.h.
|
inline |
Compare this LightColorValues to rhs, return true if and only if all attributes match.
Definition at line 194 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 239 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 219 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 269 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 224 of file light_color_values.h.
|
inline |
Set the color mode of these light color values.
Definition at line 205 of file light_color_values.h.
|
inline |
Set the color temperature property of these light color values in mired.
Definition at line 249 of file light_color_values.h.
|
inline |
Set the color temperature property of these light color values in kelvin.
Definition at line 259 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 234 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 229 of file light_color_values.h.
|
inline |
Set the state of these light color values as a binary true/false.
Definition at line 214 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 212 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 274 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 244 of file light_color_values.h.
|
protected |
Definition at line 284 of file light_color_values.h.
|
protected |
Definition at line 280 of file light_color_values.h.
|
protected |
Definition at line 287 of file light_color_values.h.
|
protected |
Definition at line 281 of file light_color_values.h.
|
protected |
Definition at line 289 of file light_color_values.h.
|
protected |
Color Temperature in Mired.
Definition at line 286 of file light_color_values.h.
|
protected |
Definition at line 283 of file light_color_values.h.
|
protected |
Definition at line 282 of file light_color_values.h.
|
protected |
ON / OFF, float for transition.
Definition at line 279 of file light_color_values.h.
|
protected |
Definition at line 288 of file light_color_values.h.
|
protected |
Definition at line 285 of file light_color_values.h.