FastLED 3.10.10
Loading...
Searching...
No Matches

◆ applyConfig()

void fl::Channel::applyConfig ( const ChannelConfig & config)

Apply reconfigurable settings from a ChannelConfig.

Parameters
configThe configuration to apply
Note
Pin assignment, chipset timing/encoder, bus binding and ID stay unchanged. A conflicting chipset or explicit bus rejects the entire configuration; Bus::AUTO retains the existing bus and instance.

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

536 {
537 const auto* currentClockless = mChipset.ptr<ClocklessChipset>();
538 const auto* incomingClockless = config.chipset.ptr<ClocklessChipset>();
539 const auto* currentSpi = mChipset.ptr<SpiChipsetConfig>();
540 const auto* incomingSpi = config.chipset.ptr<SpiChipsetConfig>();
541 const bool compatible = currentClockless && incomingClockless
542 ? currentClockless->timing == incomingClockless->timing &&
543 currentClockless->encoder == incomingClockless->encoder
544 : currentSpi && incomingSpi && currentSpi->timing == incomingSpi->timing &&
545 currentSpi->spiBus == incomingSpi->spiBus;
546 if (!compatible) {
547 FL_WARN("Channel " << id() << ": applyConfig rejected, chipset conflicts with the existing binding");
548 return;
549 }
550 if (config.options.mBus != Bus::AUTO &&
551 (config.options.mBus != mBus || config.options.mBusWhich != mBusWhich)) {
552 FL_WARN("Channel " << id() << ": applyConfig rejected, bus conflicts with the existing binding");
553 return;
554 }
555 mRgbOrder = config.rgb_order;
556 if (config.mName.has_value()) {
557 mName = config.mName.value();
558 }
559 setLeds(config.mLeds);
560 // Replace Channel-owned options and synchronize the base rendering fields.
561 mSettings = config.options;
562#if !FL_COLOR_PROFILE_RUNTIME && !defined(FL_IS_AVR)
563 // Tiny options cannot carry a replacement profile; applying them is a
564 // legacy transition, just like the base correction/temperature setters.
566#endif
570 auto& events = ChannelEvents::instance();
571#if FL_COLOR_PROFILE_RUNTIME
572 if (reconcileColorProfile(config.options)) {
573 events.onColorProfileFallback(ColorProfileEvent{id(), colorProfileStatus(), {}});
574 }
575#endif
576 events.onChannelConfigured(*this, config);
577}
CLEDController & setLeds(CRGB *data, int nLeds) FL_NO_EXCEPT
Set the default array of LEDs to be used by this controller.
EOrder mRgbOrder
Definition channel.h:417
fl::u8 mBusWhich
Definition channel.h:441
i32 id() const FL_NO_EXCEPT override
Get the channel ID.
Definition channel.h:106
ChipsetVariant mChipset
Definition channel.h:415
ColorProfileStatus colorProfileStatus() const FL_NO_EXCEPT
Definition channel.h:277
void syncLegacySettings() FL_NO_EXCEPT
bool mStaticProfileCleared
Definition channel.h:458
fl::string mName
Definition channel.h:453
ChannelOptions mSettings
Definition channel.h:456
#define FL_WARN(...)
Definition log.h:437
@ AUTO
Definition bus.h:32
static ChannelEvents & instance() FL_NO_EXCEPT

References fl::AUTO, colorProfileStatus(), fl::ClocklessChipset::encoder, fl::FL_NO_EXCEPT, FL_WARN, id(), fl::ChannelEvents::instance(), mBus, mBusWhich, mChipset, mName, mRgbOrder, mSettings, mStaticProfileCleared, fl::CLEDController::setLeds(), fl::SpiChipsetConfig::spiBus, syncLegacySettings(), fl::ClocklessChipset::timing, and fl::SpiChipsetConfig::timing.

+ Here is the call graph for this function: