This commit is contained in:
J. Nick Koston 2025-07-26 21:11:57 -10:00
parent 5cf89f8594
commit 8e6a053ead
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -85,6 +85,8 @@ class LightColorValues {
*/
static LightColorValues lerp(const LightColorValues &start, const LightColorValues &end, float completion) {
// Directly interpolate the raw values to avoid getter/setter overhead
// Linear interpolation between two clamped values produces a clamped result,
// so we can skip the setters which include redundant clamping logic
LightColorValues v;
v.color_mode_ = end.color_mode_;
v.state_ = std::lerp(start.state_, end.state_, completion);

View File

@ -24,7 +24,8 @@ void LightState::setup() {
}
// When supported color temperature range is known, initialize color temperature setting within bounds.
float min_mireds = this->get_traits().get_min_mireds();
auto traits = this->get_traits();
float min_mireds = traits.get_min_mireds();
if (min_mireds > 0) {
this->remote_values.set_color_temperature(min_mireds);
this->current_values.set_color_temperature(min_mireds);
@ -43,11 +44,8 @@ void LightState::setup() {
this->rtc_ = global_preferences->make_preference<LightStateRTCState>(this->get_object_id_hash());
// Attempt to load from preferences, else fall back to default values
if (!this->rtc_.load(&recovered)) {
recovered.state = false;
if (this->restore_mode_ == LIGHT_RESTORE_DEFAULT_ON ||
this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON) {
recovered.state = true;
}
recovered.state = (this->restore_mode_ == LIGHT_RESTORE_DEFAULT_ON ||
this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON);
} else if (this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_OFF ||
this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON) {
// Inverted restore state