Skip to content

Commit

Permalink
garland: implement commands queue
Browse files Browse the repository at this point in the history
  • Loading branch information
ElderJoy authored and mcspr committed Feb 26, 2021
1 parent 4efc417 commit 24550a5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions code/espurna/garland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 24550a5

Please sign in to comment.