More variant.h cleanup. LED_NOTIFICATION, remove dead code, etc (#9477)

This commit is contained in:
Jonathan Bennett
2026-01-29 12:51:48 -06:00
committed by GitHub
parent 45fbc0f9d3
commit dbded86dcb
59 changed files with 82 additions and 153 deletions

View File

@@ -816,6 +816,9 @@ void Power::shutdown()
#endif
#ifdef PIN_LED3
ledOff(PIN_LED3);
#endif
#ifdef LED_NOTIFICATION
ledOff(LED_NOTIFICATION);
#endif
doDeepSleep(DELAY_FOREVER, true, true);
#elif defined(ARCH_PORTDUINO)

View File

@@ -428,12 +428,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define HAS_RGB_LED
#endif
#ifndef LED_STATE_OFF
#define LED_STATE_OFF 0
#endif
#ifndef LED_STATE_ON
#define LED_STATE_ON 1
#endif
#ifndef LED_STATE_OFF
#define LED_STATE_OFF (LED_STATE_ON ^ 1)
#endif
// default mapping of pins
#if defined(PIN_BUTTON2) && !defined(CANCEL_BUTTON_PIN)

View File

@@ -354,9 +354,9 @@ void setup()
digitalWrite(LED_POWER, LED_STATE_ON);
#endif
#ifdef USER_LED
pinMode(USER_LED, OUTPUT);
digitalWrite(USER_LED, HIGH ^ LED_STATE_ON);
#ifdef LED_NOTIFICATION
pinMode(LED_NOTIFICATION, OUTPUT);
digitalWrite(LED_NOTIFICATION, HIGH ^ LED_STATE_ON);
#endif
#ifdef WIFI_LED

View File

@@ -824,16 +824,10 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.external_notification.output_ms = 500;
moduleConfig.external_notification.nag_timeout = 2;
#endif
#if defined(RAK4630) || defined(RAK11310) || defined(RAK3312) || defined(MUZI_BASE) || defined(ELECROW_ThinkNode_M3) || \
defined(ELECROW_ThinkNode_M4) || defined(ELECROW_ThinkNode_M6)
// Default to PIN_LED2 for external notification output (LED color depends on device variant)
#if defined(LED_NOTIFICATION)
moduleConfig.external_notification.enabled = true;
moduleConfig.external_notification.output = PIN_LED2;
#if defined(MUZI_BASE) || defined(ELECROW_ThinkNode_M3)
moduleConfig.external_notification.active = false;
#else
moduleConfig.external_notification.active = true;
#endif
moduleConfig.external_notification.output = LED_NOTIFICATION;
moduleConfig.external_notification.active = LED_STATE_ON;
moduleConfig.external_notification.alert_message = true;
moduleConfig.external_notification.output_ms = 1000;
moduleConfig.external_notification.nag_timeout = default_ringtone_nag_secs;
@@ -857,15 +851,6 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.external_notification.output_ms = 100;
moduleConfig.external_notification.active = true;
#endif
#ifdef ELECROW_ThinkNode_M1
// Default to Elecrow USER_LED (blue)
moduleConfig.external_notification.enabled = true;
moduleConfig.external_notification.output = USER_LED;
moduleConfig.external_notification.active = true;
moduleConfig.external_notification.alert_message = true;
moduleConfig.external_notification.output_ms = 1000;
moduleConfig.external_notification.nag_timeout = 60;
#endif
#ifdef T_LORA_PAGER
moduleConfig.canned_message.updown1_enabled = true;
moduleConfig.canned_message.inputbroker_pin_a = ROTARY_A;

View File

@@ -10,3 +10,6 @@ build_flags =
-D EBYTE_E22
-D EBYTE_E22_900M30S ; Assume Tx power curve is identical to 900M30S as there is no documentation
-I variants/esp32/diy/9m2ibr_aprs_lora_tracker
build_src_filter =
${esp32_base.build_src_filter}
+<../variants/esp32/diy/9m2ibr_aprs_lora_tracker>

View File

@@ -0,0 +1,8 @@
#include "variant.h"
#include "Arduino.h"
void earlyInitVariant()
{
pinMode(USER_LED, OUTPUT);
digitalWrite(USER_LED, HIGH ^ LED_STATE_ON);
}

View File

@@ -46,4 +46,5 @@
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// #define LED_PIN 1
#define LED_NOTIFICATION 1
#define LED_STATE_ON 0

View File

@@ -22,7 +22,7 @@
#define LED_BLUE 45
#define PIN_LED1 LED_GREEN
#define PIN_LED2 LED_BLUE
#define LED_NOTIFICATION LED_BLUE
#define LED_PIN LED_GREEN
#define ledOff(pin) pinMode(pin, INPUT)

View File

@@ -30,7 +30,7 @@
#define LED_BLUE 45
#define PIN_LED1 LED_GREEN
#define PIN_LED2 LED_BLUE
#define LED_NOTIFICATION LED_BLUE
#define LED_PIN LED_GREEN
#define ledOff(pin) pinMode(pin, INPUT)

View File

@@ -32,15 +32,8 @@ const uint32_t g_ADigitalPinMap[] = {
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
pinMode(PIN_LED3, OUTPUT);
ledOff(PIN_LED3);
}
void variant_shutdown()

View File

@@ -41,20 +41,15 @@ extern "C" {
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
#define PIN_LED2 -1
#define PIN_LED3 -1
// LED
#define PIN_LED1 (32 + 6) // red
#define LED_POWER (32 + 4)
#define USER_LED (0 + 13) // green
#define LED_NOTIFICATION (0 + 13) // green
// USB_CHECK
#define EXT_PWR_DETECT (32 + 3)
#define ADC_V (0 + 8)
#define LED_RED PIN_LED3
#define LED_BLUE PIN_LED1
#define LED_GREEN PIN_LED2
#define LED_STATE_ON 0 // State when LED is lit // LED灯亮时的状态
#define PIN_BUZZER (0 + 6)
/*

View File

@@ -54,7 +54,7 @@ extern "C" {
#define LED_POWER LED_RED
#define LED_CHARGE LED_POWER // Signals the Status LED Module to handle this LED
#define LED_GREEN 35
#define PIN_LED2 LED_GREEN
#define LED_NOTIFICATION LED_GREEN
#define LED_BLUE 37
#define LED_PAIRING LED_BLUE // Signals the Status LED Module to handle this LED

View File

@@ -32,9 +32,6 @@ const uint32_t g_ADigitalPinMap[] = {
void initVariant()
{
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
pinMode(LED_PAIRING, OUTPUT);
ledOff(LED_PAIRING);

View File

@@ -41,7 +41,7 @@ extern "C" {
// LEDs
#define LED_BLUE -1
#define PIN_LED2 (32 + 9)
#define LED_NOTIFICATION (32 + 9)
#define LED_PAIRING (13)
#define Battery_LED_1 (15)

View File

@@ -43,7 +43,7 @@ extern "C" {
#define LED_BLUE -1
#define LED_CHARGE (12)
#define LED_PAIRING (7)
#define PIN_LED2 LED_PAIRING
#define LED_NOTIFICATION LED_PAIRING
#define LED_STATE_ON HIGH
#define LED_STATE_OFF LOW

View File

@@ -32,7 +32,4 @@ void initVariant()
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}

View File

@@ -27,12 +27,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (32 + 10) // LED P1.15
#define PIN_LED2 (-1) //
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_STATE_ON 0 // State when LED is litted
#define LED_STATE_ON 0 // State when LED is lit
/*
* Buttons

View File

@@ -32,7 +32,4 @@ void initVariant()
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}

View File

@@ -27,12 +27,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (32 + 10) // LED P1.15
#define PIN_LED2 (-1) //
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_STATE_ON 0 // State when LED is litted
#define LED_STATE_ON 0 // State when LED is lit
/*
* Buttons

View File

@@ -52,7 +52,7 @@ extern "C" {
#define LED_GREEN PIN_LED2 // Actually red
#define LED_BLUE PIN_LED1
#define LED_STATE_ON 1 // State when LED is litted
#define LED_STATE_ON 1 // State when LED is lit
#define BUTTON_PIN (32 + 2) // P1.02 7

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -46,10 +46,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -32,12 +32,12 @@ const uint32_t g_ADigitalPinMap[] = {
void initVariant()
{
// LED1 & LED2
// LED1 & LED_BLUE
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
pinMode(LED_BLUE, OUTPUT);
ledOff(LED_BLUE);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);

View File

@@ -47,10 +47,9 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -35,7 +35,4 @@ void initVariant()
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}

View File

@@ -50,10 +50,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36) // Connected to WWAN host LED (if present)
#define LED_BLUE (36) // Connected to WWAN host LED (if present)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -63,8 +63,8 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
digitalWrite(PIN_LED1, HIGH);
pinMode(PIN_LED2, OUTPUT);
digitalWrite(PIN_LED2, HIGH);
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, HIGH);
// Initialize LoRa pins
pinMode(SX126X_RESET, OUTPUT);

View File

@@ -43,9 +43,9 @@ extern "C" {
// LEDs
#define PIN_LED1 (32 + 3) // P1.03, Green
#define PIN_LED2 (32 + 4) // P1.04, Blue
#define LED_BLUE (32 + 4) // P1.04, Blue
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 0 // State when LED is lit
// Buttons

View File

@@ -41,15 +41,6 @@ extern "C" {
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (-1)
#define PIN_LED2 (-1)
#define PIN_LED3 (-1)
#define LED_RED PIN_LED3
#define LED_BLUE PIN_LED1
#define LED_GREEN PIN_LED2
#define LED_STATE_ON 0 // State when LED is lit
/*

View File

@@ -7,7 +7,7 @@ extends = arduino_base
platform_packages =
; our custom Git version until they merge our PR
# TODO renovate
platformio/framework-arduinoadafruitnrf52 @ https://github.com/meshtastic/Adafruit_nRF52_Arduino#c770c8a16a351b55b86e347a3d9d7b74ad0bbf39
platformio/framework-arduinoadafruitnrf52 @ https://github.com/meshtastic/Adafruit_nRF52_Arduino#74096746e5f167a2ff22e483d8e79bb1aef00591
; Don't renovate toolchain-gccarmnoneeabi
platformio/toolchain-gccarmnoneeabi@~1.90301.0

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
// pinMode(PIN_3V3_EN, OUTPUT);
// digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (32 + 4) // P1.04 Controls Green LED
#define PIN_LED2 (28) // P0.28 Controls Blue LED
#define LED_BLUE (28) // P0.28 Controls Blue LED
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -46,10 +46,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -27,10 +27,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -45,10 +45,10 @@ extern "C" {
// LEDs
#define PIN_LED1 (35)
#define PIN_LED2 (36)
#define LED_BLUE (36)
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_NOTIFICATION LED_BLUE
#define LED_STATE_ON 1 // State when LED is litted

View File

@@ -25,7 +25,6 @@
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
// #define LED_PIN PIN_LED2
#define LED_STATE_ON 1 // State when LED is litted
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Button Configuration

View File

@@ -25,8 +25,7 @@
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
// #define LED_PIN PIN_LED2
#define LED_STATE_ON 1 // State when LED is litted
#define LED_STATE_ON 1 // State when LED is lit
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Button Configuration
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

View File

@@ -25,8 +25,7 @@
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
// #define LED_PIN PIN_LED2
#define LED_STATE_ON 1 // State when LED is litted
#define LED_STATE_ON 1 // State when LED is lit
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Button Configuration
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

View File

@@ -69,8 +69,6 @@ static const uint8_t A5 = PIN_A5;
#define PIN_LED2 LED_BLUE
#define PIN_LED3 LED_RED
#define USER_LED LED_BLUE
/*
* Buttons
*/

View File

@@ -36,9 +36,6 @@ void initVariant()
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

View File

@@ -51,11 +51,8 @@ extern "C" {
#define PIN_WIRE_SDA (0 + 5) // P0.05
#define PIN_WIRE_SCL (0 + 4) // P0.04
#define PIN_LED1 (0 + 6) // P0.06
#define PIN_LED2 (PINS_COUNT) // P0.14
#define PIN_LED1 (0 + 6) // P0.06
#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_STATE_ON 0

View File

@@ -25,7 +25,7 @@ static const uint8_t A3 = PIN_A3;
// LEDs
#define PIN_LED (23u)
#define PIN_LED1 PIN_LED
#define PIN_LED2 (24u)
#define LED_NOTIFICATION (24u)
#define ADC_RESOLUTION 12

View File

@@ -15,6 +15,9 @@ build_flags =
-DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1
build_unflags =
-DDEBUG_MUTE # We have space for debug output until sensor support is added
build_src_filter =
${stm32_base.build_src_filter}
+<../variants/stm32/milesight_gs301>
lib_deps =
${stm32_base.lib_deps}

View File

@@ -0,0 +1,8 @@
#include "variant.h"
#include "Arduino.h"
void earlyInitVariant()
{
pinMode(USER_LED, OUTPUT);
digitalWrite(USER_LED, HIGH ^ LED_STATE_ON);
}