diff --git a/esphome/components/x9c/x9c.cpp b/esphome/components/x9c/x9c.cpp index 8f66c46015..773e52d6e1 100644 --- a/esphome/components/x9c/x9c.cpp +++ b/esphome/components/x9c/x9c.cpp @@ -6,7 +6,7 @@ namespace x9c { static const char *const TAG = "x9c.output"; -void X9cOutput::trim_value(int change_amount) { +void X9cOutput::trim_value(int32_t change_amount) { if (change_amount == 0) { return; } @@ -47,17 +47,17 @@ void X9cOutput::setup() { if (this->initial_value_ <= 0.50) { this->trim_value(-101); // Set min value (beyond 0) - this->trim_value(static_cast(roundf(this->initial_value_ * 100))); + this->trim_value(lroundf(this->initial_value_ * 100)); } else { this->trim_value(101); // Set max value (beyond 100) - this->trim_value(static_cast(roundf(this->initial_value_ * 100) - 100)); + this->trim_value(lroundf(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(static_cast(roundf((state - this->pot_value_) * 100))); + this->trim_value(lroundf((state - this->pot_value_) * 100)); this->pot_value_ = state; } diff --git a/esphome/components/x9c/x9c.h b/esphome/components/x9c/x9c.h index e7cc29a6cc..66c3df14e1 100644 --- a/esphome/components/x9c/x9c.h +++ b/esphome/components/x9c/x9c.h @@ -18,7 +18,7 @@ class X9cOutput : public output::FloatOutput, public Component { void setup() override; void dump_config() override; - void trim_value(int change_amount); + void trim_value(int32_t change_amount); protected: void write_state(float state) override;