FastLED 3.10.9
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 187 of file slim_bridge_controller.h.

187 {
189
190 // (A1) Respect runtime driver enable/disable: ChannelManager is the
191 // single source of truth. A disabled driver means "drop this frame",
192 // not "enqueue and hope" -- silently enqueuing to a disabled driver
193 // is the #2517 silent-drop failure mode.
194 if (!Policy::enabled(driver)) {
195 FL_WARN_ONCE("SlimBridgeController: driver '" << driver.getName().c_str() << "' is disabled - dropping frame");
196 return;
197 }
198
199 // (A8) If the previous frame's buffer is still in flight, block
200 // (bounded) until the driver reports it can accept more work rather
201 // than racing the driver's in-progress DMA/RMT transfer.
202 if (mData->isInUse()) {
203 if (!driver.waitForReady()) {
204 FL_WARN_ONCE("SlimBridgeController: driver '" << driver.getName().c_str() << "' did not become ready in time - dropping frame");
205 return;
206 }
207 }
208
209 // (A5) Publish the pixel byte layout so the driver (and any
210 // downstream padding/diagnostic code) knows the encoded stride.
211 if (this->getRgbww().active()) {
212 mData->setPixelFormat(ChannelPixelFormat::RGBWW);
213 } else if (this->getRgbw().active()) {
214 mData->setPixelFormat(ChannelPixelFormat::RGBW);
215 } else {
216 mData->setPixelFormat(ChannelPixelFormat::RGB);
217 }
218
219 const int pixelCount = pixels.size();
221 if (pixelCount < 0 || bytesPerPixel == 0 ||
222 static_cast<fl::size>(pixelCount) > static_cast<fl::size>(-1) / bytesPerPixel) {
224 FL_WARN_ONCE("SlimBridgeController: invalid encoded frame size - dropping frame");
225 return;
226 }
227 const fl::size expectedSize = static_cast<fl::size>(pixelCount) * bytesPerPixel;
228 auto &encoded = mData->getData();
229 // Reserve the complete snapshot before clearing the old one. Byte-wise
230 // geometric growth could fail partway through encoding and enqueue a
231 // silently truncated frame; exact reservation also bounds peak heap.
232 encoded.reserve(expectedSize);
233 if (encoded.capacity() < expectedSize) {
235 FL_WARN_ONCE("SlimBridgeController: cannot allocate encoded frame - dropping frame");
236 return;
237 }
238
239 // Observe accepted frames only after allocation succeeds (e.g. feeding
240 // ActiveStripTracker for stub/WASM channels).
242
243 // (A3) Re-encode into the same buffer every frame -- clear() keeps
244 // capacity, so steady-state operation is allocation-free.
245 encoded.clear();
247 iterator.writeWS2812(&encoded);
248 if (encoded.size() != expectedSize) {
249 encoded.clear();
251 FL_WARN_ONCE("SlimBridgeController: incomplete encoded frame - dropping frame");
252 return;
253 }
254
255 driver.enqueue(mData);
257 }
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
auto reject_legacy_frame(int) FL_NO_EXCEPT -> decltype(Traits::rejectLegacyFrame(), void())
u8 channelPixelFormatBytesPerPixel(ChannelPixelFormat format) FL_NO_EXCEPT
Definition data.h:33

References fl::basic_string::c_str(), fl::channelPixelFormatBytesPerPixel(), fl::IChannelDriver::enqueue(), fl::FL_NO_EXCEPT, FL_WARN_ONCE, fl::IChannelDriver::getName(), fl::CLEDController::getRgbw(), fl::CLEDController::getRgbww(), mData, onBeforeEncode(), fl::detail::reject_legacy_frame(), fl::RGB, fl::RGBW, fl::RGBWW, fl::IChannelDriver::waitForReady(), and fl::PixelIterator::writeWS2812().

+ Here is the call graph for this function: