1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-08 14:22:21 +01:00

[sx1509] Migrate to CachedGpioExpander to reduce I2C bus usage

This commit is contained in:
J. Nick Koston
2025-09-04 14:36:27 -05:00
parent d9ded6b87e
commit 06833d6f8b

View File

@@ -77,15 +77,12 @@ void SX1509Component::loop() {
}
bool SX1509Component::digital_read_hw(uint8_t pin) {
if (this->ddr_mask_ & (1 << pin)) {
if (!this->read_byte_16(REG_DATA_B, &this->input_mask_))
return false;
return true;
}
return false;
// Always read all pins when any input pin is accessed
return this->read_byte_16(REG_DATA_B, &this->input_mask_);
}
bool SX1509Component::digital_read_cache(uint8_t pin) {
// Return cached value for input pins, false for output pins
if (this->ddr_mask_ & (1 << pin)) {
return this->input_mask_ & (1 << pin);
}