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;