1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-28 21:48:16 +00:00

Update mcp4461_output.cpp

This commit is contained in:
Oliver Kleinecke 2025-02-06 16:47:40 +01:00 committed by GitHub
parent 30d4cd089f
commit ab85e4e28f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,10 +35,11 @@ void Mcp4461Wiper::set_initial_value(float initial_value) {
return;
}
if (initial_value >= 0.000 && initial_value <= 0.256) {
this->initial_value_ = static_cast<uint16_t>(initial_value * 1000);
float state = initial_value * 1000;
this->initial_value_ = static_cast<uint16_t>(state);
// Use the value
ESP_LOGCONFIG(TAG, "Setting initial value %" PRIu16 "", *this->initial_value_);
this->state_ = initial_value * 1000;
this->state_ = state;
this->parent_->set_wiper_level(this->wiper_, *this->initial_value_);
} else {
ESP_LOGCONFIG(TAG, "Invalid initial value set, retaining previous wiper level.");