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

◆ selectControllerForClockPin()

int fl::SpiChannelEngineAdapter::selectControllerForClockPin ( int clockPin,
Esp32SpiBus requestedBus )
private

Select best controller for a given clock pin.

Parameters
clockPinClock pin number to route
Returns
Controller index, or -1 if none available

Definition at line 103 of file spi_channel_adapter.cpp.hpp.

103 {
104 // Check if clock pin already assigned
105 for (const auto& assignment : mClockPinAssignments) {
106 if (assignment.clockPin == clockPin && assignment.requestedBus == requestedBus) {
107 return assignment.controllerIndex;
108 }
109 }
110
111 // Find highest priority available controller
112 int bestIndex = -1;
113 int bestPriority = -1;
114
115 for (size_t i = 0; i < mControllers.size(); i++) {
116 if (requestedBus != Esp32SpiBus::AUTO &&
117 mControllers[i].controller->getBusId() != static_cast<int>(requestedBus)) {
118 continue;
119 }
120 if (requestedBus == Esp32SpiBus::AUTO &&
122 continue;
123 }
124
125 if (mControllers[i].priority > bestPriority) {
126 bestIndex = i;
127 bestPriority = mControllers[i].priority;
128 }
129 }
130
131 // Record assignment
132 if (bestIndex >= 0) {
133 mClockPinAssignments.push_back({clockPin, requestedBus, static_cast<size_t>(bestIndex)});
134 }
135
136 return bestIndex;
137}
CLEDController * controller
fl::vector< ControllerInfo > mControllers
All managed controllers.
bool canControllerHandleClockPin(const ControllerInfo &ctrl, int clockPin) const FL_NO_EXCEPT
Check if controller can handle this clock pin.
fl::vector< ClockPinAssignment > mClockPinAssignments
Clock pin → controller mapping.

References fl::AUTO, canControllerHandleClockPin(), controller, fl::FL_NO_EXCEPT, mClockPinAssignments, and mControllers.

Referenced by transmitBatch().

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