diff --git a/src/main.cpp b/src/main.cpp index 9a8280a..b7b2062 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,6 +96,7 @@ bool initLEDs() } enum LEDState { + STARTUP, UDP, ANIMATION, TRANSITION, @@ -105,7 +106,7 @@ enum LEDState { static void ledFSM(void) { static bool stateEntered = true; - static LEDState ledState = ANIMATION; + static LEDState ledState = STARTUP; static LEDState nextState; static unsigned long lastUDPUpdate = 0; @@ -113,19 +114,22 @@ static void ledFSM(void) LEDState lastState = ledState; switch(ledState) { - case ANIMATION: - Serial.print("A"); + case STARTUP: + animController.loop(); + if(animController.isIdle()) { + animController.changeAnimation(std::unique_ptr(new FireAnimation(&ledFader, false)), false); + ledState = ANIMATION; + } + break; + + case ANIMATION: if(stateEntered) { animController.restart(); } animController.loop(); - if(animController.isIdle()) { - animController.changeAnimation(std::unique_ptr(new FireAnimation(&ledFader, false))); - } - if(((WiFi.status() == WL_CONNECTED) || (WiFi.getMode() == WIFI_MODE_AP)) && udpProto.check()) { // UDP packet received -> transition to UDP state