CycleEffect can now be configured to show the effects sequentially or randomly.

This commit is contained in:
Fabian Schlenz 2019-06-05 06:28:21 +02:00
parent a2b0f7106f
commit f7230b54a2

View File

@ -2,13 +2,18 @@
void CycleEffect::changeEffect() { void CycleEffect::changeEffect() {
int new_id; int new_id;
do { if (EFFECT_CYCLE_RANDOM) {
new_id = random8(cycle_effects->size()); do {
} while (new_id == effect_id); new_id = random8(cycle_effects->size());
LOG("CycleEffect * Changing effect to #"); LOGln(new_id); } while (new_id == effect_id);
} else {
new_id = (effect_id + 1) % cycle_effects->size();
}
LOG("CycleEffect * Changing effect from #"); LOG(effect_id); LOG(" to #"); LOGln(new_id);
if (effect) effect->stop(); if (effect) effect->stop();
effect = cycle_effects->get(new_id); effect = cycle_effects->get(new_id);
effect->start(); effect->start();
effect_id = new_id;
effectSince = millis(); effectSince = millis();
} }