From 1deba54baa71d2cee7cdc2e08f2e56e2db641f28 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sat, 8 Feb 2025 15:56:06 +0100 Subject: [PATCH] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index 3682f58c66..6689ecfb8e 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -22,7 +22,6 @@ void Mcp4461Component::setup() { void Mcp4461Component::begin_() { // save WP/WL status this->set_write_protection_status_(); - this->previous_write_exec_time_ = 0; for (uint8_t i = 0; i < 8; i++) { if (this->reg_[i].initial_value.has_value()) { uint16_t initial_state; @@ -212,7 +211,7 @@ uint16_t Mcp4461Component::read_wiper_level_(uint8_t wiper) { reg |= this->get_wiper_address_(wiper); reg |= static_cast(Mcp4461Commands::READ); if (wiper > 3) { - if (this->is_eeprom_ready_for_writing_(true)) { + if (!this->is_eeprom_ready_for_writing_(true)) { return 0; } } @@ -511,7 +510,7 @@ uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) { reg |= static_cast(Mcp4461EepromLocation::MCP4461_EEPROM_1) + (static_cast(location) * 0x10); reg |= static_cast(Mcp4461Commands::READ); uint16_t buf; - if (this->is_eeprom_ready_for_writing_(true)) { + if (!this->is_eeprom_ready_for_writing_(true)) { return 0; } if (!this->read_byte_16(reg, &buf)) { @@ -642,10 +641,9 @@ bool Mcp4461Component::mcp4461_write_(uint8_t addr, uint16_t data, bool nonvolat ESP_LOGW(TAG, "Ignoring write to write protected chip"); return false; } - if (this->is_eeprom_ready_for_writing_(true)) { + if (!this->is_eeprom_ready_for_writing_(true)) { return false; } - this->previous_write_exec_time_ = millis(); } return this->write_byte(reg, value_byte); }