FastLED 3.6.0
Loading...
Searching...
No Matches
controller.h
Go to the documentation of this file.
1#ifndef __INC_CONTROLLER_H
2#define __INC_CONTROLLER_H
3
6
7#include "FastLED.h"
8#include "led_sysdefs.h"
9#include "pixeltypes.h"
10#include "color.h"
11#include <stddef.h>
12
13FASTLED_NAMESPACE_BEGIN
14
21#define RO(X) RGB_BYTE(RGB_ORDER, X)
22
29#define RGB_BYTE(RO,X) (((RO)>>(3*(2-(X)))) & 0x3)
30
33#define RGB_BYTE0(RO) ((RO>>6) & 0x3)
36#define RGB_BYTE1(RO) ((RO>>3) & 0x3)
39#define RGB_BYTE2(RO) ((RO) & 0x3)
40
41// operator byte *(struct CRGB[] arr) { return (byte*)arr; }
42
44#define DISABLE_DITHER 0x00
46#define BINARY_DITHER 0x01
48typedef uint8_t EDitherMode;
49
51//
52// LED Controller interface definition
53//
55
62protected:
63 friend class CFastLED;
69 int m_nLeds;
72
77 virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) = 0;
78
83 virtual void show(const struct CRGB *data, int nLeds, CRGB scale) = 0;
84
85public:
88 m_pNext = NULL;
89 if(m_pHead==NULL) { m_pHead = this; }
90 if(m_pTail != NULL) { m_pTail->m_pNext = this; }
91 m_pTail = this;
92 }
93
95 virtual void init() = 0;
96
99 virtual void clearLeds(int nLeds) { showColor(CRGB::Black, nLeds, CRGB::Black); }
100
108 void show(const struct CRGB *data, int nLeds, uint8_t brightness) {
109 show(data, nLeds, getAdjustment(brightness));
110 }
111
119 void showColor(const struct CRGB &data, int nLeds, uint8_t brightness) {
120 showColor(data, nLeds, getAdjustment(brightness));
121 }
122
126 void showLeds(uint8_t brightness=255) {
127 show(m_Data, m_nLeds, getAdjustment(brightness));
128 }
129
135 void showColor(const struct CRGB & data, uint8_t brightness=255) {
136 showColor(data, m_nLeds, getAdjustment(brightness));
137 }
138
141 static CLEDController *head() { return m_pHead; }
142
146
150 CLEDController & setLeds(CRGB *data, int nLeds) {
151 m_Data = data;
152 m_nLeds = nLeds;
153 return *this;
154 }
155
158 if(m_Data) {
159 memset8((void*)m_Data, 0, sizeof(struct CRGB) * m_nLeds);
160 }
161 }
162
165 virtual int size() { return m_nLeds; }
166
169 virtual int lanes() { return 1; }
170
173 CRGB* leds() { return m_Data; }
174
178 CRGB &operator[](int x) { return m_Data[x]; }
179
183 inline CLEDController & setDither(uint8_t ditherMode = BINARY_DITHER) { m_DitherMode = ditherMode; return *this; }
184
187 inline uint8_t getDither() { return m_DitherMode; }
188
192 CLEDController & setCorrection(CRGB correction) { m_ColorCorrection = correction; return *this; }
193
195 CLEDController & setCorrection(LEDColorCorrection correction) { m_ColorCorrection = correction; return *this; }
196
200
204 CLEDController & setTemperature(CRGB temperature) { m_ColorTemperature = temperature; return *this; }
205
207 CLEDController & setTemperature(ColorTemperature temperature) { m_ColorTemperature = temperature; return *this; }
208
212
216 CRGB getAdjustment(uint8_t scale) {
218 }
219
225 static CRGB computeAdjustment(uint8_t scale, const CRGB & colorCorrection, const CRGB & colorTemperature) {
226 #if defined(NO_CORRECTION) && (NO_CORRECTION==1)
227 return CRGB(scale,scale,scale);
228 #else
229 CRGB adj(0,0,0);
230
231 if(scale > 0) {
232 for(uint8_t i = 0; i < 3; ++i) {
233 uint8_t cc = colorCorrection.raw[i];
234 uint8_t ct = colorTemperature.raw[i];
235 if(cc > 0 && ct > 0) {
236 uint32_t work = (((uint32_t)cc)+1) * (((uint32_t)ct)+1) * scale;
237 work /= 0x10000L;
238 adj.raw[i] = work & 0xFF;
239 }
240 }
241 }
242
243 return adj;
244 #endif
245 }
246
249 virtual uint16_t getMaxRefreshRate() const { return 0; }
250};
251
258template<EOrder RGB_ORDER, int LANES=1, uint32_t MASK=0xFFFFFFFF>
260 const uint8_t *mData;
261 int mLen;
263 uint8_t d[3];
264 uint8_t e[3];
266 int8_t mAdvance;
267 int mOffsets[LANES];
268
272 d[0] = other.d[0];
273 d[1] = other.d[1];
274 d[2] = other.d[2];
275 e[0] = other.e[0];
276 e[1] = other.e[1];
277 e[2] = other.e[2];
278 mData = other.mData;
279 mScale = other.mScale;
280 mAdvance = other.mAdvance;
281 mLenRemaining = mLen = other.mLen;
282 for(int i = 0; i < LANES; ++i) { mOffsets[i] = other.mOffsets[i]; }
283 }
284
287 void initOffsets(int len) {
288 int nOffset = 0;
289 for(int i = 0; i < LANES; ++i) {
290 mOffsets[i] = nOffset;
291 if((1<<i) & MASK) { nOffset += (len * mAdvance); }
292 }
293 }
294
302 PixelController(const uint8_t *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER, bool advance=true, uint8_t skip=0) : mData(d), mLen(len), mLenRemaining(len), mScale(s) {
304 mData += skip;
305 mAdvance = (advance) ? 3+skip : 0;
306 initOffsets(len);
307 }
308
314 PixelController(const CRGB *d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)d), mLen(len), mLenRemaining(len), mScale(s) {
316 mAdvance = 3;
317 initOffsets(len);
318 }
319
325 PixelController(const CRGB &d, int len, CRGB & s, EDitherMode dither = BINARY_DITHER) : mData((const uint8_t*)&d), mLen(len), mLenRemaining(len), mScale(s) {
327 mAdvance = 0;
328 initOffsets(len);
329 }
330
331
332#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
333
335#define MAX_LIKELY_UPDATE_RATE_HZ 400
336
338#define MIN_ACCEPTABLE_DITHER_RATE_HZ 50
339
341#define UPDATES_PER_FULL_DITHER_CYCLE (MAX_LIKELY_UPDATE_RATE_HZ / MIN_ACCEPTABLE_DITHER_RATE_HZ)
342
356#define RECOMMENDED_VIRTUAL_BITS ((UPDATES_PER_FULL_DITHER_CYCLE>1) + \
357 (UPDATES_PER_FULL_DITHER_CYCLE>2) + \
358 (UPDATES_PER_FULL_DITHER_CYCLE>4) + \
359 (UPDATES_PER_FULL_DITHER_CYCLE>8) + \
360 (UPDATES_PER_FULL_DITHER_CYCLE>16) + \
361 (UPDATES_PER_FULL_DITHER_CYCLE>32) + \
362 (UPDATES_PER_FULL_DITHER_CYCLE>64) + \
363 (UPDATES_PER_FULL_DITHER_CYCLE>128) )
364
366#define VIRTUAL_BITS RECOMMENDED_VIRTUAL_BITS
367
368#endif
369
370
373#if !defined(NO_DITHERING) || (NO_DITHERING != 1)
374 // R is the digther signal 'counter'.
375 static uint8_t R = 0;
376 ++R;
377
378 // R is wrapped around at 2^ditherBits,
379 // so if ditherBits is 2, R will cycle through (0,1,2,3)
380 uint8_t ditherBits = VIRTUAL_BITS;
381 R &= (0x01 << ditherBits) - 1;
382
383 // Q is the "unscaled dither signal" itself.
384 // It's initialized to the reversed bits of R.
385 // If 'ditherBits' is 2, Q here will cycle through (0,128,64,192)
386 uint8_t Q = 0;
387
388 // Reverse bits in a byte
389 {
390 if(R & 0x01) { Q |= 0x80; }
391 if(R & 0x02) { Q |= 0x40; }
392 if(R & 0x04) { Q |= 0x20; }
393 if(R & 0x08) { Q |= 0x10; }
394 if(R & 0x10) { Q |= 0x08; }
395 if(R & 0x20) { Q |= 0x04; }
396 if(R & 0x40) { Q |= 0x02; }
397 if(R & 0x80) { Q |= 0x01; }
398 }
399
400 // Now we adjust Q to fall in the center of each range,
401 // instead of at the start of the range.
402 // If ditherBits is 2, Q will be (0, 128, 64, 192) at first,
403 // and this adjustment makes it (31, 159, 95, 223).
404 if( ditherBits < 8) {
405 Q += 0x01 << (7 - ditherBits);
406 }
407
408 // D and E form the "scaled dither signal"
409 // which is added to pixel values to affect the
410 // actual dithering.
411
412 // Setup the initial D and E values
413 for(int i = 0; i < 3; ++i) {
414 uint8_t s = mScale.raw[i];
415 e[i] = s ? (256/s) + 1 : 0;
416 d[i] = scale8(Q, e[i]);
417#if (FASTLED_SCALE8_FIXED == 1)
418 if(d[i]) (--d[i]);
419#endif
420 if(e[i]) --e[i];
421 }
422#endif
423 }
424
428 __attribute__((always_inline)) inline bool has(int n) {
429 return mLenRemaining >= n;
430 }
431
438 switch(dither) {
440 default: d[0]=d[1]=d[2]=e[0]=e[1]=e[2]=0; break;
441 }
442 }
443
446 __attribute__((always_inline)) inline int size() { return mLen; }
447
450 __attribute__((always_inline)) inline int lanes() { return LANES; }
451
454 __attribute__((always_inline)) inline int advanceBy() { return mAdvance; }
455
457 __attribute__((always_inline)) inline void advanceData() { mData += mAdvance; --mLenRemaining;}
458
461 __attribute__((always_inline)) inline void stepDithering() {
462 // IF UPDATING HERE, BE SURE TO UPDATE THE ASM VERSION IN
463 // clockless_trinket.h!
464 d[0] = e[0] - d[0];
465 d[1] = e[1] - d[1];
466 d[2] = e[2] - d[2];
467 }
468
470 __attribute__((always_inline)) inline void preStepFirstByteDithering() {
471 d[RO(0)] = e[RO(0)] - d[RO(0)];
472 }
473
477
481 template<int SLOT> __attribute__((always_inline)) inline static uint8_t loadByte(PixelController & pc) { return pc.mData[RO(SLOT)]; }
486 template<int SLOT> __attribute__((always_inline)) inline static uint8_t loadByte(PixelController & pc, int lane) { return pc.mData[pc.mOffsets[lane] + RO(SLOT)]; }
487
493 template<int SLOT> __attribute__((always_inline)) inline static uint8_t dither(PixelController & pc, uint8_t b) { return b ? qadd8(b, pc.d[RO(SLOT)]) : 0; }
498 template<int SLOT> __attribute__((always_inline)) inline static uint8_t dither(PixelController & , uint8_t b, uint8_t d) { return b ? qadd8(b,d) : 0; }
499
505 template<int SLOT> __attribute__((always_inline)) inline static uint8_t scale(PixelController & pc, uint8_t b) { return scale8(b, pc.mScale.raw[RO(SLOT)]); }
510 template<int SLOT> __attribute__((always_inline)) inline static uint8_t scale(PixelController & , uint8_t b, uint8_t scale) { return scale8(b, scale); }
511
517
518
522 template<int SLOT> __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc) { return scale<SLOT>(pc, pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc))); }
523
528 template<int SLOT> __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc, int lane) { return scale<SLOT>(pc, pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc, lane))); }
529
536 template<int SLOT> __attribute__((always_inline)) 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); }
537
543 template<int SLOT> __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc, int lane, uint8_t scale) { return scale8(pc.loadByte<SLOT>(pc, lane), scale); }
544
545
548 template<int SLOT> __attribute__((always_inline)) inline static uint8_t advanceAndLoadAndScale(PixelController & pc) { pc.advanceData(); return pc.loadAndScale<SLOT>(pc); }
549
553 template<int SLOT> __attribute__((always_inline)) inline static uint8_t advanceAndLoadAndScale(PixelController & pc, int lane) { pc.advanceData(); return pc.loadAndScale<SLOT>(pc, lane); }
554
559 template<int SLOT> __attribute__((always_inline)) inline static uint8_t advanceAndLoadAndScale(PixelController & pc, int lane, uint8_t scale) { pc.advanceData(); return pc.loadAndScale<SLOT>(pc, lane, scale); }
560
562
563
568
574 template<int SLOT> __attribute__((always_inline)) inline static uint8_t getd(PixelController & pc) { return pc.d[RO(SLOT)]; }
575
581 template<int SLOT> __attribute__((always_inline)) inline static uint8_t getscale(PixelController & pc) { return pc.mScale.raw[RO(SLOT)]; }
582
584
585
587
588 // Helper functions to get around gcc stupidities
589 __attribute__((always_inline)) inline uint8_t loadAndScale0(int lane, uint8_t scale) { return loadAndScale<0>(*this, lane, scale); }
590 __attribute__((always_inline)) inline uint8_t loadAndScale1(int lane, uint8_t scale) { return loadAndScale<1>(*this, lane, scale); }
591 __attribute__((always_inline)) inline uint8_t loadAndScale2(int lane, uint8_t scale) { return loadAndScale<2>(*this, lane, scale); }
592 __attribute__((always_inline)) inline uint8_t advanceAndLoadAndScale0(int lane, uint8_t scale) { return advanceAndLoadAndScale<0>(*this, lane, scale); }
593 __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0(int lane, uint8_t scale) { stepDithering(); return advanceAndLoadAndScale<0>(*this, lane, scale); }
594
595 __attribute__((always_inline)) inline uint8_t loadAndScale0(int lane) { return loadAndScale<0>(*this, lane); }
596 __attribute__((always_inline)) inline uint8_t loadAndScale1(int lane) { return loadAndScale<1>(*this, lane); }
597 __attribute__((always_inline)) inline uint8_t loadAndScale2(int lane) { return loadAndScale<2>(*this, lane); }
598 __attribute__((always_inline)) inline uint8_t advanceAndLoadAndScale0(int lane) { return advanceAndLoadAndScale<0>(*this, lane); }
599 __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0(int lane) { stepDithering(); return advanceAndLoadAndScale<0>(*this, lane); }
600
601 __attribute__((always_inline)) inline uint8_t loadAndScale0() { return loadAndScale<0>(*this); }
602 __attribute__((always_inline)) inline uint8_t loadAndScale1() { return loadAndScale<1>(*this); }
603 __attribute__((always_inline)) inline uint8_t loadAndScale2() { return loadAndScale<2>(*this); }
604 __attribute__((always_inline)) inline uint8_t advanceAndLoadAndScale0() { return advanceAndLoadAndScale<0>(*this); }
605 __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0() { stepDithering(); return advanceAndLoadAndScale<0>(*this); }
606
607 __attribute__((always_inline)) inline uint8_t getScale0() { return getscale<0>(*this); }
608 __attribute__((always_inline)) inline uint8_t getScale1() { return getscale<1>(*this); }
609 __attribute__((always_inline)) inline uint8_t getScale2() { return getscale<2>(*this); }
610};
611
616template<EOrder RGB_ORDER, int LANES=1, uint32_t MASK=0xFFFFFFFF> class CPixelLEDController : public CLEDController {
617protected:
621
626 virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) {
627 PixelController<RGB_ORDER, LANES, MASK> pixels(data, nLeds, scale, getDither());
628 showPixels(pixels);
629 }
630
635 virtual void show(const struct CRGB *data, int nLeds, CRGB scale) {
636 PixelController<RGB_ORDER, LANES, MASK> pixels(data, nLeds < 0 ? -nLeds : nLeds, scale, getDither());
637 if(nLeds < 0) {
638 // nLeds < 0 implies that we want to show them in reverse
639 pixels.mAdvance = -pixels.mAdvance;
640 }
641 showPixels(pixels);
642 }
643
644public:
646
649 int lanes() { return LANES; }
650};
651
652
653FASTLED_NAMESPACE_END
654
655#endif
central include file for FastLED, defines the CFastLED class/object
High level controller interface for FastLED.
Definition FastLED.h:221
Base definition for an LED controller.
Definition controller.h:61
virtual void showColor(const struct CRGB &data, int nLeds, CRGB scale)=0
Set all the LEDs to a given color.
CLEDController & setTemperature(ColorTemperature temperature)
Set the color temperature, aka white point, for this controller.
Definition controller.h:207
CRGB getCorrection()
Get the correction value used by this controller.
Definition controller.h:199
CLEDController * next()
Get the next controller in the linked list after this one.
Definition controller.h:145
void showColor(const struct CRGB &data, int nLeds, uint8_t brightness)
Set all the LEDs to a given color.
Definition controller.h:119
CLEDController & setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode for this controller to use.
Definition controller.h:183
virtual int lanes()
How many Lanes does this controller manage?
Definition controller.h:169
static CRGB computeAdjustment(uint8_t scale, const CRGB &colorCorrection, const CRGB &colorTemperature)
Calculates the combined color adjustment to the LEDs at a given scale, color correction,...
Definition controller.h:225
virtual uint16_t getMaxRefreshRate() const
Gets the maximum possible refresh rate of the strip.
Definition controller.h:249
CRGB * m_Data
pointer to the LED data used by this controller
Definition controller.h:64
CRGB & operator[](int x)
Reference to the n'th LED managed by the controller.
Definition controller.h:178
void showColor(const struct CRGB &data, uint8_t brightness=255)
Set all the LEDs to a given color.
Definition controller.h:135
CRGB m_ColorCorrection
CRGB object representing the color correction to apply to the strip on show()
Definition controller.h:66
virtual int size()
How many LEDs does this controller manage?
Definition controller.h:165
uint8_t getDither()
Get the dithering option currently set for this controller.
Definition controller.h:187
CLEDController & setLeds(CRGB *data, int nLeds)
Set the default array of LEDs to be used by this controller.
Definition controller.h:150
void clearLedData()
Zero out the LED data managed by this controller.
Definition controller.h:157
CLEDController & setCorrection(CRGB correction)
The color corrction to use for this controller, expressed as a CRGB object.
Definition controller.h:192
static CLEDController * head()
Get the first LED controller in the linked list of controllers.
Definition controller.h:141
CLEDController()
Create an led controller object, add it to the chain of controllers.
Definition controller.h:87
EDitherMode m_DitherMode
the current dither mode of the controller
Definition controller.h:68
CLEDController & setTemperature(CRGB temperature)
Set the color temperature, aka white point, for this controller.
Definition controller.h:204
void showLeds(uint8_t brightness=255)
Write the data to the LEDs managed by this controller.
Definition controller.h:126
CRGB * leds()
Pointer to the CRGB array for this controller.
Definition controller.h:173
CLEDController * m_pNext
pointer to the next LED controller in the linked list
Definition controller.h:65
int m_nLeds
the number of LEDs in the LED data array
Definition controller.h:69
static CLEDController * m_pTail
pointer to the last LED controller in the linked list
Definition controller.h:71
virtual void clearLeds(int nLeds)
Clear out/zero out the given number of LEDs.
Definition controller.h:99
void show(const struct CRGB *data, int nLeds, uint8_t brightness)
Write the passed in RGB data out to the LEDs managed by this controller.
Definition controller.h:108
CLEDController & setCorrection(LEDColorCorrection correction)
The color corrction to use for this controller, expressed as a CRGB object.
Definition controller.h:195
CRGB m_ColorTemperature
CRGB object representing the color temperature to apply to the strip on show()
Definition controller.h:67
virtual void show(const struct CRGB *data, int nLeds, CRGB scale)=0
Write the passed in RGB data out to the LEDs managed by this controller.
CRGB getAdjustment(uint8_t scale)
Get the combined brightness/color adjustment for this controller.
Definition controller.h:216
virtual void init()=0
Initialize the LED controller.
static CLEDController * m_pHead
pointer to the first LED controller in the linked list
Definition controller.h:70
CRGB getTemperature()
Get the color temperature, aka whipe point, for this controller.
Definition controller.h:211
Template extension of the CLEDController class.
Definition controller.h:616
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels)=0
Send the LED data to the strip.
int lanes()
Get the number of lanes of the Controller.
Definition controller.h:649
virtual void show(const struct CRGB *data, int nLeds, CRGB scale)
Write the passed in RGB data out to the LEDs managed by this controller.
Definition controller.h:635
virtual void showColor(const struct CRGB &data, int nLeds, CRGB scale)
Set all the LEDs on the controller to a given color.
Definition controller.h:626
Contains definitions for color correction and temperature.
#define VIRTUAL_BITS
Alias for RECOMMENDED_VIRTUAL_BITS.
Definition controller.h:366
uint8_t EDitherMode
The dither setting, either DISABLE_DITHER or BINARY_DITHER.
Definition controller.h:48
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Definition controller.h:46
#define RO(X)
Gets the assigned color channel for a byte's position in the output, using the color order (EOrder) t...
Definition controller.h:21
ColorTemperature
Color temperature values.
Definition color.h:47
LEDColorCorrection
Color correction starting points.
Definition color.h:16
@ UncorrectedTemperature
Uncorrected temperature (0xFFFFFF)
Definition color.h:95
@ UncorrectedColor
Uncorrected color (0xFFFFFF)
Definition color.h:29
void * memset8(void *ptr, uint8_t value, uint16_t num)
Faster alternative to memset() on AVR.
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:28
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:30
Determines which platform system definitions to include.
Definitions for pixel color data structs.
Representation of an RGB pixel (Red, Green, Blue)
Definition pixeltypes.h:120
uint8_t raw[3]
Access the red, green, and blue data as an array.
Definition pixeltypes.h:141
@ Black
Definition pixeltypes.h:672
Pixel controller class.
Definition controller.h:259
int8_t mAdvance
how many bytes to advance the pointer by each time. For CRGB this is 3.
Definition controller.h:266
uint8_t getScale1()
non-template alias of getscale<1>()
Definition controller.h:608
uint8_t stepAdvanceAndLoadAndScale0(int lane, uint8_t scale)
stepDithering() and advanceAndLoadAndScale0()
Definition controller.h:593
uint8_t loadAndScale0()
non-template alias of loadAndScale<0>()
Definition controller.h:601
static uint8_t dither(PixelController &pc, uint8_t b)
Calculate a dither value using the per-channel dither data.
Definition controller.h:493
uint8_t stepAdvanceAndLoadAndScale0(int lane)
stepDithering() and advanceAndLoadAndScale0()
Definition controller.h:599
void init_binary_dithering()
Set up the values for binary dithering.
Definition controller.h:372
int mLenRemaining
counter for the number of LEDs left to process
Definition controller.h:262
void stepDithering()
Step the dithering forward.
Definition controller.h:461
uint8_t loadAndScale0(int lane, uint8_t scale)
non-template alias of loadAndScale<0>()
Definition controller.h:589
void initOffsets(int len)
Initialize the PixelController::mOffsets array based on the length of the strip.
Definition controller.h:287
static uint8_t advanceAndLoadAndScale(PixelController &pc)
A version of loadAndScale() that advances the output data pointer.
Definition controller.h:548
static uint8_t getscale(PixelController &pc)
Gets the scale data for the provided output slot.
Definition controller.h:581
static uint8_t scale(PixelController &, uint8_t b, uint8_t scale)
Scale a value.
Definition controller.h:510
void preStepFirstByteDithering()
Some chipsets pre-cycle the first byte, which means we want to cycle byte 0's dithering separately.
Definition controller.h:470
const uint8_t * mData
pointer to the underlying LED data
Definition controller.h:260
PixelController(const CRGB *d, int len, CRGB &s, EDitherMode dither=BINARY_DITHER)
Constructor.
Definition controller.h:314
uint8_t d[3]
values for the scaled dither signal
Definition controller.h:263
int mOffsets[LANES]
the number of bytes to offset each lane from the starting pointer
Definition controller.h:267
void advanceData()
Advance the data pointer forward, adjust position counter.
Definition controller.h:457
int size()
Get the length of the LED strip.
Definition controller.h:446
static 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.
Definition controller.h:536
uint8_t loadAndScale1(int lane, uint8_t scale)
non-template alias of loadAndScale<1>()
Definition controller.h:590
int mLen
number of LEDs in the data for one lane
Definition controller.h:261
uint8_t getScale0()
non-template alias of getscale<0>()
Definition controller.h:607
static uint8_t dither(PixelController &, uint8_t b, uint8_t d)
Calculate a dither value.
Definition controller.h:498
static uint8_t advanceAndLoadAndScale(PixelController &pc, int lane)
A version of loadAndScale() that advances the output data pointer.
Definition controller.h:553
static uint8_t loadAndScale(PixelController &pc, int lane, uint8_t scale)
Loads and scales a single byte for a given output slot and lane.
Definition controller.h:543
PixelController(const CRGB &d, int len, CRGB &s, EDitherMode dither=BINARY_DITHER)
Constructor.
Definition controller.h:325
PixelController(const uint8_t *d, int len, CRGB &s, EDitherMode dither=BINARY_DITHER, bool advance=true, uint8_t skip=0)
Constructor.
Definition controller.h:302
static uint8_t loadAndScale(PixelController &pc)
Loads, dithers, and scales a single byte for a given output slot, using class dither and scale values...
Definition controller.h:522
uint8_t stepAdvanceAndLoadAndScale0()
stepDithering() and advanceAndLoadAndScale0()
Definition controller.h:605
uint8_t e[3]
values for the scaled dither signal
Definition controller.h:264
CRGB mScale
the per-channel scale values, provided by a color correction function such as CLEDController::compute...
Definition controller.h:265
void enable_dithering(EDitherMode dither)
Toggle dithering enable If dithering is set to enabled, this will re-init the dithering values (init_...
Definition controller.h:437
uint8_t advanceAndLoadAndScale0(int lane)
non-template alias of advanceAndLoadAndScale<0>()
Definition controller.h:598
int lanes()
Get the number of lanes of the Controller.
Definition controller.h:450
uint8_t loadAndScale1()
non-template alias of loadAndScale<1>()
Definition controller.h:602
static uint8_t scale(PixelController &pc, uint8_t b)
Scale a value using the per-channel scale data.
Definition controller.h:505
uint8_t loadAndScale2(int lane, uint8_t scale)
non-template alias of loadAndScale<2>()
Definition controller.h:591
int advanceBy()
Get the amount to advance the pointer by.
Definition controller.h:454
uint8_t loadAndScale0(int lane)
non-template alias of loadAndScale<0>()
Definition controller.h:595
uint8_t loadAndScale1(int lane)
non-template alias of loadAndScale<1>()
Definition controller.h:596
static uint8_t loadByte(PixelController &pc, int lane)
Read a byte of LED data for parallel output.
Definition controller.h:486
uint8_t loadAndScale2()
non-template alias of loadAndScale<2>()
Definition controller.h:603
uint8_t advanceAndLoadAndScale0()
non-template alias of advanceAndLoadAndScale<0>()
Definition controller.h:604
static uint8_t getd(PixelController &pc)
Gets the dithering data for the provided output slot.
Definition controller.h:574
static 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...
Definition controller.h:528
uint8_t getScale2()
non-template alias of getscale<2>()
Definition controller.h:609
PixelController(const PixelController &other)
Copy constructor.
Definition controller.h:271
bool has(int n)
Do we have n pixels left to process?
Definition controller.h:428
uint8_t advanceAndLoadAndScale0(int lane, uint8_t scale)
non-template alias of advanceAndLoadAndScale<0>()
Definition controller.h:592
static uint8_t advanceAndLoadAndScale(PixelController &pc, int lane, uint8_t scale)
A version of loadAndScale() that advances the output data pointer without dithering.
Definition controller.h:559
static uint8_t loadByte(PixelController &pc)
Read a byte of LED data.
Definition controller.h:481
uint8_t loadAndScale2(int lane)
non-template alias of loadAndScale<2>()
Definition controller.h:597