mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
8eb8b3dc0fed6d394b5ff418d316052664fbde77
Move `float_out_of_unit_range()` / add `clamp_unit_float()` to light_color_values.h so the nine `set_*(float)` setters can use the unsigned bit-pattern clamp instead of `std::clamp(x, 0.0f, 1.0f)`. `std::clamp` expands to two soft-float `__ltsf2`/`__gtsf2` calls per invocation on ESP8266 — replacing it with a single unsigned compare saves code across every caller of these setters (StrobeLightEffect, the 11-arg LightColorValues constructor, external components). Split the cold-path helper: `log_value_out_of_range_()` now only logs, and each caller applies the clamp strategy appropriate to its range (`clamp_unit_float` for the 8-field loop, `std::clamp` for color temperature's runtime-variable range). Add layout/format assertions: - std::is_standard_layout_v on LightCall and LightColorValues so the offsetof arithmetic in the clamp loop is well-defined. - sizeof(float) == 4 and is_iec559 so the bit-pattern trick is valid. A direct __builtin_bit_cast check would be cleaner but is not available on the ESP8266 xtensa toolchain. Text-section delta vs. prior commit (isolated light build): ESP32-IDF: .flash.text 137760 -> 136988 (-772 B) ESP8266: .irom0.text 268440 -> 267912 (-528 B)
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
546 MiB
Languages
C++
60.1%
Python
39.3%
C
0.3%
JavaScript
0.2%
