From f7230b54a24aca25b4a52c7cb61aec98f16c465d Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 5 Jun 2019 06:28:21 +0200 Subject: [PATCH] CycleEffect can now be configured to show the effects sequentially or randomly. --- src/effect_cycle.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/effect_cycle.cpp b/src/effect_cycle.cpp index 5d56279..4167a96 100644 --- a/src/effect_cycle.cpp +++ b/src/effect_cycle.cpp @@ -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(); }