ESPHome  2025.4.0
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
esphome::mcp4461::Mcp4461Component Class Reference

#include <mcp4461.h>

Inheritance diagram for esphome::mcp4461::Mcp4461Component:
esphome::Component esphome::i2c::I2CDevice

Public Member Functions

 Mcp4461Component (bool disable_wiper_0, bool disable_wiper_1, bool disable_wiper_2, bool disable_wiper_3)
 
void setup () override
 
void dump_config () override
 
float get_setup_priority () const override
 
void loop () override
 
uint16_t get_eeprom_value (Mcp4461EepromLocation location)
 get eeprom value from location More...
 
bool set_eeprom_value (Mcp4461EepromLocation location, uint16_t value)
 set eeprom value at specified location More...
 
void set_initial_value (Mcp4461WiperIdx wiper, float initial_value)
 public function used to set initial value More...
 
void initialize_terminal_disabled (Mcp4461WiperIdx wiper, char terminal)
 public function used to set disable terminal config More...
 
void read_status_register_to_log ()
 read status register to log More...
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
void mark_failed (const char *message)
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning (const char *message="unspecified")
 
void status_set_error (const char *message="unspecified")
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 
- Public Member Functions inherited from esphome::i2c::I2CDevice
 I2CDevice ()=default
 we use the C++ default constructor More...
 
void set_i2c_address (uint8_t address)
 We store the address of the device on the bus. More...
 
void set_i2c_bus (I2CBus *bus)
 we store the pointer to the I2CBus to use More...
 
I2CRegister reg (uint8_t a_register)
 calls the I2CRegister constructor More...
 
I2CRegister16 reg16 (uint16_t a_register)
 calls the I2CRegister16 constructor More...
 
ErrorCode read (uint8_t *data, size_t len)
 reads an array of bytes from the device using an I2CBus More...
 
ErrorCode read_register (uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
 reads an array of bytes from a specific register in the I²C device More...
 
ErrorCode read_register16 (uint16_t a_register, uint8_t *data, size_t len, bool stop=true)
 reads an array of bytes from a specific register in the I²C device More...
 
ErrorCode write (const uint8_t *data, size_t len, bool stop=true)
 writes an array of bytes to a device using an I2CBus More...
 
ErrorCode write_register (uint8_t a_register, const uint8_t *data, size_t len, bool stop=true)
 writes an array of bytes to a specific register in the I²C device More...
 
ErrorCode write_register16 (uint16_t a_register, const uint8_t *data, size_t len, bool stop=true)
 write an array of bytes to a specific register in the I²C device More...
 
bool read_bytes (uint8_t a_register, uint8_t *data, uint8_t len)
 Compat APIs All methods below have been added for compatibility reasons. More...
 
bool read_bytes_raw (uint8_t *data, uint8_t len)
 
template<size_t N>
optional< std::array< uint8_t, N > > read_bytes (uint8_t a_register)
 
template<size_t N>
optional< std::array< uint8_t, N > > read_bytes_raw ()
 
bool read_bytes_16 (uint8_t a_register, uint16_t *data, uint8_t len)
 
bool read_byte (uint8_t a_register, uint8_t *data, bool stop=true)
 
optional< uint8_t > read_byte (uint8_t a_register)
 
bool read_byte_16 (uint8_t a_register, uint16_t *data)
 
bool write_bytes (uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
 
bool write_bytes (uint8_t a_register, const std::vector< uint8_t > &data)
 
template<size_t N>
bool write_bytes (uint8_t a_register, const std::array< uint8_t, N > &data)
 
bool write_bytes_16 (uint8_t a_register, const uint16_t *data, uint8_t len)
 
bool write_byte (uint8_t a_register, uint8_t data, bool stop=true)
 
bool write_byte_16 (uint8_t a_register, uint16_t data)
 

Protected Types

enum  ErrorCode {
  MCP4461_STATUS_OK = 0, MCP4461_FAILED, MCP4461_STATUS_I2C_ERROR, MCP4461_STATUS_REGISTER_INVALID,
  MCP4461_STATUS_REGISTER_ERROR, MCP4461_PROHIBITED_FOR_NONVOLATILE, MCP4461_VALUE_INVALID, MCP4461_WRITE_PROTECTED,
  MCP4461_WIPER_ENABLED, MCP4461_WIPER_DISABLED, MCP4461_WIPER_LOCKED
}
 

Protected Member Functions

void update_write_protection_status_ ()
 
uint8_t get_wiper_address_ (uint8_t wiper)
 
uint16_t read_wiper_level_ (uint8_t wiper)
 
uint8_t get_status_register_ ()
 
uint16_t get_wiper_level_ (Mcp4461WiperIdx wiper)
 
bool set_wiper_level_ (Mcp4461WiperIdx wiper, uint16_t value)
 
bool update_wiper_level_ (Mcp4461WiperIdx wiper)
 
void enable_wiper_ (Mcp4461WiperIdx wiper)
 
void disable_wiper_ (Mcp4461WiperIdx wiper)
 
bool increase_wiper_ (Mcp4461WiperIdx wiper)
 
bool decrease_wiper_ (Mcp4461WiperIdx wiper)
 
void enable_terminal_ (Mcp4461WiperIdx wiper, char terminal)
 
void disable_terminal_ (Mcp4461WiperIdx, char terminal)
 
bool is_writing_ ()
 
bool is_eeprom_ready_for_writing_ (bool wait_if_not_ready)
 
void write_wiper_level_ (uint8_t wiper, uint16_t value)
 
bool mcp4461_write_ (uint8_t addr, uint16_t data, bool nonvolatile=false)
 
uint8_t calc_terminal_connector_byte_ (Mcp4461TerminalIdx terminal_connector)
 
void update_terminal_register_ (Mcp4461TerminalIdx terminal_connector)
 
uint8_t get_terminal_register_ (Mcp4461TerminalIdx terminal_connector)
 
bool set_terminal_register_ (Mcp4461TerminalIdx terminal_connector, uint8_t data)
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_setup ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Static Protected Member Functions

static const LogString * get_message_string (int status)
 

Protected Attributes

enum esphome::mcp4461::Mcp4461Component::ErrorCode MCP4461_STATUS_OK
 
WiperState reg_ [8]
 
bool last_eeprom_write_timed_out_ {false}
 
bool write_protected_ {false}
 
bool wiper_0_disabled_ {false}
 
bool wiper_1_disabled_ {false}
 
bool wiper_2_disabled_ {false}
 
bool wiper_3_disabled_ {false}
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ {nullptr}
 
std::string error_message_ {}
 
- Protected Attributes inherited from esphome::i2c::I2CDevice
uint8_t address_ {0x00}
 store the address of the device on the bus More...
 
I2CBusbus_ {nullptr}
 pointer to I2CBus instance More...
 

Detailed Description

Definition at line 61 of file mcp4461.h.

Member Enumeration Documentation

◆ ErrorCode

Enumerator
MCP4461_STATUS_OK 
MCP4461_FAILED 
MCP4461_STATUS_I2C_ERROR 
MCP4461_STATUS_REGISTER_INVALID 
MCP4461_STATUS_REGISTER_ERROR 
MCP4461_PROHIBITED_FOR_NONVOLATILE 
MCP4461_VALUE_INVALID 
MCP4461_WRITE_PROTECTED 
MCP4461_WIPER_ENABLED 
MCP4461_WIPER_DISABLED 
MCP4461_WIPER_LOCKED 

Definition at line 147 of file mcp4461.h.

Constructor & Destructor Documentation

◆ Mcp4461Component()

esphome::mcp4461::Mcp4461Component::Mcp4461Component ( bool  disable_wiper_0,
bool  disable_wiper_1,
bool  disable_wiper_2,
bool  disable_wiper_3 
)
inline

Definition at line 63 of file mcp4461.h.

Member Function Documentation

◆ calc_terminal_connector_byte_()

uint8_t esphome::mcp4461::Mcp4461Component::calc_terminal_connector_byte_ ( Mcp4461TerminalIdx  terminal_connector)
protected

Definition at line 373 of file mcp4461.cpp.

◆ decrease_wiper_()

bool esphome::mcp4461::Mcp4461Component::decrease_wiper_ ( Mcp4461WiperIdx  wiper)
protected

Definition at line 342 of file mcp4461.cpp.

◆ disable_terminal_()

void esphome::mcp4461::Mcp4461Component::disable_terminal_ ( Mcp4461WiperIdx  wiper,
char  terminal 
)
protected

Definition at line 482 of file mcp4461.cpp.

◆ disable_wiper_()

void esphome::mcp4461::Mcp4461Component::disable_wiper_ ( Mcp4461WiperIdx  wiper)
protected

Definition at line 289 of file mcp4461.cpp.

◆ dump_config()

void esphome::mcp4461::Mcp4461Component::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 69 of file mcp4461.cpp.

◆ enable_terminal_()

void esphome::mcp4461::Mcp4461Component::enable_terminal_ ( Mcp4461WiperIdx  wiper,
char  terminal 
)
protected

Definition at line 455 of file mcp4461.cpp.

◆ enable_wiper_()

void esphome::mcp4461::Mcp4461Component::enable_wiper_ ( Mcp4461WiperIdx  wiper)
protected

Definition at line 267 of file mcp4461.cpp.

◆ get_eeprom_value()

uint16_t esphome::mcp4461::Mcp4461Component::get_eeprom_value ( Mcp4461EepromLocation  location)

get eeprom value from location

Parameters
[in]location- eeprom location 0-4
Returns
eeprom value of specified location (9 bits max)

Definition at line 509 of file mcp4461.cpp.

◆ get_message_string()

static const LogString* esphome::mcp4461::Mcp4461Component::get_message_string ( int  status)
inlinestaticprotected

Definition at line 122 of file mcp4461.h.

◆ get_setup_priority()

float esphome::mcp4461::Mcp4461Component::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 76 of file mcp4461.h.

◆ get_status_register_()

uint8_t esphome::mcp4461::Mcp4461Component::get_status_register_ ( )
protected

Definition at line 118 of file mcp4461.cpp.

◆ get_terminal_register_()

uint8_t esphome::mcp4461::Mcp4461Component::get_terminal_register_ ( Mcp4461TerminalIdx  terminal_connector)
protected

Definition at line 387 of file mcp4461.cpp.

◆ get_wiper_address_()

uint8_t esphome::mcp4461::Mcp4461Component::get_wiper_address_ ( uint8_t  wiper)
protected

Definition at line 153 of file mcp4461.cpp.

◆ get_wiper_level_()

uint16_t esphome::mcp4461::Mcp4461Component::get_wiper_level_ ( Mcp4461WiperIdx  wiper)
protected

Definition at line 183 of file mcp4461.cpp.

◆ increase_wiper_()

bool esphome::mcp4461::Mcp4461Component::increase_wiper_ ( Mcp4461WiperIdx  wiper)
protected

Definition at line 311 of file mcp4461.cpp.

◆ initialize_terminal_disabled()

void esphome::mcp4461::Mcp4461Component::initialize_terminal_disabled ( Mcp4461WiperIdx  wiper,
char  terminal 
)

public function used to set disable terminal config

Parameters
[in]wiper- the wiper to set the value for
[in]terminal- the terminal to disable, one of ['a','b','w','h']

Definition at line 45 of file mcp4461.cpp.

◆ is_eeprom_ready_for_writing_()

bool esphome::mcp4461::Mcp4461Component::is_eeprom_ready_for_writing_ ( bool  wait_if_not_ready)
protected

Definition at line 565 of file mcp4461.cpp.

◆ is_writing_()

bool esphome::mcp4461::Mcp4461Component::is_writing_ ( )
protected

Definition at line 552 of file mcp4461.cpp.

◆ loop()

void esphome::mcp4461::Mcp4461Component::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 90 of file mcp4461.cpp.

◆ mcp4461_write_()

bool esphome::mcp4461::Mcp4461Component::mcp4461_write_ ( uint8_t  addr,
uint16_t  data,
bool  nonvolatile = false 
)
protected

Definition at line 600 of file mcp4461.cpp.

◆ read_status_register_to_log()

void esphome::mcp4461::Mcp4461Component::read_status_register_to_log ( )

read status register to log

Definition at line 144 of file mcp4461.cpp.

◆ read_wiper_level_()

uint16_t esphome::mcp4461::Mcp4461Component::read_wiper_level_ ( uint8_t  wiper)
protected

Definition at line 200 of file mcp4461.cpp.

◆ set_eeprom_value()

bool esphome::mcp4461::Mcp4461Component::set_eeprom_value ( Mcp4461EepromLocation  location,
uint16_t  value 
)

set eeprom value at specified location

Parameters
[in]location- eeprom location 0-4
[in]value- 9 bits value to store

Definition at line 530 of file mcp4461.cpp.

◆ set_initial_value()

void esphome::mcp4461::Mcp4461Component::set_initial_value ( Mcp4461WiperIdx  wiper,
float  initial_value 
)

public function used to set initial value

Parameters
[in]wiper- the wiper to set the value for
[in]initial_value- the initial value in range 0-1.0 as float

Definition at line 40 of file mcp4461.cpp.

◆ set_terminal_register_()

bool esphome::mcp4461::Mcp4461Component::set_terminal_register_ ( Mcp4461TerminalIdx  terminal_connector,
uint8_t  data 
)
protected

Definition at line 433 of file mcp4461.cpp.

◆ set_wiper_level_()

bool esphome::mcp4461::Mcp4461Component::set_wiper_level_ ( Mcp4461WiperIdx  wiper,
uint16_t  value 
)
protected

Definition at line 234 of file mcp4461.cpp.

◆ setup()

void esphome::mcp4461::Mcp4461Component::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 12 of file mcp4461.cpp.

◆ update_terminal_register_()

void esphome::mcp4461::Mcp4461Component::update_terminal_register_ ( Mcp4461TerminalIdx  terminal_connector)
protected

Definition at line 406 of file mcp4461.cpp.

◆ update_wiper_level_()

bool esphome::mcp4461::Mcp4461Component::update_wiper_level_ ( Mcp4461WiperIdx  wiper)
protected

Definition at line 218 of file mcp4461.cpp.

◆ update_write_protection_status_()

void esphome::mcp4461::Mcp4461Component::update_write_protection_status_ ( )
protected

Definition at line 60 of file mcp4461.cpp.

◆ write_wiper_level_()

void esphome::mcp4461::Mcp4461Component::write_wiper_level_ ( uint8_t  wiper,
uint16_t  value 
)
protected

Definition at line 258 of file mcp4461.cpp.

Field Documentation

◆ last_eeprom_write_timed_out_

bool esphome::mcp4461::Mcp4461Component::last_eeprom_write_timed_out_ {false}
protected

Definition at line 163 of file mcp4461.h.

◆ MCP4461_STATUS_OK

enum esphome::mcp4461::Mcp4461Component::ErrorCode esphome::mcp4461::Mcp4461Component::MCP4461_STATUS_OK
protected

◆ reg_

WiperState esphome::mcp4461::Mcp4461Component::reg_[8]
protected

Definition at line 162 of file mcp4461.h.

◆ wiper_0_disabled_

bool esphome::mcp4461::Mcp4461Component::wiper_0_disabled_ {false}
protected

Definition at line 165 of file mcp4461.h.

◆ wiper_1_disabled_

bool esphome::mcp4461::Mcp4461Component::wiper_1_disabled_ {false}
protected

Definition at line 166 of file mcp4461.h.

◆ wiper_2_disabled_

bool esphome::mcp4461::Mcp4461Component::wiper_2_disabled_ {false}
protected

Definition at line 167 of file mcp4461.h.

◆ wiper_3_disabled_

bool esphome::mcp4461::Mcp4461Component::wiper_3_disabled_ {false}
protected

Definition at line 168 of file mcp4461.h.

◆ write_protected_

bool esphome::mcp4461::Mcp4461Component::write_protected_ {false}
protected

Definition at line 164 of file mcp4461.h.


The documentation for this class was generated from the following files: