diff --git a/main/User_config.h b/main/User_config.h index 893110dfd2..ff528d9208 100644 --- a/main/User_config.h +++ b/main/User_config.h @@ -416,65 +416,95 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE; #ifndef RGB_INDICATORS // Management of Errors, reception/emission and informations indicators with basic LED /*-------------DEFINE PINs FOR STATUS LEDs----------------*/ # ifndef LED_SEND_RECEIVE +# ifdef LED_BUILTIN +# define LED_SEND_RECEIVE LED_BUILTIN +# endif # ifdef ESP8266 -# define LED_SEND_RECEIVE 40 +//# define LED_SEND_RECEIVE 40 # elif ESP32 -# define LED_SEND_RECEIVE 40 +//# define LED_SEND_RECEIVE 40 # elif __AVR_ATmega2560__ //arduino mega -# define LED_SEND_RECEIVE 40 +//# define LED_SEND_RECEIVE 40 # else //arduino uno/nano -# define LED_SEND_RECEIVE 40 +//# define LED_SEND_RECEIVE 40 # endif # endif # ifndef LED_SEND_RECEIVE_ON # define LED_SEND_RECEIVE_ON HIGH # endif # ifndef LED_ERROR +# ifdef LED_BUILTIN +# define LED_ERROR LED_BUILTIN +# endif # ifdef ESP8266 -# define LED_ERROR 42 +//# define LED_ERROR 42 # elif ESP32 -# define LED_ERROR 42 +//# define LED_ERROR 42 # elif __AVR_ATmega2560__ //arduino mega -# define LED_ERROR 42 +//# define LED_ERROR 42 # else //arduino uno/nano -# define LED_ERROR 42 +//# define LED_ERROR 42 # endif # endif # ifndef LED_ERROR_ON # define LED_ERROR_ON HIGH # endif # ifndef LED_INFO +# ifdef LED_BUILTIN +# define LED_INFO LED_BUILTIN +# endif # ifdef ESP8266 -# define LED_INFO 44 +//# define LED_INFO 44 # elif ESP32 -# define LED_INFO 44 +//# define LED_INFO 44 # elif __AVR_ATmega2560__ //arduino mega -# define LED_INFO 44 +//# define LED_INFO 44 # else //arduino uno/nano -# define LED_INFO 44 +//# define LED_INFO 44 # endif # endif # ifndef LED_INFO_ON # define LED_INFO_ON HIGH # endif -# define SetupIndicators() \ - pinMode(LED_SEND_RECEIVE, OUTPUT); \ - pinMode(LED_INFO, OUTPUT); \ - pinMode(LED_ERROR, OUTPUT); \ - SendReceiveIndicatorOFF(); \ - InfoIndicatorOFF(); \ - ErrorIndicatorOFF(); - -# define ErrorIndicatorON() digitalWrite(LED_ERROR, LED_ERROR_ON) -# define ErrorIndicatorOFF() digitalWrite(LED_ERROR, !LED_ERROR_ON) -# define SendReceiveIndicatorON() digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON) -# define SendReceiveIndicatorOFF() digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON) -# define InfoIndicatorON() digitalWrite(LED_INFO, LED_INFO_ON) -# define InfoIndicatorOFF() digitalWrite(LED_INFO, !LED_INFO_ON) -# define CriticalIndicatorON() // Not used -# define CriticalIndicatorON() // Not used -# define PowerIndicatorON() // Not used -# define PowerIndicatorOFF() // Not used + +# ifdef LED_ERROR +# define SetupIndicatorError() \ + pinMode(LED_ERROR, OUTPUT); \ + ErrorIndicatorOFF(); +# define ErrorIndicatorON() digitalWrite(LED_ERROR, LED_ERROR_ON) +# define ErrorIndicatorOFF() digitalWrite(LED_ERROR, !LED_ERROR_ON) +# else +# define SetupIndicatorError() +# define ErrorIndicatorON() +# define ErrorIndicatorOFF() +# endif +# ifdef LED_SEND_RECEIVE +# define SetupIndicatorSendReceive() \ + pinMode(LED_SEND_RECEIVE, OUTPUT); \ + SendReceiveIndicatorOFF(); +# define SendReceiveIndicatorON() digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON) +# define SendReceiveIndicatorOFF() digitalWrite(LED_SEND_RECEIVE, !LED_SEND_RECEIVE_ON) +# else +# define SetupIndicatorSendReceive() +# define SendReceiveIndicatorON() +# define SendReceiveIndicatorOFF() +# endif +# ifdef LED_INFO +# define SetupIndicatorInfo() \ + pinMode(LED_INFO, OUTPUT); \ + InfoIndicatorOFF(); +# define InfoIndicatorON() digitalWrite(LED_INFO, LED_INFO_ON) +# define InfoIndicatorOFF() digitalWrite(LED_INFO, !LED_INFO_ON) +# else +# define SetupIndicatorInfo() +# define InfoIndicatorON() +# define InfoIndicatorOFF() +# endif +# define CriticalIndicatorON() // Not used +# define CriticalIndicatorON() // Not used +# define PowerIndicatorON() // Not used +# define PowerIndicatorOFF() // Not used +# define SetupIndicators() // Not used #else // Management of Errors, reception/emission and informations indicators with RGB LED # if !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C3) //I2S not available yet with Fastled on S3 and C3 # define FASTLED_ESP32_I2S // To avoid ESP32 instabilities https://github.com/FastLED/FastLED/issues/1438 @@ -549,6 +579,9 @@ CRGB leds2[FASTLED_IND_NUM_LEDS]; leds2[FASTLED_INFO_LED] = CRGB::Black; \ FastLED.show() # endif +# define SetupIndicatorInfo() +# define SetupIndicatorSendReceive() +# define SetupIndicatorError() #endif #ifdef ESP8266 diff --git a/main/main.ino b/main/main.ino index 1f8edcd435..d9ff4da1fa 100644 --- a/main/main.ino +++ b/main/main.ino @@ -755,7 +755,10 @@ void setup() { checkButton(); #endif //setup LED status - SetupIndicators(); + SetupIndicatorError(); + SetupIndicatorSendReceive(); + SetupIndicatorInfo(); + SetupIndicators(); // For RGB Leds #if defined(ESP8266) || defined(ESP32) # ifdef ESP8266