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

◆ selectControllerForClockPin()

int fl::SpiChannelEngineAdapter::selectControllerForClockPin ( int clockPin)
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 101 of file spi_channel_adapter.cpp.hpp.

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

References canControllerHandleClockPin(), mClockPinAssignments, and mControllers.

Referenced by transmitBatch().

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