63 Mcp4461Component(
bool disable_wiper_0,
bool disable_wiper_1,
bool disable_wiper_2,
bool disable_wiper_3)
64 : wiper_0_disabled_(disable_wiper_0),
65 wiper_1_disabled_(disable_wiper_1),
66 wiper_2_disabled_(disable_wiper_2),
67 wiper_3_disabled_(disable_wiper_3) {
68 this->reg_[0].enabled = !wiper_0_disabled_;
69 this->reg_[1].enabled = !wiper_1_disabled_;
70 this->reg_[2].enabled = !wiper_2_disabled_;
71 this->reg_[3].enabled = !wiper_3_disabled_;
74 void setup()
override;
75 void dump_config()
override;
93 void initialize_terminal_disabled(
Mcp4461WiperIdx wiper,
char terminal);
95 void read_status_register_to_log();
99 void update_write_protection_status_();
100 uint8_t get_wiper_address_(uint8_t wiper);
101 uint16_t read_wiper_level_(uint8_t wiper);
102 uint8_t get_status_register_();
113 bool is_eeprom_ready_for_writing_(
bool wait_if_not_ready);
114 void write_wiper_level_(uint8_t wiper, uint16_t value);
115 bool mcp4461_write_(uint8_t addr, uint16_t data,
bool nonvolatile =
false);
124 case MCP4461_STATUS_I2C_ERROR:
125 return LOG_STR(
"I2C error - communication with MCP4461 failed!");
126 case MCP4461_STATUS_REGISTER_ERROR:
127 return LOG_STR(
"Status register could not be read");
128 case MCP4461_STATUS_REGISTER_INVALID:
129 return LOG_STR(
"Invalid status register value - bits 1,7 or 8 are 0");
130 case MCP4461_VALUE_INVALID:
131 return LOG_STR(
"Invalid value for wiper given");
132 case MCP4461_WRITE_PROTECTED:
133 return LOG_STR(
"MCP4461 is write protected. Setting nonvolatile wipers/eeprom values is prohibited.");
134 case MCP4461_WIPER_ENABLED:
135 return LOG_STR(
"MCP4461 Wiper is already enabled, ignoring cmd to enable.");
136 case MCP4461_WIPER_DISABLED:
137 return LOG_STR(
"MCP4461 Wiper is disabled. All actions on this wiper are prohibited.");
138 case MCP4461_WIPER_LOCKED:
139 return LOG_STR(
"MCP4461 Wiper is locked using WiperLock-technology. All actions on this wiper are prohibited.");
140 case MCP4461_STATUS_OK:
141 return LOG_STR(
"Status OK");
143 return LOG_STR(
"Unknown");
148 MCP4461_STATUS_OK = 0,
160 } error_code_{MCP4461_STATUS_OK};
163 bool last_eeprom_write_timed_out_{
false};
164 bool write_protected_{
false};
165 bool wiper_0_disabled_{
false};
166 bool wiper_1_disabled_{
false};
167 bool wiper_2_disabled_{
false};
168 bool wiper_3_disabled_{
false};
optional< float > initial_value
static const LogString * get_message_string(int status)
float get_setup_priority() const override
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Implementation of SPI Controller mode.
Mcp4461Component(bool disable_wiper_0, bool disable_wiper_1, bool disable_wiper_2, bool disable_wiper_3)
This Class provides the methods to read/write bytes from/to an i2c device.