Only auto-activate FireAnimation once on startup

This commit is contained in:
Thomas Kolb 2019-12-16 22:32:28 +01:00
parent 9d60afe1fb
commit 4d2c61782b

View file

@ -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<Animation>(new FireAnimation(&ledFader, false)), false);
ledState = ANIMATION;
}
break;
case ANIMATION:
if(stateEntered) {
animController.restart();
}
animController.loop();
if(animController.isIdle()) {
animController.changeAnimation(std::unique_ptr<Animation>(new FireAnimation(&ledFader, false)));
}
if(((WiFi.status() == WL_CONNECTED) || (WiFi.getMode() == WIFI_MODE_AP)) &&
udpProto.check()) {
// UDP packet received -> transition to UDP state