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

56 {
57 if (!mEffects.has(index)) {
58 return FxPtr();
59 }
60
61 FxPtr removedFx;
62 bool ok = mEffects.get(index, &removedFx);
63 if (!ok) {
64 return FxPtr();
65 }
66
67 if (mCurrId == index) {
68 // If we're removing the current effect, switch to the next one
69 mEffects.next(mCurrId, &mCurrId, true);
70 mDurationSet = true;
71 mDuration = 0; // Instant transition
72 }
73
74 return removedFx;
75}
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.