mirror of
https://github.com/esphome/esphome.git
synced 2026-10-02 17:30:22 +00:00
[mcp23xxx][pi4ioe5v6408] Add optional interrupt pin to eliminate polling
Extend interrupt_pin support to MCP23008, MCP23017, MCP23S08, MCP23S17, and PI4IOE5V6408 GPIO expander components. Same approach as PCF8574/PCA9554: when configured, the component disables its loop and only wakes on interrupt, and the cache stays valid between interrupts so binary sensors return from cache instead of doing I2C/SPI reads every loop iteration. For MCP23xxx, the interrupt_pin config and C++ logic lives in the shared MCP23XXXBase template class, so all four variants (I2C 8/16-pin, SPI 8/16-pin) inherit it automatically. Inspired by jesserockz's work in #11959 which proposed a more comprehensive interrupt-driven approach with per-pin interrupt status register reading. This implementation takes a simpler path by leveraging the existing CachedGpioExpander cache invalidation mechanism.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
mcp23008:
|
||||
i2c_id: i2c_bus
|
||||
id: mcp23008_hub
|
||||
- i2c_id: i2c_bus
|
||||
id: mcp23008_hub
|
||||
- i2c_id: i2c_bus
|
||||
id: mcp23008_hub_int
|
||||
address: 0x21
|
||||
interrupt_pin: ${interrupt_pin}
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
substitutions:
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/esp32-idf.yaml
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
substitutions:
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/esp8266-ard.yaml
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
substitutions:
|
||||
interrupt_pin: GPIO2
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/rp2040-ard.yaml
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
mcp23017:
|
||||
i2c_id: i2c_bus
|
||||
id: mcp23017_hub
|
||||
- i2c_id: i2c_bus
|
||||
id: mcp23017_hub
|
||||
- i2c_id: i2c_bus
|
||||
id: mcp23017_hub_int
|
||||
address: 0x21
|
||||
interrupt_pin: ${interrupt_pin}
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
substitutions:
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/esp32-idf.yaml
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
substitutions:
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/esp8266-ard.yaml
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
substitutions:
|
||||
interrupt_pin: GPIO2
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/rp2040-ard.yaml
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ mcp23s08:
|
||||
- id: mcp23s08_hub
|
||||
cs_pin: ${cs_pin}
|
||||
deviceaddress: 0
|
||||
interrupt_pin: ${interrupt_pin}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
substitutions:
|
||||
cs_pin: GPIO5
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
spi: !include ../../test_build_components/common/spi/esp32-idf.yaml
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
substitutions:
|
||||
cs_pin: GPIO15
|
||||
interrupt_pin: GPIO13
|
||||
|
||||
packages:
|
||||
spi: !include ../../test_build_components/common/spi/esp8266-ard.yaml
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
substitutions:
|
||||
cs_pin: GPIO5
|
||||
interrupt_pin: GPIO2
|
||||
|
||||
packages:
|
||||
spi: !include ../../test_build_components/common/spi/rp2040-ard.yaml
|
||||
|
||||
@@ -2,3 +2,4 @@ mcp23s17:
|
||||
- id: mcp23s17_hub
|
||||
cs_pin: ${cs_pin}
|
||||
deviceaddress: 0
|
||||
interrupt_pin: ${interrupt_pin}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
substitutions:
|
||||
cs_pin: GPIO5
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
spi: !include ../../test_build_components/common/spi/esp32-idf.yaml
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
substitutions:
|
||||
cs_pin: GPIO15
|
||||
interrupt_pin: GPIO13
|
||||
|
||||
packages:
|
||||
spi: !include ../../test_build_components/common/spi/esp8266-ard.yaml
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
substitutions:
|
||||
cs_pin: GPIO5
|
||||
interrupt_pin: GPIO2
|
||||
|
||||
packages:
|
||||
spi: !include ../../test_build_components/common/spi/rp2040-ard.yaml
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
pi4ioe5v6408:
|
||||
i2c_id: i2c_bus
|
||||
id: pi4ioe1
|
||||
address: 0x44
|
||||
- i2c_id: i2c_bus
|
||||
id: pi4ioe1
|
||||
address: 0x44
|
||||
- i2c_id: i2c_bus
|
||||
id: pi4ioe1_int
|
||||
address: 0x45
|
||||
interrupt_pin: ${interrupt_pin}
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
substitutions:
|
||||
i2c_sda: GPIO21
|
||||
i2c_scl: GPIO22
|
||||
interrupt_pin: GPIO15
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/esp32-idf.yaml
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
substitutions:
|
||||
i2c_sda: GPIO4
|
||||
i2c_scl: GPIO5
|
||||
interrupt_pin: GPIO2
|
||||
|
||||
packages:
|
||||
i2c: !include ../../test_build_components/common/i2c/rp2040-ard.yaml
|
||||
|
||||
Reference in New Issue
Block a user