Remove LED_INVERTED, see below for why ;-) (#4382)

While working on #4378 I noticed a funny problem: the blinking system
LED was on during deep-sleep.  Initially I thought it was some weird
sleep hw config thing but it turns out it was easier but more pervasive.

We had two different preprocessor symbols which both meant approximately the same
thing LED_INVERTED and LED_STATE_ON (though their polarity was opposite).
Some variant files were setting one, others were setting the other, and others were
setting both. heh.

In the case of the board I was testing (seeed tracker wio 1100) it was only setting one
and the default behavior for the other (for all boards) was incorrect.  So I did a grep
and it seems like LED_STATE_ON was used more often, so I kept that one and removed
LED_INVERTED everywhere.
This commit is contained in:
geeksville 2024-08-05 04:02:32 -07:00 committed by GitHub
parent 40d6b99911
commit 1a38c4e51d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 24 additions and 28 deletions

View File

@ -3,8 +3,8 @@
#include "configuration.h"
// DEBUG LED
#ifndef LED_INVERTED
#define LED_INVERTED 0 // define as 1 if LED is active low (on)
#ifndef LED_STATE_ON
#define LED_STATE_ON 1
#endif
// -----------------------------------------------------------------------------

View File

@ -583,7 +583,7 @@ void setup()
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, 1 ^ LED_INVERTED); // turn on for now
digitalWrite(LED_PIN, LED_STATE_ON); // turn on for now
#endif
// Hello
@ -728,7 +728,7 @@ void setup()
#ifdef LED_PIN
// Turn LED off after boot, if heartbeat by config
if (config.device.led_heartbeat_disabled)
digitalWrite(LED_PIN, LOW ^ LED_INVERTED);
digitalWrite(LED_PIN, HIGH ^ LED_STATE_ON);
#endif
// Do this after service.init (because that clears error_code)

View File

@ -372,7 +372,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
#ifdef LED_PIN
// Turn LED off if heartbeat by config
if (c.payload_variant.device.led_heartbeat_disabled) {
digitalWrite(LED_PIN, LOW ^ LED_INVERTED);
digitalWrite(LED_PIN, HIGH ^ LED_STATE_ON);
}
#endif
if (config.device.button_gpio == c.payload_variant.device.button_gpio &&

View File

@ -75,16 +75,16 @@
#ifdef ARDUINO_NRF52840_PCA10056
// This board uses 0 to be mean LED on
#undef LED_INVERTED
#define LED_INVERTED 1
#undef LED_STATE_ON
#define LED_STATE_ON 0 // State when LED is lit
#endif
#ifdef _SEEED_XIAO_NRF52840_SENSE_H_
// This board uses 0 to be mean LED on
#undef LED_INVERTED
#define LED_INVERTED 1
#undef LED_STATE_ON
#define LED_STATE_ON 0 // State when LED is lit
#endif
@ -116,4 +116,4 @@
#if !defined(PIN_SERIAL_RX) && !defined(NRF52840_XXAA)
// No serial ports on this board - ONLY use segger in memory console
#define USE_SEGGER
#endif
#endif

View File

@ -90,7 +90,7 @@ void setLed(bool ledOn)
#ifdef LED_PIN
// toggle the led so we can get some rough sense of how often loop is pausing
digitalWrite(LED_PIN, ledOn ^ LED_INVERTED);
digitalWrite(LED_PIN, ledOn ^ LED_STATE_ON ^ HIGH);
#endif
#ifdef HAS_PMU
@ -519,4 +519,4 @@ void enableLoraInterrupt()
}
#endif
}
#endif
#endif

View File

@ -101,7 +101,7 @@
// Status
#define LED_PIN 1
#define LED_INVERTED 0
#define LED_STATE_ON 1 // State when LED is lit
// External notification
// FIXME: Check if EXT_NOTIFY_OUT actualy has any effect and removes the need for setting the external notication pin in the
// app/preferences

View File

@ -56,7 +56,6 @@ extern "C" {
#define LED_CONN PIN_LED3
#define LED_STATE_ON 0 // State when LED is lit
#define LED_INVERTED 1
/*
* Buttons

View File

@ -3,8 +3,8 @@
// LED pin on HT-DEV-ESP_V2 and HT-DEV-ESP_V3
// https://resource.heltec.cn/download/HT-CT62/HT-CT62_Reference_Design.pdf
// https://resource.heltec.cn/download/HT-DEV-ESP/HT-DEV-ESP_V3_Sch.pdf
#define LED_PIN 2 // LED
#define LED_INVERTED 0
#define LED_PIN 2 // LED
#define LED_STATE_ON 1 // State when LED is lit
#define HAS_SCREEN 0
#define HAS_GPS 0
@ -26,4 +26,4 @@
#define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define SX126X_DIO3_TCXO_VOLTAGE 1.8

View File

@ -80,7 +80,6 @@ extern "C" {
#define LED_CONN PIN_GREEN
#define LED_STATE_ON 0 // State when LED is lit
#define LED_INVERTED 1
/*
* Buttons

View File

@ -10,7 +10,7 @@
// #define GPS_TX_PIN 32 (now used by SX1262 BUSY as GPS works with just RX)
// Green LED
#define LED_INVERTED 0
#define LED_STATE_ON 1 // State when LED is lit
#define LED_PIN 10
#include "pcf8563.h"
@ -106,4 +106,4 @@
// GND
// https://github.com/m5stack/M5Core-Ink/blob/master/examples/Basics/FactoryTest/FactoryTest.ino#L58
#define ADC_MULTIPLIER 5
// https://embeddedexplorer.com/esp32-adc-esp-idf-tutorial/
// https://embeddedexplorer.com/esp32-adc-esp-idf-tutorial/

View File

@ -54,7 +54,6 @@ extern "C" {
#define LED_CONN PIN_GREEN
#define LED_STATE_ON 0 // State when LED is lit
// #define LED_INVERTED 1
/*
* Buttons

View File

@ -56,7 +56,6 @@ extern "C" {
#define LED_CONN PIN_GREEN
#define LED_STATE_ON 0 // State when LED is lit
#define LED_INVERTED 1
/*
* Buttons

View File

@ -11,7 +11,7 @@
// anywhere.
// #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
#define LED_INVERTED 1
#define LED_STATE_ON 0 // State when LED is lit
// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
// not found then probe for SX1262
@ -66,4 +66,4 @@
// has 32768 Hz crystal
#define HAS_32768HZ
#define USE_SH1106
#define USE_SH1106

View File

@ -8,8 +8,8 @@
// anywhere.
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
#define LED_INVERTED 1
#define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4
#define LED_STATE_ON 0 // State when LED is lit
#define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4
// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
// not found then probe for SX1262

View File

@ -51,8 +51,8 @@
// #define HAS_SDCARD 1 // causes hang if defined
#define SDCARD_CS 43
#define LED_PIN 13 // the red part of the RGB LED
#define LED_INVERTED 1
#define LED_PIN 13 // the red part of the RGB LED
#define LED_STATE_ON 0 // State when LED is lit
#define BUTTON_PIN 21 // Button 3 - square - top button in landscape mode
#define BUTTON_NEED_PULLUP // we do need a helping hand up