From f897295db50093d868adee84e057edc548d77d84 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 18:58:26 +0100 Subject: [PATCH] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index ee39a2db6f..23809f85c5 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -366,6 +366,10 @@ bool Mcp4461Component::increase_wiper_(Mcp4461WiperIdx wiper) { ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return false; } + if (this->reg_[wiper_idx].state == 256) { + ESP_LOGV(TAG, "%s", "Maximum wiper level reached, further increase of wiper %" PRIu8 " prohibited", wiper_idx); + return false; + } ESP_LOGV(TAG, "Increasing wiper %" PRIu8 "", wiper_idx); uint8_t reg = 0; uint8_t addr; @@ -396,6 +400,10 @@ bool Mcp4461Component::decrease_wiper_(Mcp4461WiperIdx wiper) { ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return false; } + if (this->reg_[wiper_idx].state == 0) { + ESP_LOGV(TAG, "%s", "Minimum wiper level reached, further decrease of wiper %" PRIu8 " prohibited", wiper_idx); + return false; + } ESP_LOGV(TAG, "Decreasing wiper %" PRIu8 "", wiper_idx); uint8_t reg = 0; uint8_t addr;