ESPHome
2026.1.2
Loading...
Searching...
No Matches
esphome
components
light
light_color_values.cpp
Go to the documentation of this file.
1
#include "
light_color_values.h
"
2
3
#include <cmath>
4
5
namespace
esphome::light
{
6
7
LightColorValues
LightColorValues::lerp
(
const
LightColorValues
&start,
const
LightColorValues
&
end
,
float
completion) {
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
13
LightColorValues
v;
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
esphome::light::LightColorValues
This class represents the color state for a light object.
Definition
light_color_values.h:44
esphome::light::LightColorValues::red_
float red_
Definition
light_color_values.h:283
esphome::light::LightColorValues::state_
float state_
ON / OFF, float for transition.
Definition
light_color_values.h:280
esphome::light::LightColorValues::blue_
float blue_
Definition
light_color_values.h:285
esphome::light::LightColorValues::lerp
static LightColorValues lerp(const LightColorValues &start, const LightColorValues &end, float completion)
Linearly interpolate between the values in start to the values in end.
Definition
light_color_values.cpp:7
esphome::light::LightColorValues::brightness_
float brightness_
Definition
light_color_values.h:281
esphome::light::LightColorValues::color_temperature_
float color_temperature_
Color Temperature in Mired.
Definition
light_color_values.h:287
esphome::light::LightColorValues::color_mode_
ColorMode color_mode_
Definition
light_color_values.h:290
esphome::light::LightColorValues::cold_white_
float cold_white_
Definition
light_color_values.h:288
esphome::light::LightColorValues::warm_white_
float warm_white_
Definition
light_color_values.h:289
esphome::light::LightColorValues::white_
float white_
Definition
light_color_values.h:286
esphome::light::LightColorValues::green_
float green_
Definition
light_color_values.h:284
esphome::light::LightColorValues::color_brightness_
float color_brightness_
Definition
light_color_values.h:282
light_color_values.h
esphome::light
Definition
addressable_light.cpp:4
end
uint8_t end[39]
Definition
sun_gtil2.cpp:17
Generated by
1.12.0