8static const uint8_t IO_EXTENSION_DIRECTION = 0x02;
9static const uint8_t IO_EXTENSION_IO_OUTPUT_ADDR = 0x03;
10static const uint8_t IO_EXTENSION_IO_INPUT_ADDR = 0x04;
11static const uint8_t IO_EXTENSION_PWM_ADDR = 0x05;
12static const uint8_t IO_EXTENSION_ADC_ADDR = 0x06;
13static const uint8_t IO_EXTENSION_RTC_INT_ADDR = 0x07;
24 if (!step1 || !step2) {
25 this->
mark_failed(LOG_STR(
"Failed to initialize Waveshare IO expander"));
48 ESP_LOGCONFIG(TAG,
"WaveshareIO:");
58 LOG_STR(
"Failed to read ADC register")))
69 LOG_STR(
"Failed to read RTC interrupt register")))
84 auto pwm_value =
static_cast<uint8_t
>(
state * 255.0f);
85 uint8_t final_pwm_value = std::clamp(pwm_value, min_value, max_value);
86 if (final_pwm_value != pwm_value) {
87 ESP_LOGVV(TAG,
"Clamping PWM value %u to safe range [%u, %u]", pwm_value, min_value, max_value);
96 LOG_STR(
"Failed to write mode register"));
103 LOG_STR(
"Failed to write output register"));
112 LOG_STR(
"Failed to read input register")))
126 LOG_STR(
"Failed to write output register"));
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
bool read_byte_16_le(uint8_t a_register, uint16_t *data)
Read a 16-bit value stored least significant byte first.
void pin_mode(uint8_t pin, gpio::Flags flags)
void set_pwm_value(uint8_t value)
bool digital_read_cache(uint8_t pin) override
void write_pwm_level(float state, uint8_t min_value, uint8_t max_value)
Write an output level, 0.0 to 1.0, clamped to the board's safe PWM range.
void digital_write_hw(uint8_t pin, bool value) override
uint8_t get_rtc_interrupt_status()
void dump_config() override
bool write_gpio_outputs_()
float get_setup_priority() const override
bool digital_read_hw(uint8_t pin) override
constexpr float IO
For components that represent GPIO pins like PCF8573.
ESPHOME_LOG_TAG(TAG, "waveshare_io_ch32v003.sensor")
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.