Only auto-activate FireAnimation once on startup
This commit is contained in:
parent
9d60afe1fb
commit
4d2c61782b
18
src/main.cpp
18
src/main.cpp
|
@ -96,6 +96,7 @@ bool initLEDs()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum LEDState {
|
enum LEDState {
|
||||||
|
STARTUP,
|
||||||
UDP,
|
UDP,
|
||||||
ANIMATION,
|
ANIMATION,
|
||||||
TRANSITION,
|
TRANSITION,
|
||||||
|
@ -105,7 +106,7 @@ enum LEDState {
|
||||||
static void ledFSM(void)
|
static void ledFSM(void)
|
||||||
{
|
{
|
||||||
static bool stateEntered = true;
|
static bool stateEntered = true;
|
||||||
static LEDState ledState = ANIMATION;
|
static LEDState ledState = STARTUP;
|
||||||
static LEDState nextState;
|
static LEDState nextState;
|
||||||
|
|
||||||
static unsigned long lastUDPUpdate = 0;
|
static unsigned long lastUDPUpdate = 0;
|
||||||
|
@ -113,19 +114,22 @@ static void ledFSM(void)
|
||||||
LEDState lastState = ledState;
|
LEDState lastState = ledState;
|
||||||
|
|
||||||
switch(ledState) {
|
switch(ledState) {
|
||||||
case ANIMATION:
|
case STARTUP:
|
||||||
Serial.print("A");
|
animController.loop();
|
||||||
|
|
||||||
|
if(animController.isIdle()) {
|
||||||
|
animController.changeAnimation(std::unique_ptr<Animation>(new FireAnimation(&ledFader, false)), false);
|
||||||
|
ledState = ANIMATION;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ANIMATION:
|
||||||
if(stateEntered) {
|
if(stateEntered) {
|
||||||
animController.restart();
|
animController.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
animController.loop();
|
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)) &&
|
if(((WiFi.status() == WL_CONNECTED) || (WiFi.getMode() == WIFI_MODE_AP)) &&
|
||||||
udpProto.check()) {
|
udpProto.check()) {
|
||||||
// UDP packet received -> transition to UDP state
|
// UDP packet received -> transition to UDP state
|
||||||
|
|
Loading…
Reference in a new issue