FastLED 3.9.15
Loading...
Searching...
No Matches

◆ removeFx()

FxPtr fl::FxEngine::removeFx ( int index)

Requests removal of an effect from the engine, which might not happen immediately (for example the Fx needs to finish a transition).

Parameters
indexThe index of the effect to remove.
Returns
A pointer to the removed effect, or nullptr if the index was invalid.

Definition at line 66 of file fx_engine.cpp.hpp.

66 {
67 if (!mEffects.has(index)) {
68 return FxPtr();
69 }
70
71 FxPtr removedFx;
72 bool ok = mEffects.get(index, &removedFx);
73 if (!ok) {
74 return FxPtr();
75 }
76
77 if (mCurrId == index) {
78 // If we're removing the current effect, switch to the next one
79 mEffects.next(mCurrId, &mCurrId, true);
80 mDurationSet = true;
81 mDuration = 0; // Instant transition
82 }
83
84 return removedFx;
85}
bool mDurationSet
Flag indicating if a new transition has been set.
Definition fx_engine.h:140
int mCurrId
Id of the current effect.
Definition fx_engine.h:138
u16 mDuration
Duration of the current transition.
Definition fx_engine.h:139
IntFxMap mEffects
Collection of effects.
Definition fx_engine.h:136

References mCurrId, mDuration, mDurationSet, and mEffects.