7static const char *
const TAG =
"light.addressable";
12#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
15 ESP_LOGVV(TAG,
"Addressable Light '%s' (effect_active=%s)", name, YESNO(this->
effect_active_));
16 for (
int i = 0; i < this->
size(); i++) {
17 auto color = this->
get(i);
18 ESP_LOGVV(TAG,
" [%2d] Color: R=%3u G=%3u B=%3u W=%3u", i, color.get_red_raw(), color.get_green_raw(),
19 color.get_blue_raw(), color.get_white_raw());
31 auto r = to_uint8_scale(
val.get_color_brightness() *
val.get_red());
32 auto g = to_uint8_scale(
val.get_color_brightness() *
val.get_green());
33 auto b = to_uint8_scale(
val.get_color_brightness() *
val.get_blue());
34 auto w = to_uint8_scale(
val.get_white());
35 return Color(r, g, b, w);
40 auto max_brightness = to_uint8_scale(
val.get_brightness() *
val.get_state());
61 this->
target_color_ *= to_uint8_scale(end_values.get_brightness() * end_values.get_state());
86 float alpha255 = alpha * 255.0f;
87 float alpha255int = floorf(alpha255);
88 float alpha255remainder = alpha255 - alpha255int;
94 alpha255 += alpha_add;
95 alpha255 =
clamp(alpha255, 0.0f, 255.0f);
96 auto alpha8 =
static_cast<uint8_t
>(alpha255);
99 uint8_t inv_alpha8 = 255 - alpha8;
102 for (
auto led : this->
light_)
103 led.set(add + led.get() * inv_alpha8);
virtual void setup()
Where the component's initialization should happen.
void set_interval(const std::string &name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
const StringRef & get_name() const
constexpr const char * c_str() const
LightState * state_parent_
ESPColorView get(int32_t index)
virtual int32_t size() const =0
void call_setup() override
bool is_effect_active() const
void update_state(LightState *state) override
std::unique_ptr< LightTransformer > create_default_transition() override
ESPColorCorrection correction_
void set_local_brightness(uint8_t local_brightness)
This class represents the color state for a light object.
static LightColorValues lerp(const LightColorValues &start, const LightColorValues &end, float completion)
Linearly interpolate between the values in start to the values in end.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Color color_from_light_color_values(LightColorValues val)
Convert the color information from a LightColorValues object to a Color object (does not apply bright...
Providing packet encoding functions for exchanging data with a remote host.
std::unique_ptr< T > make_unique(Args &&...args)
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)