From 9859ee6083f160c752292d60b8796b067deab050 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Sun, 13 Oct 2019 17:54:06 +0200 Subject: [PATCH] Fix some errors... 1. reset loop i=1 if address switches to range PCF8574_ADDR2 (PCF8574A were NOT detected) 2. correct logoutput to show correct number of boards found 3. String array to short for PCF8574A. Overwrite the pfc8574.type with false. Hard to find bug..... Tested with at least 2 PCF8574 boards. --- sonoff/xdrv_28_pcf8574.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sonoff/xdrv_28_pcf8574.ino b/sonoff/xdrv_28_pcf8574.ino index 6b651a296..ab63ff79b 100644 --- a/sonoff/xdrv_28_pcf8574.ino +++ b/sonoff/xdrv_28_pcf8574.ino @@ -37,7 +37,7 @@ struct PCF8574 { uint8_t pin_mask[MAX_PCF8574] = { 0 }; uint8_t max_connected_ports = 0; // Max numbers of devices comming from PCF8574 modules uint8_t max_devices = 0; // Max numbers of PCF8574 modules - char stype[8]; + char stype[9]; bool type = true; } Pcf8574; @@ -95,6 +95,7 @@ void Pcf8574Init() pcf8574_address++; if ((PCF8574_ADDR1 + 8) == pcf8574_address) { pcf8574_address = PCF8574_ADDR2; + i=0; } } if (Pcf8574.max_devices) { @@ -118,7 +119,7 @@ void Pcf8574Init() } } } - AddLog_P2(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), devices_present, Pcf8574.max_connected_ports); + AddLog_P2(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports); } }