From ae6f128951546b37a8373e8a4beb2df88e215714 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 12:17:51 +0100 Subject: [PATCH] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index f508d63bc6..0dded2b625 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -263,11 +263,11 @@ void Mcp4461Component::update_wiper_level(Mcp4461WiperIdx wiper) { ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); return; } + uint8_t wiper_idx = static_cast(wiper); if (!(this->reg_[wiper_idx].enabled)) { ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_DISABLED))); return; } - uint8_t wiper_idx = static_cast(wiper); uint16_t data; data = this->get_wiper_level(wiper); ESP_LOGV(TAG, "Got value %" PRIu16 " from wiper %" PRIu8, data, wiper_idx); @@ -315,6 +315,7 @@ void Mcp4461Component::enable_wiper(Mcp4461WiperIdx wiper) { ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); return; } + uint8_t wiper_idx = static_cast(wiper); if ((this->reg_[wiper_idx].enabled)) { ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_ENABLED))); return; @@ -323,7 +324,6 @@ void Mcp4461Component::enable_wiper(Mcp4461WiperIdx wiper) { ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_LOCKED))); return; } - uint8_t wiper_idx = static_cast(wiper); ESP_LOGV(TAG, "Enabling wiper %" PRIu8, wiper_idx); this->reg_[wiper_idx].terminal_hw = true; this->update_ = true;