FastLED 3.9.15
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 287 of file chipsets.h.

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

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: