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

◆ create()

ChannelPtr fl::Channel::create ( const ChannelConfig & config)
static

Create a new channel with optional mBus driver pinning.

Parameters
configChannel configuration. If config.options.mBus is not Bus::AUTO, the channel pins itself to the driver named by busName(mBus) via ChannelManager::findDriverByName(). On a miss, showPixels() falls back to AUTO/priority dispatch and emits a one-shot FL_ERROR (see channel.cpp.hpp).
Returns
Shared pointer to channel (auto-cleanup when out of scope)
Note
Channels always use ChannelManager by default.

Definition at line 174 of file channel.cpp.hpp.

174 {
175 // Late binding strategy: Always create with empty driver
176 // Engine binding happens on first showPixels() call:
177 // - Affinity channels: Look up by name and cache
178 // - Non-affinity channels: Select dynamically each frame
179
180 auto channel = fl::make_shared<Channel>(config.chipset, config.mLeds,
181 config.rgb_order, config.options);
182 channel->mName = makeName(channel->mId, config.mName);
183 auto& events = ChannelEvents::instance();
184 events.onChannelCreated(*channel);
185 return channel;
186}
static fl::string makeName(i32 id, const fl::optional< fl::string > &configName=fl::optional< fl::string >())
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
static ChannelEvents & instance()

References fl::ChannelConfig::chipset, fl::ChannelEvents::instance(), fl::make_shared(), makeName(), fl::ChannelConfig::mLeds, fl::ChannelConfig::mName, fl::ChannelConfig::options, and fl::ChannelConfig::rgb_order.

+ Here is the call graph for this function: