Added Effect::start() and Effect::stop() to allow effects to reserve memory on start and free it afterwards.

This commit is contained in:
2019-05-31 05:46:17 +02:00
parent a2fe1461ad
commit a7d956209a
5 changed files with 19 additions and 0 deletions

View File

@ -6,10 +6,21 @@ void CycleEffect::changeEffect() {
int new_id = random8(cycle_effects->size());
new_effect = cycle_effects->get(new_id);
} while (&new_effect == &effect);
if (effect) effect->stop();
effect = new_effect;
effect->start();
effectSince = millis();
}
void CycleEffect::start() {
if (!effect) changeEffect();
else effect->start();
}
void CycleEffect::stop() {
if (effect) effect->stop();
}
boolean CycleEffect::can_be_shown_with_clock() {
return effect->can_be_shown_with_clock();
};