FastLED 3.9.15
Loading...
Searching...
No Matches
pixel_controller.h
Go to the documentation of this file.
1#pragma once
2
5
6// Note that new code should use the PixelIterator concrete object to write out
7// led data.
8// Using this class deep in driver code is deprecated because it's templates will
9// infact everything it touches. PixelIterator is concrete and doesn't have these
10// problems. See PixelController::as_iterator() for how to create a PixelIterator.
11
12#include <stddef.h>
13
14#include "lib8tion/intmap.h"
15
16#include "rgbw.h"
18#include "fl/force_inline.h"
19#include "lib8tion/scale8.h"
20#include "fl/namespace.h"
21#include "eorder.h"
22#include "dither_mode.h"
23#include "pixel_iterator.h"
24#include "crgb.h"
25
26
27#include "FastLED.h" // Problematic.
28
30
31
38#define RO(X) RGB_BYTE(RGB_ORDER, X)
39
46#define RGB_BYTE(RO,X) (((RO)>>(3*(2-(X)))) & 0x3)
47
50#define RGB_BYTE0(RO) ((RO>>6) & 0x3)
53#define RGB_BYTE1(RO) ((RO>>3) & 0x3)
56#define RGB_BYTE2(RO) ((RO) & 0x3)
57
58// operator byte *(struct CRGB[] arr) { return (byte*)arr; }
59
62 #if FASTLED_HD_COLOR_MIXING
63 CRGB color;
64 uint8_t brightness;
65 #endif
66};
67
68
75template<EOrder RGB_ORDER, int LANES=1, uint32_t MASK=0xFFFFFFFF>
77 const uint8_t *mData;
78 int mLen;
80 uint8_t d[3];
81 uint8_t e[3];
82 int8_t mAdvance;
83 int mOffsets[LANES];
85
86 enum {
87 kLanes = LANES,
88 kMask = MASK
89 };
90
94
96 #if FASTLED_HD_COLOR_MIXING
97 mColorAdjustment.premixed = CRGB(mColorAdjustment.brightness, mColorAdjustment.brightness, mColorAdjustment.brightness);
98 mColorAdjustment.color = CRGB(0xff, 0xff, 0xff);
99 #endif
100 }
101
105 copy(other);
106 }
107
108 template<EOrder RGB_ORDER_OTHER>
112
113 template<typename PixelControllerT>
114 void copy(const PixelControllerT& other) {
115 static_assert(int(kLanes) == int(PixelControllerT::kLanes), "PixelController lanes must match or mOffsets will be wrong");
116 static_assert(int(kMask) == int(PixelControllerT::kMask), "PixelController mask must match or else one or the other controls different lanes");
117 d[0] = other.d[0];
118 d[1] = other.d[1];
119 d[2] = other.d[2];
120 e[0] = other.e[0];
121 e[1] = other.e[1];
122 e[2] = other.e[2];
123 mData = other.mData;
124 mColorAdjustment = other.mColorAdjustment;
125 mAdvance = other.mAdvance;
126 mLenRemaining = mLen = other.mLen;
127 for(int i = 0; i < LANES; ++i) { mOffsets[i] = other.mOffsets[i]; }
128 }
129
132 void initOffsets(int len) {
133 int nOffset = 0;
134 for(int i = 0; i < LANES; ++i) {
135 mOffsets[i] = nOffset;
136 if((1<<i) & MASK) { nOffset += (len * mAdvance); }
137 }
138 }
139
148 const uint8_t *d, int len, ColorAdjustment color_adjustment,
149 EDitherMode dither, bool advance, uint8_t skip)
150 : mData(d), mLen(len), mLenRemaining(len), mColorAdjustment(color_adjustment) {
152 mData += skip;
153 mAdvance = (advance) ? 3+skip : 0;
154 initOffsets(len);
155 }
156
163 const CRGB *d, int len, ColorAdjustment color_adjustment,
165 : mData((const uint8_t*)d), mLen(len), mLenRemaining(len), mColorAdjustment(color_adjustment) {
167 mAdvance = 3;
168 initOffsets(len);
169 }
170
177 const CRGB &d, int len, ColorAdjustment color_adjustment, EDitherMode dither)
178 : mData((const uint8_t*)&d), mLen(len), mLenRemaining(len), mColorAdjustment(color_adjustment) {
180 mAdvance = 0;
181 initOffsets(len);
182 }
183
184 #if FASTLED_HD_COLOR_MIXING
185 uint8_t global_brightness() const {
186 return mColorAdjustment.brightness;
187 }
188 #endif
189
190
191#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
192
194#define MAX_LIKELY_UPDATE_RATE_HZ 400
195
197#define MIN_ACCEPTABLE_DITHER_RATE_HZ 50
198
200#define UPDATES_PER_FULL_DITHER_CYCLE (MAX_LIKELY_UPDATE_RATE_HZ / MIN_ACCEPTABLE_DITHER_RATE_HZ)
201
215#define RECOMMENDED_VIRTUAL_BITS ((UPDATES_PER_FULL_DITHER_CYCLE>1) + \
216 (UPDATES_PER_FULL_DITHER_CYCLE>2) + \
217 (UPDATES_PER_FULL_DITHER_CYCLE>4) + \
218 (UPDATES_PER_FULL_DITHER_CYCLE>8) + \
219 (UPDATES_PER_FULL_DITHER_CYCLE>16) + \
220 (UPDATES_PER_FULL_DITHER_CYCLE>32) + \
221 (UPDATES_PER_FULL_DITHER_CYCLE>64) + \
222 (UPDATES_PER_FULL_DITHER_CYCLE>128) )
223
225#define VIRTUAL_BITS RECOMMENDED_VIRTUAL_BITS
226
227#endif
228
229
232#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
233 // R is the digther signal 'counter'.
234 static uint8_t R = 0;
235 ++R;
236
237 // R is wrapped around at 2^ditherBits,
238 // so if ditherBits is 2, R will cycle through (0,1,2,3)
239 uint8_t ditherBits = VIRTUAL_BITS;
240 R &= (0x01 << ditherBits) - 1;
241
242 // Q is the "unscaled dither signal" itself.
243 // It's initialized to the reversed bits of R.
244 // If 'ditherBits' is 2, Q here will cycle through (0,128,64,192)
245 uint8_t Q = 0;
246
247 // Reverse bits in a byte
248 {
249 if(R & 0x01) { Q |= 0x80; }
250 if(R & 0x02) { Q |= 0x40; }
251 if(R & 0x04) { Q |= 0x20; }
252 if(R & 0x08) { Q |= 0x10; }
253 if(R & 0x10) { Q |= 0x08; }
254 if(R & 0x20) { Q |= 0x04; }
255 if(R & 0x40) { Q |= 0x02; }
256 if(R & 0x80) { Q |= 0x01; }
257 }
258
259 // Now we adjust Q to fall in the center of each range,
260 // instead of at the start of the range.
261 // If ditherBits is 2, Q will be (0, 128, 64, 192) at first,
262 // and this adjustment makes it (31, 159, 95, 223).
263 if( ditherBits < 8) {
264 Q += 0x01 << (7 - ditherBits);
265 }
266
267 // D and E form the "scaled dither signal"
268 // which is added to pixel values to affect the
269 // actual dithering.
270
271 // Setup the initial D and E values
272 for(int i = 0; i < 3; ++i) {
273 uint8_t s = mColorAdjustment.premixed.raw[i];
274 e[i] = s ? (256/s) + 1 : 0;
275 d[i] = scale8(Q, e[i]);
276#if (FASTLED_SCALE8_FIXED == 1)
277 if(d[i]) (--d[i]);
278#endif
279 if(e[i]) --e[i];
280 }
281#endif
282 }
283
288 return mLenRemaining >= n;
289 }
290
297 switch(dither) {
299 default: d[0]=d[1]=d[2]=e[0]=e[1]=e[2]=0; break;
300 }
301 }
302
306
309 FASTLED_FORCE_INLINE int lanes() { return LANES; }
310
314
317
321 // IF UPDATING HERE, BE SURE TO UPDATE THE ASM VERSION IN
322 // clockless_trinket.h!
323 d[0] = e[0] - d[0];
324 d[1] = e[1] - d[1];
325 d[2] = e[2] - d[2];
326 }
327
330 d[RO(0)] = e[RO(0)] - d[RO(0)];
331 }
332
336
340 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t loadByte(PixelController & pc) { return pc.mData[RO(SLOT)]; }
341
346 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t loadByte(PixelController & pc, int lane) { return pc.mData[pc.mOffsets[lane] + RO(SLOT)]; }
347
353 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t dither(PixelController & pc, uint8_t b) { return b ? qadd8(b, pc.d[RO(SLOT)]) : 0; }
354
359 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t dither(PixelController & , uint8_t b, uint8_t d) { return b ? qadd8(b,d) : 0; }
360
366 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t scale(PixelController & pc, uint8_t b) { return scale8(b, pc.mColorAdjustment.premixed.raw[RO(SLOT)]); }
367
372 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t scale(PixelController & , uint8_t b, uint8_t scale) { return scale8(b, scale); }
373
379
380
384 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t loadAndScale(PixelController & pc) { return scale<SLOT>(pc, pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc))); }
385
390 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t loadAndScale(PixelController & pc, int lane) { return scale<SLOT>(pc, pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc, lane))); }
391
398 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t loadAndScale(PixelController & pc, int lane, uint8_t d, uint8_t scale) { return scale8(pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc, lane), d), scale); }
399
405 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t loadAndScale(PixelController & pc, int lane, uint8_t scale) { return scale8(pc.loadByte<SLOT>(pc, lane), scale); }
406
407
410 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t advanceAndLoadAndScale(PixelController & pc) { pc.advanceData(); return pc.loadAndScale<SLOT>(pc); }
411
415 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t advanceAndLoadAndScale(PixelController & pc, int lane) { pc.advanceData(); return pc.loadAndScale<SLOT>(pc, lane); }
416
421 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t advanceAndLoadAndScale(PixelController & pc, int lane, uint8_t scale) { pc.advanceData(); return pc.loadAndScale<SLOT>(pc, lane, scale); }
422
424
425
430
436 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t getd(PixelController & pc) { return pc.d[RO(SLOT)]; }
437
443 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t getscale(PixelController & pc) { return pc.mColorAdjustment.premixed.raw[RO(SLOT)]; }
444
446
447
449
450 // Helper functions to get around gcc stupidities
451 FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane, uint8_t scale) { return loadAndScale<0>(*this, lane, scale); }
452 FASTLED_FORCE_INLINE uint8_t loadAndScale1(int lane, uint8_t scale) { return loadAndScale<1>(*this, lane, scale); }
453 FASTLED_FORCE_INLINE uint8_t loadAndScale2(int lane, uint8_t scale) { return loadAndScale<2>(*this, lane, scale); }
454 FASTLED_FORCE_INLINE uint8_t advanceAndLoadAndScale0(int lane, uint8_t scale) { return advanceAndLoadAndScale<0>(*this, lane, scale); }
456
457 FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane) { return loadAndScale<0>(*this, lane); }
458 FASTLED_FORCE_INLINE uint8_t loadAndScale1(int lane) { return loadAndScale<1>(*this, lane); }
459 FASTLED_FORCE_INLINE uint8_t loadAndScale2(int lane) { return loadAndScale<2>(*this, lane); }
462
463 // LoadAndScale0 loads the pixel data in the order specified by RGB_ORDER and then scales it by the color correction values
464 // For example in color order GRB, loadAndScale0() will return the green channel scaled by the color correction value for green.
470
471 FASTLED_FORCE_INLINE uint8_t getScale0() { return getscale<0>(*this); }
472 FASTLED_FORCE_INLINE uint8_t getScale1() { return getscale<1>(*this); }
473 FASTLED_FORCE_INLINE uint8_t getScale2() { return getscale<2>(*this); }
474
475 #if FASTLED_HD_COLOR_MIXING
476 template<int SLOT> FASTLED_FORCE_INLINE static uint8_t getScaleFullBrightness(PixelController & pc) { return pc.mColorAdjustment.color.raw[RO(SLOT)]; }
477 // Gets the color corection and also the brightness as seperate values.
478 // This is needed for the higher precision chipsets like the APA102.
479 FASTLED_FORCE_INLINE void getHdScale(uint8_t* c0, uint8_t* c1, uint8_t* c2, uint8_t* brightness) {
480 *c0 = getScaleFullBrightness<0>(*this);
481 *c1 = getScaleFullBrightness<1>(*this);
482 *c2 = getScaleFullBrightness<2>(*this);
483 *brightness = mColorAdjustment.brightness;
484 }
485 #endif
486
487
488 FASTLED_FORCE_INLINE void loadAndScale_APA102_HD(uint8_t *b0_out, uint8_t *b1_out,
489 uint8_t *b2_out,
490 uint8_t *brightness_out) {
491 CRGB rgb = CRGB(mData[0], mData[1], mData[2]);
492 uint8_t brightness = 0;
493 if (rgb) {
494 #if FASTLED_HD_COLOR_MIXING
495 brightness = mColorAdjustment.brightness;
497 #else
498 brightness = 255;
499 CRGB scale = mColorAdjustment.premixed;
500 #endif
502 rgb,
503 scale,
505 &rgb,
506 &brightness);
507 }
508 const uint8_t b0_index = RGB_BYTE0(RGB_ORDER);
509 const uint8_t b1_index = RGB_BYTE1(RGB_ORDER);
510 const uint8_t b2_index = RGB_BYTE2(RGB_ORDER);
511 *b0_out = rgb.raw[b0_index];
512 *b1_out = rgb.raw[b1_index];
513 *b2_out = rgb.raw[b2_index];
514 *brightness_out = brightness;
515 }
516
517 FASTLED_FORCE_INLINE void loadAndScaleRGB(uint8_t *b0_out, uint8_t *b1_out,
518 uint8_t *b2_out) {
519 *b0_out = loadAndScale0();
520 *b1_out = loadAndScale1();
521 *b2_out = loadAndScale2();
522 }
523
524 // WS2816B has native 16 bit/channel color and internal 4 bit gamma correction.
525 // So we don't do gamma here, and we don't bother with dithering.
526 FASTLED_FORCE_INLINE void loadAndScale_WS2816_HD(uint16_t *s0_out, uint16_t *s1_out, uint16_t *s2_out) {
527 // Note that the WS2816 has a 4 bit gamma correction built in. To improve things this algorithm may
528 // change in the future with a partial gamma correction that is completed by the chipset gamma
529 // correction.
530 uint16_t r16 = map8_to_16(mData[0]);
531 uint16_t g16 = map8_to_16(mData[1]);
532 uint16_t b16 = map8_to_16(mData[2]);
533 if (r16 || g16 || b16) {
534 #if FASTLED_HD_COLOR_MIXING
535 uint8_t brightness = mColorAdjustment.brightness;
537 #else
538 uint8_t brightness = 255;
539 CRGB scale = mColorAdjustment.premixed;
540 #endif
541 if (scale[0] != 255) {
542 r16 = scale16by8(r16, scale[0]);
543 }
544 if (scale[1] != 255) {
545 g16 = scale16by8(g16, scale[1]);
546 }
547 if (scale[2] != 255) {
548 b16 = scale16by8(b16, scale[2]);
549 }
550 if (brightness != 255) {
551 r16 = scale16by8(r16, brightness);
552 g16 = scale16by8(g16, brightness);
553 b16 = scale16by8(b16, brightness);
554 }
555 }
556 uint16_t rgb16[3] = {r16, g16, b16};
557 const uint8_t s0_index = RGB_BYTE0(RGB_ORDER);
558 const uint8_t s1_index = RGB_BYTE1(RGB_ORDER);
559 const uint8_t s2_index = RGB_BYTE2(RGB_ORDER);
560 *s0_out = rgb16[s0_index];
561 *s1_out = rgb16[s1_index];
562 *s2_out = rgb16[s2_index];
563 }
564
565 FASTLED_FORCE_INLINE void loadAndScaleRGBW(Rgbw rgbw, uint8_t *b0_out, uint8_t *b1_out,
566 uint8_t *b2_out, uint8_t *b3_out) {
567#ifdef __AVR__
568 // Don't do RGBW conversion for AVR, just set the W pixel to black.
569 uint8_t out[4] = {
570 // Get the pixels in native order.
574 0,
575 };
576 EOrderW w_placement = rgbw.w_placement;
577 // Apply w-component insertion.
579 w_placement, out[0], out[1], out[2],
580 0, // Pre-ordered RGB data with a 0 white component.
581 b0_out, b1_out, b2_out, b3_out);
582#else
583 const uint8_t b0_index = RGB_BYTE0(RGB_ORDER); // Needed to re-order RGB back into led native order.
584 const uint8_t b1_index = RGB_BYTE1(RGB_ORDER);
585 const uint8_t b2_index = RGB_BYTE2(RGB_ORDER);
586 // Get the naive RGB data order in r,g,b order.
587 CRGB rgb(mData[0], mData[1], mData[2]);
588 uint8_t w = 0;
589 rgb_2_rgbw(rgbw.rgbw_mode,
590 rgbw.white_color_temp,
591 rgb.r, rgb.g, rgb.b, // Input colors
592 mColorAdjustment.premixed.r, mColorAdjustment.premixed.g, mColorAdjustment.premixed.b, // How these colors are scaled for color balance.
593 &rgb.r, &rgb.g, &rgb.b, &w);
594 // Now finish the ordering so that the output is in the native led order for all of RGBW.
596 rgbw.w_placement,
597 rgb.raw[b0_index], // in-place re-ordering for the RGB data.
598 rgb.raw[b1_index],
599 rgb.raw[b2_index],
600 w, // The white component is not ordered in this call.
601 b0_out, b1_out, b2_out, b3_out); // RGBW data now in total native led order.
602#endif
603 }
604};
605
606
608
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
central include file for FastLED, defines the CFastLED class/object
UISlider brightness("Brightness", 255, 0, 255, 1)
Rgbw rgbw
Defines the red, green, and blue (RGB) pixel struct.
FASTLED_NAMESPACE_BEGIN typedef uint8_t EDitherMode
The dither setting, either DISABLE_DITHER or BINARY_DITHER.
Definition dither_mode.h:16
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Definition dither_mode.h:13
Declares dithering options and types.
EOrderW
Definition eorder.h:24
Defines color channel ordering enumerations.
Declares functions for five-bit gamma correction.
#define FASTLED_FORCE_INLINE
Definition force_inline.h:6
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:31
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...
Definition scale8.h:474
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 ...
Definition scale8.h:40
LIB8STATIC_ALWAYS_INLINE uint16_t map8_to_16(uint8_t x)
Definition intmap.h:25
Defines integer mapping functions.
#define FASTLED_NAMESPACE_END
Definition namespace.h:23
Implements the FastLED namespace macros.
FASTLED_FORCE_INLINE void five_bit_hd_gamma_bitshift(CRGB colors, CRGB colors_scale, uint8_t global_brightness, CRGB *out_colors, uint8_t *out_power_5bit)
#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.
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)
Definition rgbw.cpp:133
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.
Definition rgbw.h:150
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)
Definition crgb.h:55
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 PixelIterator as_iterator(const Rgbw &rgbw)
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()
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>()
Pixel controller class.
Definition rgbw.h:28