45#define RO(X) RGB_BYTE(RGB_ORDER, X)
53#define RGB_BYTE(RO,X) (((RO)>>(3*(2-(X)))) & 0x3)
57#define RGB_BYTE0(RO) ((RO>>6) & 0x3)
60#define RGB_BYTE1(RO) ((RO>>3) & 0x3)
63#define RGB_BYTE2(RO) ((RO) & 0x3)
69 #if FASTLED_HD_COLOR_MIXING
82template<EOrder RGB_ORDER,
int LANES=1, u
int32_t MASK=0xFFFFFFFF>
103 #if FASTLED_HD_COLOR_MIXING
115 template<EOrder RGB_ORDER_OTHER>
120 template<
typename PixelControllerT>
121 void copy(
const PixelControllerT& other) {
122 static_assert(int(
kLanes) == int(PixelControllerT::kLanes),
"PixelController lanes must match or mOffsets will be wrong");
123 static_assert(int(
kMask) == int(PixelControllerT::kMask),
"PixelController mask must match or else one or the other controls different lanes");
134 for(
int i = 0; i < LANES; ++i) {
mOffsets[i] = other.mOffsets[i]; }
141 for(
int i = 0; i < LANES; ++i) {
143 if((1<<i) & MASK) { nOffset += (len *
mAdvance); }
191 #if FASTLED_HD_COLOR_MIXING
192 uint8_t global_brightness()
const {
198#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
201#define MAX_LIKELY_UPDATE_RATE_HZ 400
204#define MIN_ACCEPTABLE_DITHER_RATE_HZ 50
207#define UPDATES_PER_FULL_DITHER_CYCLE (MAX_LIKELY_UPDATE_RATE_HZ / MIN_ACCEPTABLE_DITHER_RATE_HZ)
222#define RECOMMENDED_VIRTUAL_BITS ((UPDATES_PER_FULL_DITHER_CYCLE>1) + \
223 (UPDATES_PER_FULL_DITHER_CYCLE>2) + \
224 (UPDATES_PER_FULL_DITHER_CYCLE>4) + \
225 (UPDATES_PER_FULL_DITHER_CYCLE>8) + \
226 (UPDATES_PER_FULL_DITHER_CYCLE>16) + \
227 (UPDATES_PER_FULL_DITHER_CYCLE>32) + \
228 (UPDATES_PER_FULL_DITHER_CYCLE>64) + \
229 (UPDATES_PER_FULL_DITHER_CYCLE>128) )
232#define VIRTUAL_BITS RECOMMENDED_VIRTUAL_BITS
239#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
241 static uint8_t R = 0;
247 R &= (0x01 << ditherBits) - 1;
256 if(R & 0x01) { Q |= 0x80; }
257 if(R & 0x02) { Q |= 0x40; }
258 if(R & 0x04) { Q |= 0x20; }
259 if(R & 0x08) { Q |= 0x10; }
260 if(R & 0x10) { Q |= 0x08; }
261 if(R & 0x20) { Q |= 0x04; }
262 if(R & 0x40) { Q |= 0x02; }
263 if(R & 0x80) { Q |= 0x01; }
270 if( ditherBits < 8) {
271 Q += 0x01 << (7 - ditherBits);
279 for(
int i = 0; i < 3; ++i) {
281 e[i] = s ? (256/s) + 1 : 0;
283#if (FASTLED_SCALE8_FIXED == 1)
306 default:
d[0]=
d[1]=
d[2]=
e[0]=
e[1]=
e[2]=0;
break;
482 #if FASTLED_HD_COLOR_MIXING
487 *c0 = getScaleFullBrightness<0>(*
this);
488 *c1 = getScaleFullBrightness<1>(*
this);
489 *c2 = getScaleFullBrightness<2>(*
this);
497 uint8_t *brightness_out) {
501 #if FASTLED_HD_COLOR_MIXING
515 const uint8_t b0_index =
RGB_BYTE0(RGB_ORDER);
516 const uint8_t b1_index =
RGB_BYTE1(RGB_ORDER);
517 const uint8_t b2_index =
RGB_BYTE2(RGB_ORDER);
518 *b0_out = rgb.raw[b0_index];
519 *b1_out = rgb.raw[b1_index];
520 *b2_out = rgb.raw[b2_index];
540 if (r16 || g16 || b16) {
541 #if FASTLED_HD_COLOR_MIXING
548 if (
scale[0] != 255) {
551 if (
scale[1] != 255) {
554 if (
scale[2] != 255) {
563 uint16_t rgb16[3] = {r16, g16, b16};
564 const uint8_t s0_index =
RGB_BYTE0(RGB_ORDER);
565 const uint8_t s1_index =
RGB_BYTE1(RGB_ORDER);
566 const uint8_t s2_index =
RGB_BYTE2(RGB_ORDER);
567 *s0_out = rgb16[s0_index];
568 *s1_out = rgb16[s1_index];
569 *s2_out = rgb16[s2_index];
573 uint8_t *b2_out, uint8_t *b3_out) {
586 w_placement, out[0], out[1], out[2],
588 b0_out, b1_out, b2_out, b3_out);
590 const uint8_t b0_index =
RGB_BYTE0(RGB_ORDER);
591 const uint8_t b1_index =
RGB_BYTE1(RGB_ORDER);
592 const uint8_t b2_index =
RGB_BYTE2(RGB_ORDER);
597 rgbw.white_color_temp,
600 &rgb.r, &rgb.g, &rgb.b, &w);
608 b0_out, b1_out, b2_out, b3_out);
central include file for FastLED, defines the CFastLED class/object
UISlider brightness("Brightness", 128, 0, 255, 1)
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_SIGN_CONVERSION
#define FL_DISABLE_WARNING_POP
#define FL_DISABLE_WARNING_FLOAT_CONVERSION
Defines the red, green, and blue (RGB) pixel struct.
FASTLED_NAMESPACE_BEGIN typedef fl::u8 EDitherMode
The dither setting, either DISABLE_DITHER or BINARY_DITHER.
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Declares dithering options and types.
Defines color channel ordering enumerations.
Declares functions for five-bit gamma correction.
#define FASTLED_FORCE_INLINE
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
LIB8STATIC_ALWAYS_INLINE uint16_t scale16by8(uint16_t i, fract8 scale)
Scale a 16-bit unsigned value by an 8-bit value, which is treated as the numerator of a fraction whos...
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
LIB8STATIC_ALWAYS_INLINE uint16_t map8_to_16(uint8_t x)
Defines integer mapping functions.
#define FASTLED_NAMESPACE_END
#define FASTLED_NAMESPACE_BEGIN
Implements the FastLED namespace macros.
void five_bit_hd_gamma_bitshift(CRGB colors, CRGB colors_scale, fl::u8 global_brightness, CRGB *out_colors, fl::u8 *out_power_5bit)
FASTLED_FORCE_INLINE void rgb_2_rgbw(RGBW_MODE mode, uint16_t w_color_temperature, uint8_t r, uint8_t g, uint8_t b, uint8_t r_scale, uint8_t g_scale, uint8_t b_scale, uint8_t *out_r, uint8_t *out_g, uint8_t *out_b, uint8_t *out_w)
Converts RGB to RGBW using one of the functions.
void rgbw_partial_reorder(EOrderW w_placement, uint8_t b0, uint8_t b1, uint8_t b2, uint8_t w, uint8_t *out_b0, uint8_t *out_b1, uint8_t *out_b2, uint8_t *out_b3)
#define VIRTUAL_BITS
Alias for RECOMMENDED_VIRTUAL_BITS.
#define RGB_BYTE2(RO)
Gets the color channel for byte 2.
#define RGB_BYTE1(RO)
Gets the color channel for byte 1.
#define RGB_BYTE0(RO)
Gets the color channel for byte 0.
#define RO(X)
Gets the assigned color channel for a byte's position in the output, using the color order (EOrder) t...
Non-templated low level pixel data writing class.
Functions for red, green, blue, white (RGBW) output.
Fast, efficient 8-bit scaling functions specifically designed for high-performance LED programming.
Representation of an RGB pixel (Red, Green, Blue)
FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane)
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE void loadAndScale_WS2816_HD(uint16_t *s0_out, uint16_t *s1_out, uint16_t *s2_out)
static FASTLED_FORCE_INLINE uint8_t scale(PixelController &pc, uint8_t b)
Scale a value using the per-channel scale data.
FASTLED_FORCE_INLINE void loadAndScale_APA102_HD(uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out, uint8_t *brightness_out)
FASTLED_FORCE_INLINE uint8_t stepAdvanceAndLoadAndScale0()
stepDithering() and advanceAndLoadAndScale0()
int8_t mAdvance
how many bytes to advance the pointer by each time. For CRGB this is 3.
FASTLED_FORCE_INLINE uint8_t loadAndScale1(int lane, uint8_t scale)
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE uint8_t stepAdvanceAndLoadAndScale0(int lane)
stepDithering() and advanceAndLoadAndScale0()
static FASTLED_FORCE_INLINE uint8_t loadAndScale(PixelController &pc, int lane, uint8_t scale)
Loads and scales a single byte for a given output slot and lane.
void init_binary_dithering()
Set up the values for binary dithering.
FASTLED_FORCE_INLINE uint8_t loadAndScale1(int lane)
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE uint8_t getScale0()
non-template alias of getscale<0>()
int mLenRemaining
counter for the number of LEDs left to process
FASTLED_FORCE_INLINE uint8_t loadAndScale2(int lane, uint8_t scale)
non-template alias of loadAndScale<2>()
void initOffsets(int len)
Initialize the PixelController::mOffsets array based on the length of the strip.
FASTLED_FORCE_INLINE void loadAndScaleRGB(uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out)
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 uint8_t loadAndScale2(int lane)
non-template alias of loadAndScale<2>()
FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane, uint8_t scale)
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE uint8_t loadAndScale0()
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE int advanceBy()
Get the amount to advance the pointer by.
const uint8_t * mData
pointer to the underlying LED data
static FASTLED_FORCE_INLINE uint8_t loadAndScale(PixelController &pc)
Loads, dithers, and scales a single byte for a given output slot, using class dither and scale values...
uint8_t d[3]
values for the scaled dither signal
FASTLED_FORCE_INLINE int lanes()
Get the number of lanes of the Controller.
int mOffsets[LANES]
the number of bytes to offset each lane from the starting pointer
FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale0(int lane, uint8_t scale)
non-template alias of advanceAndLoadAndScale<0>()
PixelController(const PixelController< RGB_ORDER_OTHER, LANES, MASK > &other)
PixelController(const CRGB &d, int len, ColorAdjustment color_adjustment, EDitherMode dither)
Constructor.
ColorAdjustment mColorAdjustment
FASTLED_FORCE_INLINE uint8_t getScale2()
non-template alias of getscale<2>()
static FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale(PixelController &pc)
A version of loadAndScale() that advances the output data pointer.
int mLen
number of LEDs in the data for one lane
static FASTLED_FORCE_INLINE uint8_t loadAndScale(PixelController &pc, int lane)
Loads, dithers, and scales a single byte for a given output slot and lane, using class dither and sca...
static FASTLED_FORCE_INLINE uint8_t loadByte(PixelController &pc)
Read a byte of LED data.
static FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale(PixelController &pc, int lane, uint8_t scale)
A version of loadAndScale() that advances the output data pointer without dithering.
static FASTLED_FORCE_INLINE uint8_t loadAndScale(PixelController &pc, int lane, uint8_t d, uint8_t scale)
Loads, dithers, and scales a single byte for a given output slot and lane.
FASTLED_FORCE_INLINE int size()
Get the length of the LED strip.
void disableColorAdjustment()
static FASTLED_FORCE_INLINE uint8_t getd(PixelController &pc)
Gets the dithering data for the provided output slot.
FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale0(int lane)
non-template alias of advanceAndLoadAndScale<0>()
uint8_t e[3]
values for the unscaled dither signal
static FASTLED_FORCE_INLINE uint8_t getscale(PixelController &pc)
Gets the scale data for the provided output slot.
static FASTLED_FORCE_INLINE uint8_t dither(PixelController &, uint8_t b, uint8_t d)
Calculate a dither value.
static FASTLED_FORCE_INLINE uint8_t dither(PixelController &pc, uint8_t b)
Calculate a dither value using the per-channel dither data.
FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale0()
non-template alias of advanceAndLoadAndScale<0>()
FASTLED_FORCE_INLINE void loadAndScaleRGBW(Rgbw rgbw, uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out, uint8_t *b3_out)
void enable_dithering(EDitherMode dither)
Toggle dithering enable If dithering is set to enabled, this will re-init the dithering values (init_...
static FASTLED_FORCE_INLINE uint8_t scale(PixelController &, uint8_t b, uint8_t scale)
Scale a value.
FASTLED_FORCE_INLINE void advanceData()
Advance the data pointer forward, adjust position counter.
FASTLED_FORCE_INLINE bool has(int n)
Do we have n pixels left to process?
PixelController(const CRGB *d, int len, ColorAdjustment color_adjustment, EDitherMode dither)
Constructor.
FASTLED_FORCE_INLINE void stepDithering()
Step the dithering forward.
FASTLED_FORCE_INLINE uint8_t stepAdvanceAndLoadAndScale0(int lane, uint8_t scale)
stepDithering() and advanceAndLoadAndScale0()
FASTLED_FORCE_INLINE fl::PixelIterator as_iterator(const Rgbw &rgbw)
PixelController(const uint8_t *d, int len, ColorAdjustment color_adjustment, EDitherMode dither, bool advance, uint8_t skip)
Constructor.
PixelController(const PixelController &other)
Copy constructor.
FASTLED_FORCE_INLINE uint8_t loadAndScale1()
non-template alias of loadAndScale<1>()
static FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale(PixelController &pc, int lane)
A version of loadAndScale() that advances the output data pointer.
FASTLED_FORCE_INLINE uint8_t getScale1()
non-template alias of getscale<1>()
static FASTLED_FORCE_INLINE uint8_t loadByte(PixelController &pc, int lane)
Read a byte of LED data for parallel output.
void copy(const PixelControllerT &other)
FASTLED_FORCE_INLINE uint8_t loadAndScale2()
non-template alias of loadAndScale<2>()