FastLED 3.9.15
Loading...
Searching...
No Matches
fl::ChannelEvents Struct Reference

Detailed Description

Singleton event router for Channel lifecycle events.

Centralized event system - supports multiple listeners per event type. All listeners are shared across all channels. Zero per-channel overhead.

Usage:

// Add a listener
int id = FastLED.channelEvents().onChannelCreated.add([](const IChannel& ch) {
FL_DBG("Channel created: " << ch.name());
});
// Add with priority (higher priority executes first)
int id2 = FastLED.channelEvents().onChannelCreated.add([](const IChannel& ch) {
FL_DBG("High priority listener");
}, 100);
// Remove a listener
FastLED.channelEvents().onChannelCreated.remove(id);
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
virtual const fl::string & name() const =0
User-specified or auto-generated name (e.g. "Channel_3").
Polymorphic identification base for any channel in the system.
Definition ichannel.h:23
#define FL_DBG
Definition log.h:388

Event naming convention:

  • Past tense (Created, Added, Configured, Removed, Enqueued): fired after the action
  • "Begin" prefix (BeginDestroy, BeginShow): fired before the action
  • "End" prefix (EndShow): fired after a bracketed action

Callbacks receive const IChannel& so the same listener works regardless of which Channel<Bus, Chipset> instantiation produced the event. See fl/channels/ichannel.h and issue #2428.

Definition at line 79 of file channel_events.h.

#include <channel_events.h>

Static Public Member Functions

static ChannelEventsinstance ()
 

Public Attributes

fl::function_list< void(const IChannel &)> onChannelAdded
 Fired after a Channel is added to FastLED's controller list.
 
fl::function_list< void(const IChannel &)> onChannelBeginDestroy
 Fired at the start of ~Channel(), before members are torn down.
 
fl::function_list< void(const IChannel &, const ChannelConfig &)> onChannelConfigured
 Fired after applyConfig() reconfigures a Channel.
 
fl::function_list< void(const IChannel &)> onChannelCreated
 Fired after a Channel is constructed via Channel::create()
 
fl::function_list< void(const IChannel &, const ChannelData &)> onChannelDataEncoded
 Fired after pixel data is encoded into byte stream (before enqueuing) Second parameter is the encoded channel data.
 
fl::function_list< void(const IChannel &, const fl::string &driverName)> onChannelEnqueued
 Fired after channel data is enqueued to a driver Second parameter is the driver name (empty string for unnamed drivers)
 
fl::function_list< void(const IChannel &)> onChannelRemoved
 Fired after a Channel is removed from FastLED's controller list.
 

The documentation for this struct was generated from the following files: