This commit is contained in:
cschwinne 2020-10-19 23:30:07 +02:00
commit 3b7f5a1397
2 changed files with 36 additions and 0 deletions

View File

@ -103,6 +103,7 @@ void WLED::loop()
} }
yield(); yield();
handleWs(); handleWs();
handleStatusLED();
// DEBUG serial logging // DEBUG serial logging
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
@ -174,6 +175,10 @@ void WLED::setup()
SPIFFS.begin(); SPIFFS.begin();
#endif #endif
#if STATUSLED && STATUSLED != LEDPIN
pinMode(STATUSLED, OUTPUT);
#endif
DEBUG_PRINTLN(F("Load EEPROM")); DEBUG_PRINTLN(F("Load EEPROM"));
loadSettingsFromEEPROM(true); loadSettingsFromEEPROM(true);
beginStrip(); beginStrip();
@ -504,3 +509,26 @@ void WLED::handleConnection()
} }
} }
} }
void WLED::handleStatusLED()
{
#if STATUSLED && STATUSLED != LEDPIN
ledStatusType = WLED_CONNECTED ? 0 : 2;
if (mqttEnabled && ledStatusType != 2) // Wi-Fi takes presendence over MQTT
ledStatusType = WLED_MQTT_CONNECTED ? 0 : 4;
if (ledStatusType) {
if (millis() - ledStatusLastMillis >= (1000/ledStatusType)) {
ledStatusLastMillis = millis();
ledStatusState = ledStatusState ? 0 : 1;
digitalWrite(STATUSLED, ledStatusState);
}
} else {
#ifdef STATUSLEDINVERTED
digitalWrite(STATUSLED, HIGH);
#else
digitalWrite(STATUSLED, LOW);
#endif
}
#endif
}

View File

@ -506,6 +506,13 @@ WLED_GLOBAL WS2812FX strip _INIT(WS2812FX());
// Usermod manager // Usermod manager
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager()); WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
// Status LED
#if STATUSLED && STATUSLED != LEDPIN
WLED_GLOBAL unsigned long ledStatusLastMillis _INIT(0);
WLED_GLOBAL unsigned short ledStatusType _INIT(0); // current status type - corresponds to number of blinks per second
WLED_GLOBAL bool ledStatusState _INIT(0); // the current LED state
#endif
// debug macro variable definitions // debug macro variable definitions
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
WLED_GLOBAL unsigned long debugTime _INIT(0); WLED_GLOBAL unsigned long debugTime _INIT(0);
@ -544,5 +551,6 @@ public:
void initAP(bool resetAP = false); void initAP(bool resetAP = false);
void initConnection(); void initConnection();
void initInterfaces(); void initInterfaces();
void handleStatusLED();
}; };
#endif // WLED_H #endif // WLED_H