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 {
|
class CycleEffect : public Effect {
|
||||||
private:
|
private:
|
||||||
Effect* effect;
|
Effect* effect;
|
||||||
|
long effectSince = 0;
|
||||||
public:
|
public:
|
||||||
void changeEffect() {
|
void changeEffect() {
|
||||||
Effect* new_effect;
|
Effect* new_effect;
|
||||||
@ -378,6 +379,7 @@ class CycleEffect : public Effect {
|
|||||||
new_effect = cycle_effects->get(new_id);
|
new_effect = cycle_effects->get(new_id);
|
||||||
} while (&new_effect == &effect);
|
} while (&new_effect == &effect);
|
||||||
effect = new_effect;
|
effect = new_effect;
|
||||||
|
effectSince = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean can_be_shown_with_clock() {
|
boolean can_be_shown_with_clock() {
|
||||||
@ -392,8 +394,12 @@ class CycleEffect : public Effect {
|
|||||||
void loop() {
|
void loop() {
|
||||||
if (!effect) changeEffect(); // If this is the first run, we have to select an effect first!
|
if (!effect) changeEffect(); // If this is the first run, we have to select an effect first!
|
||||||
effect->loop();
|
effect->loop();
|
||||||
EVERY_N_SECONDS(config_effect_cycle_time) {
|
// Don't use EVERY_N_SECONDS(config_effect_cycle_time) here because that function isn't relly made
|
||||||
changeEffect();
|
// 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