FastLED 3.10.6
Loading...
Searching...
No Matches

◆ ensureBuffer()

template<typename CONTROLLER, EOrder RGB_ORDER = GRB>
void RGBWEmulatedController< CONTROLLER, RGB_ORDER >::ensureBuffer ( fl::i32 num_leds)
inlineprivate

Ensures the internal RGBW buffer is large enough for the LED count.

Parameters
num_ledsNumber of RGB LEDs to convert to RGBW

Reallocates the buffer if needed, accounting for the 4:3 byte ratio when packing RGBW data into RGB format

Definition at line 288 of file chipsets.h.

288 {
289 if (num_leds != mNumRGBLeds) {
291 // The delegate controller expects the raw pixel byte data in multiples of 3.
292 // In the case of src data not a multiple of 3, then we need to
293 // add pad bytes so that the delegate controller doesn't walk off the end
294 // of the array and invoke a buffer overflow panic.
296 mRGBWPixels.reset(new CRGB[new_size]); // ok bare allocation (array new)
297 // showPixels may never clear the last two pixels.
298 for (fl::u32 i = 0; i < new_size; i++) {
299 mRGBWPixels[i] = CRGB(0, 0, 0);
300 }
301
302 mController.setLeds(mRGBWPixels.get(), new_size);
303 }
304 }
Emulation layer to support RGBW LEDs on RGB controllers.
Definition chipsets.h:196
fl::i32 mNumRGBLeds
Number of RGB LEDs in the original array.
Definition chipsets.h:307
ControllerT mController
The underlying RGB controller instance.
Definition chipsets.h:309
fl::unique_ptr< CRGB[]> mRGBWPixels
Internal buffer for packed RGBW data.
Definition chipsets.h:306
fl::CRGB CRGB
Definition crgb.h:25
static u32 size_as_rgb(u32 num_of_rgbw_pixels) FL_NO_EXCEPT
Definition rgbw.h:236

References mController, mNumRGBLeds, mRGBWPixels, and Rgbw::size_as_rgb().

Referenced by showPixels().

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