mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 17:28:01 +01:00
x9c: fix off by 1 error (#6318)
This commit is contained in:
parent
56837b0947
commit
f3ed091395
@ -49,17 +49,17 @@ void X9cOutput::setup() {
|
||||
|
||||
if (this->initial_value_ <= 0.50) {
|
||||
this->trim_value(-101); // Set min value (beyond 0)
|
||||
this->trim_value((int) (this->initial_value_ * 100));
|
||||
this->trim_value(static_cast<uint32_t>(roundf(this->initial_value_ * 100)));
|
||||
} else {
|
||||
this->trim_value(101); // Set max value (beyond 100)
|
||||
this->trim_value((int) (this->initial_value_ * 100) - 100);
|
||||
this->trim_value(static_cast<uint32_t>(roundf(this->initial_value_ * 100) - 100));
|
||||
}
|
||||
this->pot_value_ = this->initial_value_;
|
||||
this->write_state(this->initial_value_);
|
||||
}
|
||||
|
||||
void X9cOutput::write_state(float state) {
|
||||
this->trim_value((int) ((state - this->pot_value_) * 100));
|
||||
this->trim_value(static_cast<uint32_t>(roundf((state - this->pot_value_) * 100)));
|
||||
this->pot_value_ = state;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user