catch 0.0 in float set_level pre-adjustment (#2013)

This commit is contained in:
WeekendWarrior1 2021-07-14 12:43:30 +10:00 committed by GitHub
parent 07ae8ec553
commit 08b67e7aea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,10 @@ void FloatOutput::set_level(float state) {
#endif #endif
if (this->is_inverted()) if (this->is_inverted())
state = 1.0f - state; state = 1.0f - state;
if (state == 0.0f) { // regardless of min_power_, 0.0 means off
this->write_state(state);
return;
}
float adjusted_value = (state * (this->max_power_ - this->min_power_)) + this->min_power_; float adjusted_value = (state * (this->max_power_ - this->min_power_)) + this->min_power_;
this->write_state(adjusted_value); this->write_state(adjusted_value);
} }