FastLED 3.9.15
Loading...
Searching...
No Matches
PixelController< RGB_ORDER, LANES, MASK > Struct Template Reference

Detailed Description

template<EOrder RGB_ORDER, int LANES = 1, fl::u32 MASK = 0xFFFFFFFF>
struct PixelController< RGB_ORDER, LANES, MASK >

Pixel controller class.

This is the class that we use to centralize pixel access in a block of data, including support for things like RGB reordering, scaling, dithering, skipping (for ARGB data), and eventually, we will centralize 8/12/16 conversions here as well.

Template Parameters
RGB_ORDERthe rgb ordering for the LEDs (e.g. what order red, green, and blue data is written out in)
LANEShow many parallel lanes of output to write
MASKbitmask for the output lanes

Definition at line 102 of file pixel_controller.h.

#include <pixel_controller.h>

+ Collaboration diagram for PixelController< RGB_ORDER, LANES, MASK >:

Public Types

enum  { kLanes = LANES , kMask = MASK }
 

Public Member Functions

 PixelController (const CRGB &d, int len, ColorAdjustment color_adjustment, EDitherMode dither)
 Constructor.
 
 PixelController (const CRGB *d, int len, ColorAdjustment color_adjustment, EDitherMode dither)
 Constructor.
 
 PixelController (const fl::u8 *d, int len, ColorAdjustment color_adjustment, EDitherMode dither, bool advance, fl::u8 skip)
 Constructor.
 
 PixelController (const PixelController &other)
 Copy constructor.
 
template<EOrder RGB_ORDER_OTHER>
 PixelController (const PixelController< RGB_ORDER_OTHER, LANES, MASK > &other)
 
FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale0 ()
 
FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale0 (int lane)
 
FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale0 (int lane, fl::u8 scale)
 non-template alias of advanceAndLoadAndScale<0>()
 
FASTLED_FORCE_INLINE int advanceBy ()
 Get the amount to advance the pointer by.
 
FASTLED_FORCE_INLINE void advanceData ()
 Advance the data pointer forward, adjust position counter.
 
FASTLED_FORCE_INLINE fl::PixelIterator as_iterator (const Rgbw &rgbw)
 
template<typename PixelControllerT>
void copy (const PixelControllerT &other)
 
void disableColorAdjustment ()
 
void enable_dithering (EDitherMode dither)
 Toggle dithering enable/disable.
 
const fl::u8getRawPixelData () const
 Get read-only access to the current pixel data Used by encoders to access raw RGB values for HD processing.
 
FASTLED_FORCE_INLINE fl::u8 getScale0 ()
 non-template alias of getscale<0>()
 
FASTLED_FORCE_INLINE fl::u8 getScale1 ()
 non-template alias of getscale<1>()
 
FASTLED_FORCE_INLINE fl::u8 getScale2 ()
 non-template alias of getscale<2>()
 
FASTLED_FORCE_INLINE bool has (int n)
 Do we have n pixels left to process?
 
void init_binary_dithering ()
 Set up the values for binary dithering.
 
void initOffsets (int len)
 Initialize the PixelController::mOffsets array based on the length of the strip.
 
FASTLED_FORCE_INLINE int lanes ()
 Get the number of lanes of the Controller.
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale0 ()
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale0 (int lane)
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale0 (int lane, fl::u8 scale)
 non-template alias of loadAndScale<0>()
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale1 ()
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale1 (int lane)
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale1 (int lane, fl::u8 scale)
 non-template alias of loadAndScale<1>()
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale2 ()
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale2 (int lane)
 
FASTLED_FORCE_INLINE fl::u8 loadAndScale2 (int lane, fl::u8 scale)
 non-template alias of loadAndScale<2>()
 
FASTLED_FORCE_INLINE void loadAndScaleRGB (fl::u8 *b0_out, fl::u8 *b1_out, fl::u8 *b2_out)
 
FASTLED_FORCE_INLINE void loadAndScaleRGBW (Rgbw rgbw, fl::u8 *b0_out, fl::u8 *b1_out, fl::u8 *b2_out, fl::u8 *b3_out)
 
FASTLED_FORCE_INLINE void loadAndScaleRGBWW (fl::Rgbww rgbww, fl::u8 *b0_out, fl::u8 *b1_out, fl::u8 *b2_out, fl::u8 *b3_out, fl::u8 *b4_out)
 Load + scale a single pixel to 5-channel RGBWW (issue #2558).
 
FASTLED_FORCE_INLINE void preStepFirstByteDithering ()
 Some chipsets pre-cycle the first byte, which means we want to cycle byte 0's dithering separately.
 
FASTLED_FORCE_INLINE int size () const
 Get the length of the LED strip.
 
FASTLED_FORCE_INLINE fl::u8 stepAdvanceAndLoadAndScale0 ()
 
FASTLED_FORCE_INLINE fl::u8 stepAdvanceAndLoadAndScale0 (int lane)
 
FASTLED_FORCE_INLINE fl::u8 stepAdvanceAndLoadAndScale0 (int lane, fl::u8 scale)
 stepDithering() and advanceAndLoadAndScale0()
 
FASTLED_FORCE_INLINE void stepDithering ()
 Step the dithering forward - creates triangular wave that toggles between pixels.
 

Static Public Member Functions

Template'd static functions for output

These functions are used for retrieving LED data for the LED chipset output controllers.

template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 loadByte (PixelController &pc)
 Read a byte of LED data.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 loadByte (PixelController &pc, int lane)
 Read a byte of LED data for parallel output.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 dither (PixelController &pc, fl::u8 b)
 Add dither offset to pixel value (BEFORE scaling).
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 dither (PixelController &, fl::u8 b, fl::u8 d)
 Add explicit dither offset to pixel value (BEFORE scaling).
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 scale (PixelController &pc, fl::u8 b)
 Scale a value using the per-channel scale data.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 scale (PixelController &, fl::u8 b, fl::u8 scale)
 Scale a value.
 
Composite shortcut functions for loading, dithering, and scaling

These composite functions will load color data, dither it, and scale it all at once so that it's ready for the output controller to send to the LEDs.

template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 loadAndScale (PixelController &pc)
 Complete pipeline: load → dither → scale (THE MAGIC HAPPENS HERE!) Order is critical: pixel + dither FIRST, then scale by brightness.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 loadAndScale (PixelController &pc, int lane)
 Complete pipeline: load → dither → scale (parallel output version)
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 loadAndScale (PixelController &pc, int lane, fl::u8 d, fl::u8 scale)
 Complete pipeline: load → dither → scale (explicit dither/scale values)
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 loadAndScale (PixelController &pc, int lane, fl::u8 scale)
 Loads and scales a single byte for a given output slot and lane.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale (PixelController &pc)
 A version of loadAndScale() that advances the output data pointer.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale (PixelController &pc, int lane)
 A version of loadAndScale() that advances the output data pointer.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale (PixelController &pc, int lane, fl::u8 scale)
 A version of loadAndScale() that advances the output data pointer without dithering.
 
Data retrieval functions

These functions retrieve channel-specific data from the class, arranged in output order.

template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 getd (PixelController &pc)
 Gets the dithering data for the provided output slot.
 
template<int SLOT>
static FASTLED_FORCE_INLINE fl::u8 getscale (PixelController &pc)
 Gets the scale data for the provided output slot.
 

Public Attributes

fl::u8 d [3]
 [DITHER] Current dither offset per R,G,B channel (toggles via stepDithering)
 
fl::u8 e [3]
 [DITHER] Max dither range per R,G,B channel (inversely proportional to brightness)
 
fl::i8 mAdvance
 how many bytes to advance the pointer by each time. For CRGB this is 3.
 
ColorAdjustment mColorAdjustment
 
const fl::u8mData
 pointer to the underlying LED data
 
int mLen
 number of LEDs in the data for one lane
 
int mLenRemaining
 counter for the number of LEDs left to process
 
int mOffsets [LANES]
 the number of bytes to offset each lane from the starting pointer
 

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