7static const uint8_t CH422G_REG_MODE = 0x24;
8static const uint8_t CH422G_MODE_OUTPUT = 0x01;
9static const uint8_t CH422G_MODE_OPEN_DRAIN = 0x04;
10static const uint8_t CH422G_REG_IN = 0x26;
11static const uint8_t CH422G_REG_OUT = 0x38;
12static const uint8_t CH422G_REG_OUT_UPPER = 0x23;
21 ESP_LOGE(TAG,
"CH422G not detected at 0x%02X", this->
address_);
26 ESP_LOGCONFIG(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
36 ESP_LOGCONFIG(TAG,
"CH422G:");
90 snprintf(buf,
sizeof(buf),
"write failed for register 0x%X, error %d",
reg, err);
103 snprintf(buf,
sizeof(buf),
"read failed for register 0x%X, error %d",
reg, err);
BedjetMode mode
BedJet operating mode.
void mark_failed()
Mark this component as failed.
void status_set_warning()
bool status_has_warning() const
bool status_has_error() const
void status_clear_warning()
void dump_config() override
uint16_t output_bits_
The mask to write as output state - 1 means HIGH, 0 means LOW.
void setup() override
Check i2c availability and setup masks.
float get_setup_priority() const override
bool set_mode_(uint8_t mode)
void pin_mode(uint8_t pin, gpio::Flags flags)
Helper function to set the pin mode of a pin.
uint8_t pin_read_flags_
Flags to check if read previously during this loop.
void loop() override
Poll for input changes periodically.
uint8_t read_reg_(uint8_t reg)
uint8_t mode_value_
Copy of the mode value.
bool write_reg_(uint8_t reg, uint8_t value)
uint8_t input_bits_
Copy of last read values.
bool digital_read(uint8_t pin)
Helper function to read the value of a pin.
void digital_write(uint8_t pin, bool value)
Helper function to write the value of a pin.
virtual ErrorCode write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count)=0
This virtual method writes bytes to an I2CBus from an array, then reads bytes into an array of ReadBu...
I2CBus * bus_
pointer to I2CBus instance
uint8_t address_
store the address of the device on the bus
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
ESPHOME_LOG_TAG(TAG, "ch422g")
@ ERROR_OK
No error found during execution of method.
constexpr float IO
For components that represent GPIO pins like PCF8573.
ESPHOME_ALWAYS_INLINE constexpr void assign_bits(T &value, std::type_identity_t< T > mask, bool on)
Set the bits of mask in value when on is true, clear them otherwise.