diff --git a/alertled.cpp b/alertled.cpp index 930aebc..c7cf904 100644 --- a/alertled.cpp +++ b/alertled.cpp @@ -26,8 +26,8 @@ void AlertLED::init(EventManager* eventManager) { pinMode(CFG_LED_ALERT1, OUTPUT); pinMode(CFG_LED_ALERT2, OUTPUT); pinMode(CFG_BEEPER, OUTPUT); - digitalWrite(CFG_LED_ALERT1, 1); - digitalWrite(CFG_LED_ALERT2, 1); + digitalWrite(CFG_LED_ALERT1, 1 - INVERTED); + digitalWrite(CFG_LED_ALERT2, 1 - INVERTED); digitalWrite(CFG_BEEPER, 1); alertStatus = ALERT_NONE; diff --git a/alertled.h b/alertled.h index 3448752..5d3bddc 100644 --- a/alertled.h +++ b/alertled.h @@ -39,8 +39,8 @@ class AlertLED { if (alertStatus == ALERT_NONE) { if (!animPtr) return; animPtr = 0; - analogWrite(CFG_LED_ALERT1, 1023); - analogWrite(CFG_LED_ALERT2, 1023); + analogWrite(CFG_LED_ALERT1, INVERTED ? 0 : 1023); + analogWrite(CFG_LED_ALERT2, INVERTED ? 0 : 1023); analogWrite(CFG_BEEPER, 1023); return; } @@ -48,8 +48,13 @@ class AlertLED { if (animPtr >= sizeof(anim_warning[alertStatus])/sizeof(ALED_CFG)) animPtr = 0; memcpy_P(&anim, &anim_warning[alertStatus][animPtr], sizeof(ALED_CFG)); - analogWrite(CFG_LED_ALERT1, (anim.lft - 1023) * mult + 1023); - analogWrite(CFG_LED_ALERT2, (anim.rgt - 1023) * mult + 1023); + if (INVERTED) { + analogWrite(CFG_LED_ALERT1, (1024 -anim.lft) * mult); + analogWrite(CFG_LED_ALERT2, (1024 - anim.rgt) * mult); + } else { + analogWrite(CFG_LED_ALERT1, (anim.lft - 1023) * mult + 1023); + analogWrite(CFG_LED_ALERT2, (anim.rgt - 1023) * mult + 1023); + } analogWrite(CFG_BEEPER, anim.beeper); animPtr++; diff --git a/config.h b/config.h index 88beeee..9750963 100644 --- a/config.h +++ b/config.h @@ -8,6 +8,8 @@ // Software version #define FW_VERSION "1.4" +#define INVERTED 1 + // Enable / disabled modules #define ENABLE_STATUSLED 1 #define ENABLE_ALERTLED 1 diff --git a/statusled.cpp b/statusled.cpp index a3203e5..f3896d7 100644 --- a/statusled.cpp +++ b/statusled.cpp @@ -37,13 +37,19 @@ void StatusLED::setStatus(byte state) { void StatusLED::tick() { if (!gpsStatus) { // Display sweep animation whene there is no reception - analogWrite(CFG_LED_STATUS, animPulse[pos]); + analogWrite(CFG_LED_STATUS, INVERTED ? 1023 - animPulse[pos] : animPulse[pos]); pos++; if (pos >= sizeof(animPulse) / 2) pos = 0; } else { // Short pings when reception acquired - if (pos == 0) analogWrite(CFG_LED_STATUS, GPS::isNight() ? 900 : 1); - else analogWrite(CFG_LED_STATUS, 1023); + if (pos == 0) { + if (GPS::isNight()) { + analogWrite(CFG_LED_STATUS, INVERTED ? 123 : 900); + } else { + analogWrite(CFG_LED_STATUS, INVERTED ? 1023 : 1); + } + } + else analogWrite(CFG_LED_STATUS, INVERTED ? 0 : 1023); if (++pos >= 150) pos = 0; } }