11 auto err = this->
write(
nullptr, 0);
19 ESP_LOGCONFIG(TAG,
"MCP4728:");
25 this->update_ =
false;
26 if (this->store_in_eeprom_) {
43 auto value =
static_cast<uint16_t
>(roundf(
state * 4095));
44 ESP_LOGV(TAG,
"Setting MCP4728 channel %c to %d!",
'A' + channel,
value);
51 for (uint8_t i = 0; i < 4; ++i) {
54 wd[1] = ((uint8_t) reg_[i].
vref << 7) | ((uint8_t) reg_[i].pd << 5) | ((uint8_t) reg_[i].
gain << 4) |
56 wd[2] = reg_[i].
data & 0xFF;
57 err[i] = this->
write(wd,
sizeof(wd));
72 for (uint8_t i = 0; i < 4; i++) {
73 wd[i * 2 + 1] = ((uint8_t) reg_[i].
vref << 7) | ((uint8_t) reg_[i].pd << 5) | ((uint8_t) reg_[i].
gain << 4) |
75 wd[i * 2 + 2] = reg_[i].
data & 0xFF;
77 auto err = this->
write(wd,
sizeof(wd));
83 this->reg_[channel].
vref = vref;
84 this->reg_[channel].
pd = pd;
void mark_failed()
Mark this component as failed.
void status_clear_error()
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
void configure_channel(MCP4728ChannelIdx channel, MCP4728Vref vref, MCP4728Gain gain, MCP4728PwrDown pd)
void dump_config() override
void write_channel(uint8_t channel, float state)
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_OK
No error found during execution of method.
ESPHOME_LOG_TAG(TAG, "mcp4728")