From 1551b3d1e3e22cc76cb590aa58f65a1f23a9e66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 22 Nov 2016 22:53:27 +0100 Subject: [PATCH] Option to define LED in inverse logic --- code/src/config/hardware.h | 6 ++++++ code/src/main.ino | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/code/src/config/hardware.h b/code/src/config/hardware.h index 1c0e173f..1a4ef2af 100644 --- a/code/src/config/hardware.h +++ b/code/src/config/hardware.h @@ -21,6 +21,7 @@ #define BUTTON_PIN 0 #define RELAY_PIN 12 #define LED_PIN 13 + #define LED_PIN_INVERSE 0 #elif defined(SONOFF_TH) @@ -29,6 +30,7 @@ #define BUTTON_PIN 0 #define RELAY_PIN 12 #define LED_PIN 13 + #define LED_PIN_INVERSE 0 #elif defined(SONOFF_POW) @@ -37,6 +39,7 @@ #define BUTTON_PIN 0 #define RELAY_PIN 12 #define LED_PIN 15 + #define LED_PIN_INVERSE 1 #define ENABLE_POW 1 #elif defined(SLAMPHER) @@ -46,6 +49,7 @@ #define BUTTON_PIN 0 #define RELAY_PIN 12 #define LED_PIN 13 + #define LED_PIN_INVERSE 0 #elif defined(S20) @@ -54,6 +58,7 @@ #define BUTTON_PIN 0 #define RELAY_PIN 12 #define LED_PIN 13 + #define LED_PIN_INVERSE 0 // ----------------------------------------------------------------------------- // ESPurna board (still beta) @@ -66,6 +71,7 @@ #define BUTTON_PIN 0 #define RELAY_PIN 12 #define LED_PIN 13 + #define LED_PIN_INVERSE 0 // ----------------------------------------------------------------------------- // Unknown hardware diff --git a/code/src/main.ino b/code/src/main.ino index b8b6a066..b8282859 100644 --- a/code/src/main.ino +++ b/code/src/main.ino @@ -46,7 +46,7 @@ void blink(unsigned long delayOff, unsigned long delayOn) { static bool status = HIGH; if (next < millis()) { status = !status; - digitalWrite(LED_PIN, status); + digitalWrite(LED_PIN, LED_PIN_INVERSE ? !status : status); next += ((status) ? delayOff : delayOn); } }