mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 23:21:54 +00:00 
			
		
		
		
	preen
This commit is contained in:
		| @@ -85,6 +85,8 @@ class LightColorValues { | |||||||
|    */ |    */ | ||||||
|   static LightColorValues lerp(const LightColorValues &start, const LightColorValues &end, float completion) { |   static LightColorValues lerp(const LightColorValues &start, const LightColorValues &end, float completion) { | ||||||
|     // Directly interpolate the raw values to avoid getter/setter overhead |     // 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; |     LightColorValues v; | ||||||
|     v.color_mode_ = end.color_mode_; |     v.color_mode_ = end.color_mode_; | ||||||
|     v.state_ = std::lerp(start.state_, end.state_, completion); |     v.state_ = std::lerp(start.state_, end.state_, completion); | ||||||
|   | |||||||
| @@ -24,7 +24,8 @@ void LightState::setup() { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // When supported color temperature range is known, initialize color temperature setting within bounds. |   // 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) { |   if (min_mireds > 0) { | ||||||
|     this->remote_values.set_color_temperature(min_mireds); |     this->remote_values.set_color_temperature(min_mireds); | ||||||
|     this->current_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()); |       this->rtc_ = global_preferences->make_preference<LightStateRTCState>(this->get_object_id_hash()); | ||||||
|       // Attempt to load from preferences, else fall back to default values |       // Attempt to load from preferences, else fall back to default values | ||||||
|       if (!this->rtc_.load(&recovered)) { |       if (!this->rtc_.load(&recovered)) { | ||||||
|         recovered.state = false; |         recovered.state = (this->restore_mode_ == LIGHT_RESTORE_DEFAULT_ON || | ||||||
|         if (this->restore_mode_ == LIGHT_RESTORE_DEFAULT_ON || |                            this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON); | ||||||
|             this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON) { |  | ||||||
|           recovered.state = true; |  | ||||||
|         } |  | ||||||
|       } else if (this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_OFF || |       } else if (this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_OFF || | ||||||
|                  this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON) { |                  this->restore_mode_ == LIGHT_RESTORE_INVERTED_DEFAULT_ON) { | ||||||
|         // Inverted restore state |         // Inverted restore state | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user