From f94d5ef927f1753951b9ccc2775a52a911822496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 20 Dec 2016 16:55:58 +0100 Subject: [PATCH] Fix LED logic in hardware configuration --- code/src/config/hardware.h | 20 ++++++++++---------- code/src/led.ino | 6 +++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/code/src/config/hardware.h b/code/src/config/hardware.h index 3b164872..f14e9e77 100644 --- a/code/src/config/hardware.h +++ b/code/src/config/hardware.h @@ -26,8 +26,8 @@ #define DEVICE "LOLIN" #define BUTTON1_PIN 0 #define RELAY1_PIN 12 - #define LED1_PIN 2 - #define LED1_PIN_INVERSE 0 + #define LED1_PIN 2 + #define LED1_PIN_INVERSE 1 // ----------------------------------------------------------------------------- // Itead Studio boards @@ -40,7 +40,7 @@ #define BUTTON1_PIN 0 #define RELAY1_PIN 12 #define LED1_PIN 13 - #define LED1_PIN_INVERSE 0 + #define LED1_PIN_INVERSE 1 #elif defined(SONOFF_TH) @@ -49,7 +49,7 @@ #define BUTTON1_PIN 0 #define RELAY1_PIN 12 #define LED1_PIN 13 - #define LED1_PIN_INVERSE 0 + #define LED1_PIN_INVERSE 1 #elif defined(SONOFF_TOUCH) @@ -67,7 +67,7 @@ #define BUTTON1_PIN 0 #define RELAY1_PIN 12 #define LED1_PIN 15 - #define LED1_PIN_INVERSE 1 + #define LED1_PIN_INVERSE 0 #define ENABLE_POW 1 #elif defined(SONOFF_DUAL) @@ -76,7 +76,7 @@ #define DEVICE "SONOFF_DUAL" #define BUTTON1_PIN 0 #define LED1_PIN 13 - #define LED1_PIN_INVERSE 0 + #define LED1_PIN_INVERSE 1 #undef SERIAL_BAUDRATE #define SERIAL_BAUDRATE 19230 @@ -111,7 +111,7 @@ #define BUTTON1_PIN 0 #define RELAY1_PIN 12 #define LED1_PIN 13 - #define LED1_PIN_INVERSE 0 + #define LED1_PIN_INVERSE 1 #elif defined(S20) @@ -120,7 +120,7 @@ #define BUTTON1_PIN 0 #define RELAY1_PIN 12 #define LED1_PIN 13 - #define LED1_PIN_INVERSE 0 + #define LED1_PIN_INVERSE 1 // ----------------------------------------------------------------------------- // Electrodragon boards @@ -135,7 +135,7 @@ #define RELAY1_PIN 12 #define RELAY2_PIN 13 #define LED1_PIN 16 - #define LED1_PIN_INVERSE 1 + #define LED1_PIN_INVERSE 0 // ----------------------------------------------------------------------------- // WorkChoice ecoPlug @@ -148,7 +148,7 @@ #define BUTTON1_PIN 13 #define RELAY_PIN 15 #define LED1_PIN 2 - #define LED1_PIN_INVERSE 1 + #define LED1_PIN_INVERSE 0 // ----------------------------------------------------------------------------- // ESPurna board (still beta) diff --git a/code/src/led.ino b/code/src/led.ino index f973e2d4..14af752e 100644 --- a/code/src/led.ino +++ b/code/src/led.ino @@ -70,7 +70,7 @@ void ledMQTTCallback(unsigned int type, const char * topic, const char * payload // Get led ID unsigned int ledID = topic[strlen(topic)-1] - '0'; - if (ledID >= relayCount()) ledID = 0; + if (ledID >= ledCount()) ledID = 0; // get value unsigned int value = (char)payload[0] - '0'; @@ -95,6 +95,10 @@ void ledMQTTCallback(unsigned int type, const char * topic, const char * payload } +unsigned char ledCount() { + return _leds.size(); +} + void ledConfigure() { ledAuto = getSetting("ledAuto", String() + LED_AUTO).toInt() == 1; }