From ace6d366c271d2438e38e715fa147d483b595573 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:57:21 +0100 Subject: [PATCH 1/4] Update mcp4461.h --- esphome/components/mcp4461/mcp4461.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index bbb2da26ad..830f483b5a 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -97,7 +97,7 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { MCP4461_STATUS_I2C_ERROR, // Unable to communicate with device MCP4461_STATUS_REGISTER_INVALID, // Status register value was invalid MCP4461_STATUS_REGISTER_ERROR, // Error fetching status register - MCP4461_VALUE_INVALID, // Invalid value given for wiper / eeprom + MCP4461_VALUE_INVALID, // Invalid value given for wiper / eeprom MCP4461_WRITE_PROTECTED, // The value was read, but the CRC over the payload (valid and data) does not match MCP4461_WIPER_ENABLED, // The wiper is enabled, discard additional enabling actions MCP4461_WIPER_DISABLED, // The wiper is disabled - all actions for this wiper will be aborted/discarded From 5a4eb4349e7a7465c4dfac69da98f05f64f19108 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 15:41:26 +0100 Subject: [PATCH 2/4] Update mcp4461.h --- esphome/components/mcp4461/mcp4461.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index 830f483b5a..1af51cae1b 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -8,6 +8,7 @@ namespace esphome { namespace mcp4461 { struct WiperState { + bool update = false; bool terminal_a = true; bool terminal_b = true; bool terminal_w = true; @@ -118,7 +119,6 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { WiperState reg_[8]; void begin_(); - bool update_{false}; bool last_eeprom_write_timed_out_{false}; bool write_protected_{false}; bool wiper_0_disabled_{false}; From 70b52466d1b345a2cd1c8a1b21f60711368cdd6f Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 15:44:11 +0100 Subject: [PATCH 3/4] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index c0002dc6d9..5bbed4be59 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -134,9 +134,9 @@ void Mcp4461Component::loop() { if (status_has_warning()) { this->get_status_register(); } - if (this->update_) { - uint8_t i; - for (i = 0; i < 8; i++) { + uint8_t i; + for (i = 0; i < 8; i++) { + if (this->reg_[i].update) { // set wiper i state if changed if (this->reg_[i].state != this->read_wiper_level_(i)) { this->write_wiper_level_(i, this->reg_[i].state); @@ -158,7 +158,7 @@ void Mcp4461Component::loop() { } } } - this->update_ = false; + this->reg_[i].update = false; } } From 009ce097f0ad1865aa210a669486117cae2f07f6 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 15:45:21 +0100 Subject: [PATCH 4/4] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index 5bbed4be59..dabe84613e 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -292,7 +292,7 @@ void Mcp4461Component::set_wiper_level(Mcp4461WiperIdx wiper, uint16_t value) { } ESP_LOGV(TAG, "Setting MCP4461 wiper %" PRIu8 " to %" PRIu16 "!", wiper_idx, value); this->reg_[wiper_idx].state = value; - this->update_ = true; + this->reg_[wiper_idx].update = true; } void Mcp4461Component::write_wiper_level_(uint8_t wiper, uint16_t value) { @@ -324,7 +324,7 @@ void Mcp4461Component::enable_wiper(Mcp4461WiperIdx wiper) { } ESP_LOGV(TAG, "Enabling wiper %" PRIu8, wiper_idx); this->reg_[wiper_idx].terminal_hw = true; - this->update_ = true; + this->reg_[wiper_idx].update = true; } void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) { @@ -343,7 +343,7 @@ void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) { } ESP_LOGV(TAG, "Disabling wiper %" PRIu8, wiper_idx); this->reg_[wiper_idx].terminal_hw = false; - this->update_ = true; + this->reg_[wiper_idx].update = true; } bool Mcp4461Component::increase_wiper(Mcp4461WiperIdx wiper) { @@ -530,7 +530,7 @@ void Mcp4461Component::enable_terminal(Mcp4461WiperIdx wiper, char terminal) { ESP_LOGW(TAG, "Unknown terminal %c specified", terminal); return; } - this->update_ = true; + this->reg_[wiper_idx].update = true; } void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) { @@ -560,7 +560,7 @@ void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) { ESP_LOGW(TAG, "Unknown terminal %c specified", terminal); return; } - this->update_ = true; + this->reg_[wiper_idx].update = true; } uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) {