7 static const uint8_t CH422G_REG_MODE = 0x24;
8 static const uint8_t CH422G_MODE_OUTPUT = 0x01;
9 static const uint8_t CH422G_MODE_OPEN_DRAIN = 0x04;
10 static const uint8_t CH422G_REG_IN = 0x26;
11 static const uint8_t CH422G_REG_OUT = 0x38;
12 static const uint8_t CH422G_REG_OUT_UPPER = 0x23;
14 static const char *
const TAG =
"ch422g";
17 ESP_LOGCONFIG(TAG,
"Setting up CH422G...");
22 ESP_LOGE(TAG,
"CH422G not detected at 0x%02X", this->
address_);
27 ESP_LOGCONFIG(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
37 ESP_LOGCONFIG(TAG,
"CH422G:");
40 ESP_LOGE(TAG,
"Communication with CH422G failed!");
95 auto err = this->
bus_->
write(reg, &value, 1);
106 auto err = this->
bus_->
read(reg, &value, 1);
135 this->parent_->pin_mode(this->pin_, flags);
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.
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
void digital_write(uint8_t pin, bool value)
Helper function to write the value of a pin.
uint16_t output_bits_
The mask to write as output state - 1 means HIGH, 0 means LOW.
bool write_reg_(uint8_t reg, uint8_t value)
uint8_t mode_value_
Copy of the mode value.
bool status_has_error() const
uint8_t pin_read_flags_
Flags to check if read previously during this loop.
No error found during execution of method.
void set_flags(gpio::Flags flags)
std::string str_sprintf(const char *fmt,...)
void status_clear_warning()
BedjetMode mode
BedJet operating mode.
bool digital_read(uint8_t pin)
Helper function to read the value of a pin.
void dump_config() override
void pin_mode(uint8_t pin, gpio::Flags flags)
Helper function to set the pin mode of a pin.
float get_setup_priority() const override
uint8_t address_
store the address of the device on the bus
I2CBus * bus_
pointer to I2CBus instance
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.
Implementation of SPI Controller mode.
bool digital_read() override
uint8_t input_bits_
Copy of last read values.
void digital_write(bool value) override
void pin_mode(gpio::Flags flags) override
uint8_t read_reg_(uint8_t reg)
bool set_mode_(uint8_t mode)