FastLED 3.9.3
Loading...
Searching...
No Matches
FxEngine Class Reference

Detailed Description

Manages and renders multiple visual effects (Fx) for LED strips.

The FxEngine class is responsible for:

  • Storing and managing a collection of visual effects (Fx objects)
  • Handling transitions between effects
  • Rendering the current effect or transition to an output buffer

Definition at line 37 of file fx_engine.h.

#include <fx_engine.h>

Public Types

typedef FixedMap< int, FxRef, FASTLED_FX_ENGINE_MAX_FX > IntFxMap
 

Public Member Functions

 FxEngine (uint16_t numLeds)
 Constructs an FxEngine with the specified number of LEDs.
 
 ~FxEngine ()
 Destructor for FxEngine.
 
int addFx (FxRef effect)
 Adds a new effect to the engine.
 
int addVideo (Video video, XYMap xymap)
 Adds a new video effect to the engine.
 
int addFx (Fx &effect)
 Adds a new effect to the engine.
 
FxRef 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).
 
FxRef getFx (int index)
 Retrieves an effect from the engine without removing it.
 
int getCurrentFxId () const
 
bool draw (uint32_t now, CRGB *outputBuffer)
 Renders the current effect or transition to the output buffer.
 
bool nextFx (uint16_t transition_ms=500)
 Transitions to the next effect in the sequence.
 
bool setNextFx (int index, uint16_t duration)
 Sets the next effect to transition to.
 
IntFxMap_getEffects ()
 
void setTimeScale (float timeScale)
 Sets the time scale for the TimeWarp object.
 

Member Typedef Documentation

◆ IntFxMap

typedef FixedMap<int, FxRef, FASTLED_FX_ENGINE_MAX_FX> FxEngine::IntFxMap

Definition at line 39 of file fx_engine.h.

Constructor & Destructor Documentation

◆ FxEngine()

FxEngine::FxEngine ( uint16_t numLeds)
inline

Constructs an FxEngine with the specified number of LEDs.

Parameters
numLedsThe number of LEDs in the strip.

Definition at line 136 of file fx_engine.h.

◆ ~FxEngine()

FxEngine::~FxEngine ( )
inline

Destructor for FxEngine.

Definition at line 143 of file fx_engine.h.

Member Function Documentation

◆ _getEffects()

IntFxMap & FxEngine::_getEffects ( )
inline

Definition at line 117 of file fx_engine.h.

◆ addFx() [1/2]

int FxEngine::addFx ( Fx & effect)
inline

Adds a new effect to the engine.

Allocate from static memory. This is not reference tracked and an object passed in must never be deleted, as the engine will use a non tracking Ref which may outlive a call to removeFx() and the engine will thefore not know that an object has been deleted. But if it's a static object that's then the object probably wasn't going to be deleted anyway.

Definition at line 75 of file fx_engine.h.

◆ addFx() [2/2]

int FxEngine::addFx ( FxRef effect)
inline

Adds a new effect to the engine.

Parameters
effectPointer to the effect to be added.
Returns
The index of the added effect, or -1 if the effect couldn't be added.

Definition at line 145 of file fx_engine.h.

◆ addVideo()

int FxEngine::addVideo ( Video video,
XYMap xymap )

Adds a new video effect to the engine.

Parameters
videoThe video to be added.
xymapThe XYMap to be added.
Returns
The index of the added effect, or -1 if the effect couldn't be added.

Definition at line 158 of file fx_engine.h.

◆ draw()

bool FxEngine::draw ( uint32_t now,
CRGB * outputBuffer )
inline

Renders the current effect or transition to the output buffer.

Parameters
nowThe current time in milliseconds.
outputBufferThe buffer to render the effect into.

Definition at line 213 of file fx_engine.h.

◆ getCurrentFxId()

int FxEngine::getCurrentFxId ( ) const
inline

Definition at line 92 of file fx_engine.h.

◆ getFx()

FxRef FxEngine::getFx ( int index)
inline

Retrieves an effect from the engine without removing it.

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

Definition at line 204 of file fx_engine.h.

◆ nextFx()

bool FxEngine::nextFx ( uint16_t transition_ms = 500)
inline

Transitions to the next effect in the sequence.

Parameters
durationThe duration of the transition in milliseconds.
Returns
True if the transition was initiated, false otherwise.

Definition at line 164 of file fx_engine.h.

◆ removeFx()

FxRef FxEngine::removeFx ( int index)
inline

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 183 of file fx_engine.h.

◆ setNextFx()

bool FxEngine::setNextFx ( int index,
uint16_t duration )
inline

Sets the next effect to transition to.

Parameters
indexThe index of the effect to transition to.
durationThe duration of the transition in milliseconds.
Returns
True if the transition was set, false if the index was invalid.

Definition at line 173 of file fx_engine.h.

◆ setTimeScale()

void FxEngine::setTimeScale ( float timeScale)
inline

Sets the time scale for the TimeWarp object.

Parameters
timeScaleThe new time scale value.

Definition at line 123 of file fx_engine.h.


The documentation for this class was generated from the following file: