ESPHome 2026.1.2
Loading...
Searching...
No Matches
light_color_values.cpp
Go to the documentation of this file.
2
3#include <cmath>
4
5namespace esphome::light {
6
8 // Directly interpolate the raw values to avoid getter/setter overhead.
9 // This is safe because:
10 // - All LightColorValues have their values clamped when set via the setters
11 // - std::lerp guarantees output is in the same range as inputs
12 // - Therefore the output doesn't need clamping, so we can skip the setters
14 v.color_mode_ = end.color_mode_;
15 v.state_ = std::lerp(start.state_, end.state_, completion);
16 v.brightness_ = std::lerp(start.brightness_, end.brightness_, completion);
17 v.color_brightness_ = std::lerp(start.color_brightness_, end.color_brightness_, completion);
18 v.red_ = std::lerp(start.red_, end.red_, completion);
19 v.green_ = std::lerp(start.green_, end.green_, completion);
20 v.blue_ = std::lerp(start.blue_, end.blue_, completion);
21 v.white_ = std::lerp(start.white_, end.white_, completion);
22 v.color_temperature_ = std::lerp(start.color_temperature_, end.color_temperature_, completion);
23 v.cold_white_ = std::lerp(start.cold_white_, end.cold_white_, completion);
24 v.warm_white_ = std::lerp(start.warm_white_, end.warm_white_, completion);
25 return v;
26}
27
28} // namespace esphome::light
This class represents the color state for a light object.
float state_
ON / OFF, float for transition.
static LightColorValues lerp(const LightColorValues &start, const LightColorValues &end, float completion)
Linearly interpolate between the values in start to the values in end.
float color_temperature_
Color Temperature in Mired.
uint8_t end[39]
Definition sun_gtil2.cpp:17