11 static const char *
const TAG =
"ch422g";
14 ESP_LOGCONFIG(TAG,
"Setting up CH422G...");
17 ESP_LOGE(TAG,
"CH422G not detected at 0x%02X", this->
address_);
27 ESP_LOGD(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
37 ESP_LOGCONFIG(TAG,
"CH422G:");
40 ESP_LOGE(TAG,
"Communication with CH422G failed!");
89 const uint8_t temp = 1;
95 uint8_t write_mask = value;
98 str_sprintf(
"write_output_(): I2C I/O error: %d for write_mask: %d", (
int) this->
last_error_, (
int) write_mask)
float get_loop_priority() const override
std::string dump_summary() const override
void setup() override
Check i2c availability and setup masks.
void status_set_warning(const char *message="unspecified")
bool status_has_warning() const
void loop() override
Poll for input changes periodically.
void digital_write(uint8_t pin, bool value)
Helper function to write the value of a pin.
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
bool status_has_error() const
uint8_t pin_read_cache_
Flags to check if read previously during this loop.
No error found during execution of method.
std::string str_sprintf(const char *fmt,...)
const uint8_t OUT_REG_DEFAULT_VAL
void status_clear_warning()
uint8_t state_mask_
The mask to write as output state - 1 means HIGH, 0 means LOW.
bool digital_read(uint8_t pin)
Helper function to read the value of a pin.
bool write_output_(uint8_t value)
void dump_config() override
void pin_mode(uint8_t pin, gpio::Flags flags)
Helper function to set the pin mode of a pin.
esphome::i2c::ErrorCode last_error_
Storage for last I2C error seen.
float get_setup_priority() const override
uint8_t address_
store the address of the device on the bus
const uint8_t CH422G_REG_IN
I2CBus * bus_
pointer to I2CBus instance
const uint8_t CH422G_REG_OUT
virtual ErrorCode read(uint8_t address, uint8_t *buffer, size_t len)
Creates a ReadBuffer and calls the virtual readv() method to read bytes into this buffer...
virtual ErrorCode write(uint8_t address, const uint8_t *buffer, size_t len)
virtual void mark_failed()
Mark this component as failed.
const float IO
For components that represent GPIO pins like PCF8573.
bool restore_value_
Whether we want to override stored values on expander.
Implementation of SPI Controller mode.
bool digital_read() override
void digital_write(bool value) override
void pin_mode(gpio::Flags flags) override