From f3bf8998ae1f16316ba421a1d93b4091863a8b1d Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 17 Nov 2024 18:02:23 +0100 Subject: [PATCH] Fax MCP23xxx and PCF8574 last device --- tasmota/tasmota_xdrv_driver/xdrv_28_pcf8574_v2.ino | 8 ++++---- tasmota/tasmota_xdrv_driver/xdrv_67_mcp23xxx.ino | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_28_pcf8574_v2.ino b/tasmota/tasmota_xdrv_driver/xdrv_28_pcf8574_v2.ino index 7c56f460c..53e01ddb4 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_28_pcf8574_v2.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_28_pcf8574_v2.ino @@ -190,11 +190,11 @@ int Pcf8574Pin(uint32_t gpio, uint32_t index = 0); int Pcf8574Pin(uint32_t gpio, uint32_t index) { uint16_t real_gpio = gpio << 5; uint16_t mask = 0xFFE0; - if (index < GPIO_ANY) { +// if (index < GPIO_ANY) { real_gpio += index; mask = 0xFFFF; - } - for (uint32_t i = 0; i < Pcf8574.max_connected_ports; i++) { +// } + for (uint32_t i = 0; i <= Pcf8574.max_connected_ports; i++) { if ((Pcf8574_pin[i] & mask) == real_gpio) { return i; // Pin number configured for gpio } @@ -208,7 +208,7 @@ bool Pcf8574PinUsed(uint32_t gpio, uint32_t index) { } uint32_t Pcf8574GetPin(uint32_t lpin) { - if (lpin < Pcf8574.max_connected_ports) { + if (lpin <= Pcf8574.max_connected_ports) { return Pcf8574_pin[lpin]; } else { return GPIO_NONE; diff --git a/tasmota/tasmota_xdrv_driver/xdrv_67_mcp23xxx.ino b/tasmota/tasmota_xdrv_driver/xdrv_67_mcp23xxx.ino index 3182362ad..c867692fd 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_67_mcp23xxx.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_67_mcp23xxx.ino @@ -430,11 +430,11 @@ int MCP23xPin(uint32_t gpio, uint32_t index = 0); int MCP23xPin(uint32_t gpio, uint32_t index) { uint16_t real_gpio = gpio << 5; uint16_t mask = 0xFFE0; - if (index < GPIO_ANY) { +// if (index < GPIO_ANY) { real_gpio += index; mask = 0xFFFF; - } - for (uint32_t i = 0; i < Mcp23x.max_pins; i++) { +// } + for (uint32_t i = 0; i <= Mcp23x.max_pins; i++) { if ((Mcp23x_gpio_pin[i] & mask) == real_gpio) { return i; // Pin number configured for gpio } @@ -448,7 +448,7 @@ bool MCP23xPinUsed(uint32_t gpio, uint32_t index) { } uint32_t MCP23xGetPin(uint32_t lpin) { - if (lpin < Mcp23x.max_pins) { + if (lpin <= Mcp23x.max_pins) { return Mcp23x_gpio_pin[lpin]; } else { return GPIO_NONE;