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() {
int new_id;
do {
new_id = random8(cycle_effects->size());
} while (new_id == effect_id);
LOG("CycleEffect * Changing effect to #"); LOGln(new_id);
if (EFFECT_CYCLE_RANDOM) {
do {
new_id = random8(cycle_effects->size());
} 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();
effect = cycle_effects->get(new_id);
effect->start();
effect_id = new_id;
effectSince = millis();
}