From 153ef8c741339e1b9f6645509abd7254d73e4c14 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Thu, 20 Feb 2025 17:50:46 +0100 Subject: [PATCH] Update mcp4461.h --- esphome/components/mcp4461/mcp4461.h | 34 +++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index ea443616b1..2742cd8340 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -100,8 +100,22 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { /// @param[wiper] wiper for which terminal shall be initialized disabled /// @param[terminal] terminal to disable, one of { 'a', 'b', 'w', 'h' } void initialize_terminal_disabled(Mcp4461WiperIdx wiper, char terminal); - /// @brief get error code - int get_error_code(); + + /// @brief available/required status codes + enum ErrorCode { + MCP4461_STATUS_OK = 0, // CMD completed successfully + MCP4461_FAILED, // component failed + 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_PROHIBITED_FOR_NONVOLATILE, // + 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 + } error_code{MCP4461_STATUS_OK}; protected: friend class Mcp4461Wiper; @@ -172,22 +186,6 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { /// @return bool - true if write successful, false if not bool set_terminal_register_(Mcp4461TerminalIdx terminal_connector, uint8_t data); - /// @brief available/required status codes - enum ErrorCode { - MCP4461_STATUS_OK = 0, // CMD completed successfully - MCP4461_FAILED, // component failed - 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_PROHIBITED_FOR_NONVOLATILE, // - 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 - } error_code_{MCP4461_STATUS_OK}; - WiperState reg_[8]; void begin_(); bool last_eeprom_write_timed_out_{false};