Changing the cycle_delay now works.
This commit is contained in:
parent
78f0ab5991
commit
7bcb911fec
10
effects.h
10
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user