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 52 of file fx_engine.cpp.

52 {
53 if (!mEffects.has(index)) {
54 return FxPtr();
55 }
56
57 FxPtr removedFx;
58 bool ok = mEffects.get(index, &removedFx);
59 if (!ok) {
60 return FxPtr();
61 }
62
63 if (mCurrId == index) {
64 // If we're removing the current effect, switch to the next one
65 mEffects.next(mCurrId, &mCurrId, true);
66 mDurationSet = true;
67 mDuration = 0; // Instant transition
68 }
69
70 return removedFx;
71}
bool mDurationSet
Flag indicating if a new transition has been set.
Definition fx_engine.h:125
int mCurrId
Id of the current effect.
Definition fx_engine.h:123
IntFxMap mEffects
Collection of effects.
Definition fx_engine.h:121
uint16_t mDuration
Duration of the current transition.
Definition fx_engine.h:124

References mCurrId, mDuration, mDurationSet, and mEffects.