Browse Source

garland: implement commands queue

mcspr-patch-1
DmitryBlinov 3 years ago
committed by Maxim Prokhorov
parent
commit
24550a5b80
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      code/espurna/garland.cpp

+ 11
- 6
code/espurna/garland.cpp View File

@ -337,15 +337,20 @@ void garlandLoop(void) {
unsigned long currentAnimRunTime = millis() - _lastTimeUpdate;
if (currentAnimRunTime > _currentAnimDuration && scene.finishedAnimCycle()) {
unsigned int newAnimInd = _currentAnimInd;
while (newAnimInd == _currentAnimInd) newAnimInd = secureRandom(1, animsSize());
if (!_commands.empty()) {
executeCommand(_commands.front());
_commands.pop();
} else {
unsigned int newAnimInd = _currentAnimInd;
while (newAnimInd == _currentAnimInd) newAnimInd = secureRandom(1, animsSize());
unsigned int newPalInd = _currentPaletteInd;
while (newPalInd == _currentPaletteInd) newPalInd = secureRandom(palsSize());
unsigned int newPalInd = _currentPaletteInd;
while (newPalInd == _currentPaletteInd) newPalInd = secureRandom(palsSize());
unsigned long newAnimDuration = secureRandom(EFFECT_UPDATE_INTERVAL_MIN, EFFECT_UPDATE_INTERVAL_MAX);
unsigned long newAnimDuration = secureRandom(EFFECT_UPDATE_INTERVAL_MIN, EFFECT_UPDATE_INTERVAL_MAX);
setupScene(newAnimInd, newPalInd, newAnimDuration);
setupScene(newAnimInd, newPalInd, newAnimDuration);
}
}
}


Loading…
Cancel
Save