mirror of
https://github.com/esphome/esphome.git
synced 2025-09-08 22:32:21 +01:00
[sx1509] Migrate to CachedGpioExpander to reduce I2C bus usage
This commit is contained in:
@@ -77,15 +77,12 @@ void SX1509Component::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SX1509Component::digital_read_hw(uint8_t pin) {
|
bool SX1509Component::digital_read_hw(uint8_t pin) {
|
||||||
if (this->ddr_mask_ & (1 << pin)) {
|
// Always read all pins when any input pin is accessed
|
||||||
if (!this->read_byte_16(REG_DATA_B, &this->input_mask_))
|
return this->read_byte_16(REG_DATA_B, &this->input_mask_);
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SX1509Component::digital_read_cache(uint8_t pin) {
|
bool SX1509Component::digital_read_cache(uint8_t pin) {
|
||||||
|
// Return cached value for input pins, false for output pins
|
||||||
if (this->ddr_mask_ & (1 << pin)) {
|
if (this->ddr_mask_ & (1 << pin)) {
|
||||||
return this->input_mask_ & (1 << pin);
|
return this->input_mask_ & (1 << pin);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user