FastLED 3.9.15
Loading...
Searching...
No Matches
RGBWEmulatedController< CONTROLLER, RGB_ORDER > Class Template Reference

Detailed Description

template<typename CONTROLLER, EOrder RGB_ORDER = GRB>
class RGBWEmulatedController< CONTROLLER, RGB_ORDER >

Emulation layer to support RGBW LEDs on RGB controllers.

This template class allows you to use RGBW (4-channel) LED strips with controllers that only support RGB (3-channel) output. It works by:

  1. Creating an internal buffer to store the converted RGBW data
  2. Converting RGB color values to RGBW using configurable color conversion modes
  3. Packing the RGBW data (4 bytes per pixel) into RGB format (3 bytes) for transmission
  4. Sending the packed data to the underlying RGB controller
Template Parameters
CONTROLLERThe base RGB controller type (e.g., WS2812)
RGB_ORDERThe color channel ordering (e.g., GRB for WS2812)

Usage Example:

// Define your base RGB controller (must use RGB ordering, no reordering allowed)
typedef WS2812<DATA_PIN, RGB> ControllerT;
// Create the RGBW emulator with your desired color ordering
// Add to FastLED
FastLED.addLeds(&rgbwController, leds, NUM_LEDS);
#define NUM_LEDS
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
CRGB * leds() FL_NOEXCEPT
Pointer to the CRGB array for this controller.
RGBWEmulatedController(const Rgbw &rgbw=RgbwDefault())
Constructor with optional RGBW configuration.
Definition chipsets.h:222

Color Conversion Modes (via Rgbw parameter):

  • kRGBWExactColors: Preserves color accuracy, reduces max brightness
  • kRGBWMaxBrightness: Maximizes brightness, may oversaturate colors
  • kRGBWBoostedWhite: Boosts white channel for better whites
  • kRGBWNullWhitePixel: Disables white channel (RGB mode only)
Note
The base CONTROLLER must use RGB ordering (no internal reordering). Color channel reordering is handled by this wrapper class via RGB_ORDER.

Definition at line 193 of file chipsets.h.

#include <chipsets.h>

+ Inheritance diagram for RGBWEmulatedController< CONTROLLER, RGB_ORDER >:
+ Collaboration diagram for RGBWEmulatedController< CONTROLLER, RGB_ORDER >:

Classes

class  ControllerT
 

Public Types

typedef CONTROLLER ControllerBaseT
 

Public Member Functions

 RGBWEmulatedController (const Rgbw &rgbw=RgbwDefault())
 Constructor with optional RGBW configuration.
 
 ~RGBWEmulatedController ()=default
 Destructor - cleans up the internal RGBW buffer.
 
virtual void * beginShowLeds (int size) override
 
virtual void endShowLeds (void *data) override
 
 FL_STATIC_ASSERT (RGB==CONTROLLER::RGB_ORDER_VALUE, "The delegated controller MUST NOT do reordering")
 
virtual void showPixels (PixelController< RGB_ORDER, LANES, MASK > &pixels) override
 Main rendering function that converts RGB to RGBW and shows pixels.
 
- Public Member Functions inherited from CPixelLEDController< GRB, CONTROLLER::LANES_VALUE, CONTROLLER::MASK_VALUE >
 CPixelLEDController ()
 
int lanes () override
 Get the number of lanes of the Controller.
 
- Public Member Functions inherited from fl::CLEDController
 CLEDController () FL_NOEXCEPT
 Create an led controller object, add it to the chain of controllers.
 
VIRTUAL_IF_NOT_AVR ~CLEDController () FL_NOEXCEPT
 
void addToList () FL_NOEXCEPT
 Add this controller to the linked list.
 
void clearLedDataInternal (int nLeds=-1) FL_NOEXCEPT
 Zero out the LED data managed by this controller.
 
VIRTUAL_IF_NOT_AVR void clearLeds (int nLeds=-1) FL_NOEXCEPT
 Clear out/zero out the given number of LEDs.
 
CLEDControllerclearWhiteChannel () FL_NOEXCEPT
 Reset this channel to plain 3-channel RGB (clears any RGBW/RGBWW configuration).
 
CRGB getAdjustment (fl::u8 scale) FL_NOEXCEPT
 Get the combined brightness/color adjustment for this controller.
 
ColorAdjustment getAdjustmentData (fl::u8 brightness) FL_NOEXCEPT
 
CRGB getCorrection () FL_NOEXCEPT
 Get the correction value used by this controller.
 
fl::u8 getDither () FL_NOEXCEPT
 Get the dithering option currently set for this controller.
 
bool getEnabled () FL_NOEXCEPT
 
virtual fl::u16 getMaxRefreshRate () const FL_NOEXCEPT
 Gets the maximum possible refresh rate of the strip.
 
Rgbw getRgbw () const FL_NOEXCEPT
 
Rgbww getRgbww () const FL_NOEXCEPT
 
CRGB getTemperature () FL_NOEXCEPT
 Get the color temperature, aka white point, for this controller.
 
bool isInList () const FL_NOEXCEPT
 Check if this controller is in the linked list.
 
const CRGBleds () const FL_NOEXCEPT
 Const pointer to the CRGB array for this controller.
 
CRGBleds () FL_NOEXCEPT
 Pointer to the CRGB array for this controller.
 
fl::span< CRGBledsSpan () FL_NOEXCEPT
 Span of LEDs managed by this controller.
 
const CLEDControllernext () const FL_NOEXCEPT
 Get the next controller in the linked list after this one (const version).
 
CLEDControllernext () FL_NOEXCEPT
 Get the next controller in the linked list after this one.
 
CRGBoperator[] (int x) FL_NOEXCEPT
 Reference to the n'th LED managed by the controller.
 
void removeFromDrawList () FL_NOEXCEPT
 Remove this controller from the draw list.
 
CLEDControllersetCorrection (CRGB correction) FL_NOEXCEPT
 The color corrction to use for this controller, expressed as a CRGB object.
 
CLEDControllersetCorrection (LEDColorCorrection correction) FL_NOEXCEPT
 The color corrction to use for this controller, expressed as a CRGB object.
 
CLEDControllersetDither (fl::u8 ditherMode=BINARY_DITHER) FL_NOEXCEPT
 Set the dithering mode for this controller to use.
 
void setEnabled (bool enabled) FL_NOEXCEPT
 
CLEDControllersetLeds (CRGB *data, int nLeds) FL_NOEXCEPT
 Set the default array of LEDs to be used by this controller.
 
CLEDControllersetLeds (fl::span< CRGB > leds) FL_NOEXCEPT
 Set the default array of LEDs to be used by this controller (span version)
 
CLEDControllersetRgbw (const Rgbw &arg=RgbwDefault::value()) FL_NOEXCEPT
 
CLEDControllersetRgbww (const Rgbww &arg=RgbwwDefault::value()) FL_NOEXCEPT
 Configure this channel for 5-channel RGBWW (RGB + warm-W + cool-W) output.
 
CLEDControllersetScreenMap (const fl::ScreenMap &map) FL_NOEXCEPT
 
CLEDControllersetScreenMap (const fl::XYMap &map, float diameter=-1.f) FL_NOEXCEPT
 
CLEDControllersetScreenMap (fl::u16 width, fl::u16 height, float diameter=-1.f) FL_NOEXCEPT
 
CLEDControllersetTemperature (ColorTemperature temperature) FL_NOEXCEPT
 Set the color temperature, aka white point, for this controller.
 
CLEDControllersetTemperature (CRGB temperature) FL_NOEXCEPT
 Set the color temperature, aka white point, for this controller.
 
void showColorInternal (const CRGB &data, fl::u8 brightness) FL_NOEXCEPT
 
void showColorInternal (const CRGB &data, int nLeds, fl::u8 brightness) FL_NOEXCEPT
 
void showInternal (const CRGB *data, int nLeds, fl::u8 brightness) FL_NOEXCEPT
 
VIRTUAL_IF_NOT_AVR void showLeds (fl::u8 brightness) FL_NOEXCEPT
 
void showLedsInternal (fl::u8 brightness) FL_NOEXCEPT
 Write the data to the LEDs managed by this controller.
 
virtual int size () const FL_NOEXCEPT
 How many LEDs does this controller manage?
 

Static Public Attributes

static const int LANES = CONTROLLER::LANES_VALUE
 
static const fl::u32 MASK = CONTROLLER::MASK_VALUE
 
- Static Public Attributes inherited from CPixelLEDController< GRB, CONTROLLER::LANES_VALUE, CONTROLLER::MASK_VALUE >
static const int LANES_VALUE
 The number of lanes for this controller.
 
static const fl::u32 MASK_VALUE
 The mask for the lanes for this controller.
 
static const EOrder RGB_ORDER_VALUE
 The RGB ordering for this controller.
 

Private Member Functions

void ensureBuffer (fl::i32 num_leds)
 Ensures the internal RGBW buffer is large enough for the LED count.
 
void init () override
 Initialize the controller and disable the base controller.
 

Private Attributes

ControllerT mController
 The underlying RGB controller instance.
 
fl::i32 mNumRGBLeds = 0
 Number of RGB LEDs in the original array.
 
fl::i32 mNumRGBWLeds = 0
 Number of RGBW pixels the buffer can hold.
 
fl::unique_ptr< CRGB[]> mRGBWPixels
 Internal buffer for packed RGBW data.
 

Additional Inherited Members

- Static Public Member Functions inherited from fl::CLEDController
static CLEDControllerhead () FL_NOEXCEPT
 Get the first LED controller in the linked list of controllers.
 
static void removeFromList (CLEDController *controller) FL_NOEXCEPT
 Remove a controller from the linked list.
 
template<typename Visitor>
static void visitControllers (Visitor &&visitor) FL_NOEXCEPT
 Visit all controllers in the linked list with a visitor The visitor must be a callable that accepts (const CLEDController*, fl::span<const CRGB>)
 
- Protected Types inherited from fl::CLEDController
enum class  RegistrationMode { AutoRegister , DeferRegister }
 Registration mode for constructor. More...
 
- Protected Member Functions inherited from CPixelLEDController< GRB, CONTROLLER::LANES_VALUE, CONTROLLER::MASK_VALUE >
 CPixelLEDController (RegistrationMode mode)
 Protected constructor with registration mode.
 
virtual void show (const CRGB *data, int nLeds, fl::u8 brightness) override
 Write the passed in RGB data out to the LEDs managed by this controller.
 
virtual void showColor (const CRGB &data, int nLeds, fl::u8 brightness) override
 Set all the LEDs on the controller to a given color.
 
- Protected Member Functions inherited from fl::CLEDController
 CLEDController (RegistrationMode mode) FL_NOEXCEPT
 Protected constructor with registration mode.
 
- Protected Attributes inherited from fl::CLEDController
bool mEnabled = true
 
fl::span< CRGBmLeds
 span of LED data used by this controller
 
CLEDControllermPNext = nullptr
 pointer to the next LED controller in the linked list
 
ChannelOptions mSettings
 Optional channel settings (correction, temperature, dither, rgbw, affinity)
 
- Static Protected Attributes inherited from fl::CLEDController
static CLEDControllermPHead = nullptr
 pointer to the first LED controller in the linked list
 
static CLEDControllermPTail = nullptr
 pointer to the last LED controller in the linked list
 

The documentation for this class was generated from the following file: