FastLED 3.10.8
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 99 of file spi_channel_adapter.cpp.hpp.

99 {
100 // Check if clock pin already assigned
101 for (const auto& assignment : mClockPinAssignments) {
102 if (assignment.clockPin == clockPin && assignment.requestedBus == requestedBus) {
103 return assignment.controllerIndex;
104 }
105 }
106
107 // Find highest priority available controller
108 int bestIndex = -1;
109 int bestPriority = -1;
110
111 for (size_t i = 0; i < mControllers.size(); i++) {
112 if (requestedBus != Esp32SpiBus::AUTO &&
113 mControllers[i].controller->getBusId() != static_cast<int>(requestedBus)) {
114 continue;
115 }
116 if (!canControllerHandleClockPin(mControllers[i], clockPin)) {
117 continue;
118 }
119
120 if (mControllers[i].priority > bestPriority) {
121 bestIndex = i;
122 bestPriority = mControllers[i].priority;
123 }
124 }
125
126 // Record assignment
127 if (bestIndex >= 0) {
128 mClockPinAssignments.push_back({clockPin, requestedBus, static_cast<size_t>(bestIndex)});
129 }
130
131 return bestIndex;
132}
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: