FastLED 3.10.8
Loading...
Searching...
No Matches

◆ resolveDynamicDriver()

FL_NO_INLINE fl::shared_ptr< IChannelDriver > fl::Channel::resolveDynamicDriver ( )
private

Cold slow-path helper for showPixels().

Resolve the driver for this channel.

Handles dynamic ChannelManager::selectDriverForChannel() lookup AND the bus-key-miss diagnostics (#2455 / #2459). This is now the only driver-resolution path.

Marked FL_NO_INLINE to keep showPixels() compact – see #2773 item 2.1. Returns nullptr on a hard miss (caller should silently bail).

Handles dynamic ChannelManager::selectDriverForChannel lookup AND the bus-key-miss diagnostic chain. Hoisted out of showPixels so the hot path stays compact – see #2773 item 2.1. This is the only driver-resolution path; there is no pre-bound fast path.

Marked noinline (via FL_NO_INLINE) so the compiler doesn't fold the cold body back into showPixels.

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

829 {
830#if defined(FASTLED_DISABLE_DYNAMIC_DRIVER) && FASTLED_DISABLE_DYNAMIC_DRIVER
831 // Body excluded via FASTLED_DISABLE_DYNAMIC_DRIVER (#2926). The
832 // showPixels call site is also gated so this is unreachable; the
833 // empty body lets the linker dead-strip ChannelManager::findDriverByName
834 // and selectDriverForChannel along with this symbol.
835 return {};
836#else
837 // Build busKey only when we actually need it (mBus != AUTO).
838 fl::string busKey;
839 if (mBus != Bus::AUTO) {
841 }
842
843 fl::shared_ptr<IChannelDriver> driver =
845 mDriver = driver;
846
847 // #2455 / #2459: one-shot diagnostic when a typed-Bus miss happens.
848 // Probe via `findDriverByName` (silent) to distinguish "driver wasn't
849 // instantiated" from "driver exists but canHandle() rejected this
850 // chipset" — resolution paths differ. The mBusWarned guard suppresses
851 // duplicate logs on subsequent shows of the same channel.
852#if FASTLED_LOG_RUNTIME_ENABLED
853 if (mBus != Bus::AUTO && !mBusWarned &&
854 (!driver || driver->getName() != busKey)) {
855 auto busDriver = ChannelManager::instance().findDriverByName(busKey);
856 if (!busDriver) {
857 // Typed Bus miss — emit the actionable hint with the three
858 // currently-shipping remediations (option 3 added in #2460).
859 FL_ERROR("Channel '" << mName << "': Driver '" << busKey << "' wasn't instantiated. Resolve with: (1) fl::enableDrivers<fl::Bus::" << busKey << ">() (links only this driver), (2) FastLED.enableAllDrivers() (links every driver), or (3) FastLED.addLeds<..., fl::Bus::" << busKey << ">(...) (legacy API; pins Bus + triggers linker keep-alive). Defaulting to AUTO/priority dispatch.");
860 } else {
861 // Registered, but canHandle() said no — bus/chipset mismatch.
862 FL_ERROR("Channel '" << mName << "': Driver '" << busKey << "' is registered but cannot handle this channel's chipset (bus/chipset mismatch). Defaulting to AUTO/priority dispatch.");
863 }
864 mBusWarned = true;
865 }
866 if (!driver) {
867 FL_ERROR("Channel '" << mName << "': No compatible driver found - cannot transmit");
868 }
869#endif // FASTLED_LOG_RUNTIME_ENABLED — release skips the per-frame
870 // driver->getName() != busKey compare + the silent
871 // findDriverByName probe (used only to differentiate the
872 // FL_ERROR message). The functional return value below is
873 // preserved in both builds. See #2952.
874 return driver;
875#endif // !FASTLED_DISABLE_DYNAMIC_DRIVER
876}
fl::u8 mBusWhich
Definition channel.h:439
bool isSpi() const FL_NO_EXCEPT
Check if this is an SPI chipset.
Definition channel.h:146
bool mBusWarned
Definition channel.h:440
ChannelDataPtr mChannelData
Definition channel.h:457
fl::weak_ptr< IChannelDriver > mDriver
Definition channel.h:433
fl::string mName
Definition channel.h:456
fl::shared_ptr< IChannelDriver > findDriverByName(const fl::string &name) const FL_NO_EXCEPT
Silent counterpart to getDriverByName().
static ChannelManager & instance() FL_NO_EXCEPT
Get the global singleton instance.
fl::shared_ptr< IChannelDriver > selectDriverForChannel(const ChannelDataPtr &data, const fl::string &affinity) FL_NO_EXCEPT
Select best driver for channel data (used by Channel::showPixels)
static string from_literal(const char *literal) FL_NO_EXCEPT
#define FL_ERROR(...)
Definition log.h:373
const char * busDriverName(Bus b, fl::u8 which=0, bool spi=false) FL_NO_EXCEPT
Concrete ChannelManager driver name for a portable bus.
Definition bus.h:170
@ AUTO
Definition bus.h:28

References fl::AUTO, fl::busDriverName(), fl::ChannelManager::findDriverByName(), FL_ERROR, fl::FL_NO_EXCEPT, fl::string::from_literal(), fl::ChannelManager::instance(), isSpi(), mBus, mBusWarned, mBusWhich, mChannelData, mDriver, mName, and fl::ChannelManager::selectDriverForChannel().

Referenced by showPixels().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: