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

◆ showPixels()

template<int DATA_PIN, typename TIMING, EOrder RGB_ORDER, int WAIT_TIME, typename DriverTraits, int XTRA0 = 0, bool DIRECT_SHOW = SlimBridgeDirectShow<>::value, bool BATCHED_DIRECT_SHOW = false>
void fl::SlimBridgeController< DATA_PIN, TIMING, RGB_ORDER, WAIT_TIME, DriverTraits, XTRA0, DIRECT_SHOW, BATCHED_DIRECT_SHOW >::showPixels ( PixelController< RGB_ORDER > & pixels)
inlineoverrideprotected

Definition at line 203 of file slim_bridge_controller.h.

203 {
204 // (A1) Respect runtime driver enable/disable: ChannelManager is the
205 // single source of truth. A disabled driver is never enqueued to (the
206 // #2517 silent-drop failure mode); the frame goes to an enabled driver
207 // that can handle it instead, with a warning naming the fix.
212 FL_UNUSED(wanted); // FL_WARN_EVERY compiles out on low-memory targets
213 if (!fallback) {
214 FL_WARN_EVERY(1000, "addLeds: driver '" << wanted.getName().c_str()
215 << "' is not enabled and no enabled driver can take this strip - dropping frame. "
216 "Fix: FastLED.setDriverEnabled(\"" << wanted.getName().c_str()
217 << "\", true), or drop the setExclusiveDriver() that disabled it.");
218 return;
219 }
220 FL_WARN_EVERY(1000, "addLeds: driver '" << wanted.getName().c_str()
221 << "' is not enabled - falling back to '" << fallback->getName().c_str()
222 << "'. Fix: FastLED.setDriverEnabled(\"" << wanted.getName().c_str()
223 << "\", true), or name the enabled bus in addLeds<..., fl::Bus::X>().");
224 }
226
227 // (A8) If the previous frame's buffer is still in flight, block
228 // (bounded) until the driver reports it can accept more work rather
229 // than racing the driver's in-progress DMA/RMT transfer.
230 if (mData->isInUse()) {
231 if (!driver.waitForReady()) {
232 FL_WARN_ONCE("SlimBridgeController: driver '" << driver.getName().c_str() << "' did not become ready in time - dropping frame");
233 return;
234 }
235 }
236
237 // (A5) Publish the pixel byte layout so the driver (and any
238 // downstream padding/diagnostic code) knows the encoded stride.
239 if (this->getRgbww().active()) {
240 mData->setPixelFormat(ChannelPixelFormat::RGBWW);
241 } else if (this->getRgbw().active()) {
242 mData->setPixelFormat(ChannelPixelFormat::RGBW);
243 } else {
244 mData->setPixelFormat(ChannelPixelFormat::RGB);
245 }
246
247 const int pixelCount = pixels.size();
249 if (pixelCount < 0 || bytesPerPixel == 0 ||
250 static_cast<fl::size>(pixelCount) > static_cast<fl::size>(-1) / bytesPerPixel) {
252 FL_WARN_ONCE("SlimBridgeController: invalid encoded frame size - dropping frame");
253 return;
254 }
255 const fl::size expectedSize = static_cast<fl::size>(pixelCount) * bytesPerPixel;
256 auto &encoded = mData->getData();
257 // Reserve the complete snapshot before clearing the old one. Byte-wise
258 // geometric growth could fail partway through encoding and enqueue a
259 // silently truncated frame; exact reservation also bounds peak heap.
260 encoded.reserve(expectedSize);
261 if (encoded.capacity() < expectedSize) {
263 FL_WARN_ONCE("SlimBridgeController: cannot allocate encoded frame - dropping frame");
264 return;
265 }
266
267 // Observe accepted frames only after allocation succeeds (e.g. feeding
268 // ActiveStripTracker for stub/WASM channels).
270
271 // (A3) Re-encode into the same buffer every frame -- clear() keeps
272 // capacity, so steady-state operation is allocation-free.
273 encoded.clear();
275 iterator.writeWS2812(&encoded);
276 if (encoded.size() != expectedSize) {
277 encoded.clear();
279 FL_WARN_ONCE("SlimBridgeController: incomplete encoded frame - dropping frame");
280 return;
281 }
282
283 driver.enqueue(mData);
285 }
Rgbww getRgbww() const FL_NO_EXCEPT
VIRTUAL_IF_NOT_AVR int size() const FL_NO_EXCEPT
How many LEDs does this controller manage?
Rgbw getRgbw() const FL_NO_EXCEPT
virtual void onBeforeEncode(PixelController< RGB_ORDER > &pixels) FL_NO_EXCEPT
Called once per accepted frame, after the enabled/ready gates pass and BEFORE the frame is encoded an...
Shared legacy addLeds<>() bridge controller over an IChannelDriver.
#define FL_WARN_ONCE(...)
Definition log.h:439
#define FL_WARN_EVERY(MILLIS,...)
Definition log.h:442
auto reject_legacy_frame(int) FL_NO_EXCEPT -> decltype(Traits::rejectLegacyFrame(), void())
u8 channelPixelFormatBytesPerPixel(ChannelPixelFormat format) FL_NO_EXCEPT
Definition data.h:33
#define FL_UNUSED(x)