From 8164868cc5f7cccd78c019d83a6b8872e476cf73 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 12:29:14 +0100 Subject: [PATCH 01/10] Update mcp4461.h --- esphome/components/mcp4461/mcp4461.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index 272b1366a8..6d158441ef 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -101,7 +101,8 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { 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 - MCP4461_WIPER_LOCKED, // The wiper is locked using WiperLock-technology - all actions for this wiper will be aborted/discarded + MCP4461_WIPER_LOCKED, // The wiper is locked using WiperLock-technology - all actions for this wiper will be + aborted/discarded } error_code_{MCP4461_STATUS_OK}; protected: From f596248824d148cbd8996fc246fdcc47905b6dbe Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 12:33:00 +0100 Subject: [PATCH 02/10] Update mcp4461.h --- esphome/components/mcp4461/mcp4461.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index 6d158441ef..61b7713f71 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -92,17 +92,17 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { void set_initial_value(Mcp4461WiperIdx wiper, float initial_value); enum ErrorCode { - MCP4461_STATUS_OK = 0, // CMD completed successfully - 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_PARENT_FAILED, // Parent component failed - MCP4461_VALUE_INVALID, // Invalid value given for wiper / eeprom + MCP4461_STATUS_OK = 0, // CMD completed successfully + 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_PARENT_FAILED, // Parent component failed + 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 MCP4461_WIPER_LOCKED, // The wiper is locked using WiperLock-technology - all actions for this wiper will be - aborted/discarded + // aborted/discarded } error_code_{MCP4461_STATUS_OK}; protected: From 1c6d3cccf4d711a2075c16ac5dacd39e2c4f089c Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 13:07:09 +0100 Subject: [PATCH 03/10] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 60 +++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index 6c0d1ae1ba..4ded854a07 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -44,7 +44,7 @@ void Mcp4461Component::begin_() { } // Converts a status to a human readable string -static const LogString *mcp4461_get_message_string_(int status) { +static const LogString *mcp4461_get_message_string(int status) { switch (status) { case Mcp4461Component::MCP4461_STATUS_I2C_ERROR: return LOG_STR("I2C error - communication with MCP4461 failed!"); @@ -90,7 +90,7 @@ void Mcp4461Component::dump_config() { ESP_LOGCONFIG(TAG, "mcp4461:"); LOG_I2C_DEVICE(this); if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); } // log wiper status for (uint8_t i = 0; i < 8; ++i) { @@ -166,7 +166,7 @@ void Mcp4461Component::loop() { uint8_t Mcp4461Component::get_status_register() { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return 0; } uint8_t reg = 0; @@ -224,12 +224,12 @@ uint8_t Mcp4461Component::get_wiper_address_(uint8_t wiper) { uint16_t Mcp4461Component::get_wiper_level(Mcp4461WiperIdx wiper) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return 0; } 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))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_DISABLED))); return 0; } if (!(this->reg_[wiper_idx].enabled)) { @@ -260,12 +260,12 @@ uint16_t Mcp4461Component::read_wiper_level_(uint8_t wiper) { void Mcp4461Component::update_wiper_level(Mcp4461WiperIdx wiper) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + 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))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_DISABLED))); return; } uint16_t data; @@ -276,20 +276,20 @@ void Mcp4461Component::update_wiper_level(Mcp4461WiperIdx wiper) { void Mcp4461Component::set_wiper_level(Mcp4461WiperIdx wiper, uint16_t value) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return; } uint8_t wiper_idx = static_cast(wiper); if (value > 0x100) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_VALUE_INVALID))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_VALUE_INVALID))); return; } if (!(this->reg_[wiper_idx].enabled)) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_DISABLED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_DISABLED))); return; } if (this->reg_[wiper_idx].wiper_lock_active) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_LOCKED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return; } ESP_LOGV(TAG, "Setting MCP4461 wiper %" PRIu8 " to %" PRIu16 "!", wiper_idx, value); @@ -312,16 +312,16 @@ void Mcp4461Component::write_wiper_level_(uint8_t wiper, uint16_t value) { void Mcp4461Component::enable_wiper(Mcp4461WiperIdx wiper) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + 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))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_ENABLED))); return; } if (this->reg_[wiper_idx].wiper_lock_active) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_LOCKED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return; } ESP_LOGV(TAG, "Enabling wiper %" PRIu8, wiper_idx); @@ -331,16 +331,16 @@ void Mcp4461Component::enable_wiper(Mcp4461WiperIdx wiper) { void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + 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))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_DISABLED))); return; } if (this->reg_[wiper_idx].wiper_lock_active) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_LOCKED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return; } ESP_LOGV(TAG, "Disabling wiper %" PRIu8, wiper_idx); @@ -350,16 +350,16 @@ void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) { bool Mcp4461Component::increase_wiper(Mcp4461WiperIdx wiper) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return false; } 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))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_DISABLED))); return false; } if (this->reg_[wiper_idx].wiper_lock_active) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_LOCKED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return false; } ESP_LOGV(TAG, "Increasing wiper %" PRIu8 "", wiper_idx); @@ -380,16 +380,16 @@ bool Mcp4461Component::increase_wiper(Mcp4461WiperIdx wiper) { bool Mcp4461Component::decrease_wiper(Mcp4461WiperIdx wiper) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return false; } 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))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_DISABLED))); return false; } if (this->reg_[wiper_idx].wiper_lock_active) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WIPER_LOCKED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WIPER_LOCKED))); return false; } ESP_LOGV(TAG, "Decreasing wiper %" PRIu8 "", wiper_idx); @@ -434,7 +434,7 @@ uint8_t Mcp4461Component::calc_terminal_connector_byte_(Mcp4461TerminalIdx termi uint8_t Mcp4461Component::get_terminal_register(Mcp4461TerminalIdx terminal_connector) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return 0; } uint8_t reg = 0; @@ -485,7 +485,7 @@ void Mcp4461Component::update_terminal_register(Mcp4461TerminalIdx terminal_conn bool Mcp4461Component::set_terminal_register(Mcp4461TerminalIdx terminal_connector, uint8_t data) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return false; } uint8_t addr; @@ -507,7 +507,7 @@ bool Mcp4461Component::set_terminal_register(Mcp4461TerminalIdx terminal_connect void Mcp4461Component::enable_terminal(Mcp4461WiperIdx wiper, char terminal) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return; } uint8_t wiper_idx = static_cast(wiper); @@ -537,7 +537,7 @@ void Mcp4461Component::enable_terminal(Mcp4461WiperIdx wiper, char terminal) { void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return; } uint8_t wiper_idx = static_cast(wiper); @@ -567,7 +567,7 @@ void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) { uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return 0; } uint8_t reg = 0; @@ -588,7 +588,7 @@ uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) { bool Mcp4461Component::set_eeprom_value(Mcp4461EepromLocation location, uint16_t value) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(this->error_code_))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return false; } uint8_t addr = 0; @@ -705,7 +705,7 @@ bool Mcp4461Component::mcp4461_write_(uint8_t addr, uint16_t data, bool nonvolat reg |= static_cast(Mcp4461Commands::WRITE); if (nonvolatile) { if (this->write_protected_) { - ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string_(MCP4461_WRITE_PROTECTED))); + ESP_LOGW(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(MCP4461_WRITE_PROTECTED))); return false; } if (!this->is_eeprom_ready_for_writing_(true)) { From c0982a9141e0419031de2fddf2f6dccb267d6e8c Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 13:29:36 +0100 Subject: [PATCH 04/10] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index 4ded854a07..c286d74c85 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -457,7 +457,7 @@ uint8_t Mcp4461Component::get_terminal_register(Mcp4461TerminalIdx terminal_conn void Mcp4461Component::update_terminal_register(Mcp4461TerminalIdx terminal_connector) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return; } if ((static_cast(terminal_connector) != 0 && static_cast(terminal_connector) != 1)) { From 907e57956c81688db2a10e562a4929be69a46c00 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 13:32:50 +0100 Subject: [PATCH 05/10] Update mcp4461_output.cpp --- .../components/mcp4461/output/mcp4461_output.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index 932cf1a5ac..5602edb918 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -11,7 +11,7 @@ static const char *const TAG = "mcp4461.output"; void Mcp4461Wiper::write_state(float state) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -33,7 +33,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level void Mcp4461Wiper::save_level() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -49,7 +49,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -62,7 +62,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -75,7 +75,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -90,7 +90,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -105,7 +105,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -118,7 +118,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) { void Mcp4461Wiper::disable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); From b6a5f49b3c83ec014b3aa70ab98fad451ed84270 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:05:35 +0100 Subject: [PATCH 06/10] Update mcp4461_output.cpp --- .../components/mcp4461/output/mcp4461_output.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index 5602edb918..46dfe28bbd 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -11,7 +11,7 @@ static const char *const TAG = "mcp4461.output"; void Mcp4461Wiper::write_state(float state) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -33,7 +33,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level void Mcp4461Wiper::save_level() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -49,7 +49,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -62,7 +62,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -75,7 +75,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -90,7 +90,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -105,7 +105,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -118,7 +118,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) { void Mcp4461Wiper::disable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->parent_->mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); From 353c2aa2ddf6a631791b12454f94ac2baa54a000 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:13:53 +0100 Subject: [PATCH 07/10] 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 c286d74c85..dcc4b566ce 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -22,7 +22,7 @@ void Mcp4461Component::setup() { void Mcp4461Component::begin_() { // save WP/WL status - this->set_write_protection_status_(); + this->update_write_protection_status_(); for (uint8_t i = 0; i < 8; i++) { if (this->reg_[i].initial_value.has_value()) { uint16_t initial_state; @@ -76,7 +76,7 @@ void Mcp4461Component::set_initial_value(Mcp4461WiperIdx wiper, float initial_va this->reg_[wiper_id].initial_value = initial_value; } -void Mcp4461Component::set_write_protection_status_() { +void Mcp4461Component::update_write_protection_status_() { uint8_t status_register_value; status_register_value = this->get_status_register(); this->write_protected_ = static_cast((status_register_value >> 0) & 0x01); From 1323f4e5fc36c9df5b7a9ebdcf9e7811cc6082d5 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:14:11 +0100 Subject: [PATCH 08/10] 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 61b7713f71..1f6598e478 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -107,7 +107,7 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { protected: friend class Mcp4461Wiper; - void set_write_protection_status_(); + void update_write_protection_status_(); uint8_t get_wiper_address_(uint8_t wiper); uint16_t read_wiper_level_(uint8_t wiper); bool is_writing_(); From c4d720835122abe15f5e9833157344cf560f3f45 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:20:37 +0100 Subject: [PATCH 09/10] Update mcp4461_output.cpp --- .../mcp4461/output/mcp4461_output.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index 46dfe28bbd..bdbb89f098 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -8,10 +8,11 @@ namespace esphome { namespace mcp4461 { static const char *const TAG = "mcp4461.output"; +static const LogString *const LOG_PARENT_FAILED_STR = LOG_STR("Parent MCP4461 component has failed! Aborting"); void Mcp4461Wiper::write_state(float state) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -33,7 +34,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level void Mcp4461Wiper::save_level() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -49,7 +50,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -62,7 +63,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -75,7 +76,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -90,7 +91,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -105,7 +106,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -118,7 +119,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) { void Mcp4461Wiper::disable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::mcp4461_get_message_string(Mcp4461Component::MCP4461_PARENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); return; } uint8_t wiper_idx = static_cast(this->wiper_); From 94c564ac5669b9785a7018e5152c25b94d4a5ef9 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:22:52 +0100 Subject: [PATCH 10/10] Update mcp4461_output.cpp --- .../components/mcp4461/output/mcp4461_output.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index bdbb89f098..f3bea80b9b 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -12,7 +12,7 @@ static const LogString *const LOG_PARENT_FAILED_STR = LOG_STR("Parent MCP4461 co void Mcp4461Wiper::write_state(float state) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -34,7 +34,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level void Mcp4461Wiper::save_level() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -50,7 +50,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -63,7 +63,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -76,7 +76,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -91,7 +91,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -106,7 +106,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -119,7 +119,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) { void Mcp4461Wiper::disable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_);