From 7bcb911fec27642bdce3c3ee7f79e835bc473855 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Sat, 25 May 2019 23:52:41 +0200 Subject: [PATCH] Changing the cycle_delay now works. --- effects.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/effects.h b/effects.h index a6c77b7..709785d 100644 --- a/effects.h +++ b/effects.h @@ -370,6 +370,7 @@ class MatrixEffect : public Effect { class CycleEffect : public Effect { private: Effect* effect; + long effectSince = 0; public: void changeEffect() { Effect* new_effect; @@ -378,6 +379,7 @@ class CycleEffect : public Effect { new_effect = cycle_effects->get(new_id); } while (&new_effect == &effect); effect = new_effect; + effectSince = millis(); } boolean can_be_shown_with_clock() { @@ -392,8 +394,12 @@ class CycleEffect : public Effect { void loop() { if (!effect) changeEffect(); // If this is the first run, we have to select an effect first! effect->loop(); - EVERY_N_SECONDS(config_effect_cycle_time) { - changeEffect(); + // Don't use EVERY_N_SECONDS(config_effect_cycle_time) here because that function isn't relly made + // to be used with changing values. + EVERY_N_SECONDS(1) { + if (effectSince + config_effect_cycle_time*1000 < millis()) { + changeEffect(); + } } } };