After showing the IP for 1 Minute, switch animation

This commit is contained in:
Thomas Kolb 2020-04-14 21:32:47 +02:00
parent dc8bc98193
commit 320268ca14

View file

@ -99,6 +99,7 @@ bool initLEDs()
enum LEDState {
STARTUP,
UDP,
SHOWIP,
ANIMATION,
TRANSITION,
TRANSITION_FADE2BLACK
@ -112,6 +113,8 @@ static void ledFSM(void)
static unsigned long lastUDPUpdate = 0;
static unsigned long stateEnteredTime = 0;
LEDState lastState = ledState;
switch(ledState) {
@ -124,7 +127,27 @@ static void ledFSM(void)
Font::textToBitmap(infoStr.c_str(), &bmp, Fader::Color{0, 0, 0, 32});
animController.changeAnimation(std::unique_ptr<Animation>(new ImageScrollerAnimation(&ledFader, &bmp, 5)), false);
//animController.changeAnimation(std::unique_ptr<Animation>(new FireAnimation(&ledFader, false)), false);
ledState = SHOWIP;
}
break;
case SHOWIP:
if(stateEntered) {
animController.restart();
}
animController.loop();
if(((WiFi.status() == WL_CONNECTED) || (WiFi.getMode() == WIFI_MODE_AP)) &&
udpProto.check()) {
// UDP packet received -> transition to UDP state
nextState = UDP;
ledState = TRANSITION;
}
// change to last used animation after some time
if((millis() - stateEnteredTime) > 60000) {
animController.changeAnimation(std::unique_ptr<Animation>(new FireAnimation(&ledFader, false)), true);
ledState = ANIMATION;
}
break;
@ -190,7 +213,12 @@ static void ledFSM(void)
break;
}
stateEntered = (lastState != ledState);
if(lastState != ledState) {
stateEntered = true;
stateEnteredTime = millis();
} else {
stateEntered = false;
}
}
static void fineDelay(uint32_t us)