FastLED 3.9.15
Loading...
Searching...
No Matches
chipsets.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef __INC_CHIPSETS_H
4#define __INC_CHIPSETS_H
5
6#include "pixeltypes.h"
8#include "fl/force_inline.h"
9#include "fl/bit_cast.h"
10#include "pixel_iterator.h"
11#include "crgb.h"
12#include "eorder.h"
13#include "fl/namespace.h"
14#include "fl/math_macros.h"
15
16// Conditional namespace handling for WASM builds
17#ifdef FASTLED_FORCE_NAMESPACE
18#define FASTLED_CLOCKLESS_CONTROLLER fl::ClocklessController
19#else
20#define FASTLED_CLOCKLESS_CONTROLLER ClocklessController
21#endif
22
23#ifndef FASTLED_CLOCKLESS_USES_NANOSECONDS
24 #if defined(FASTLED_TEENSY4)
25 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 1
26 #elif defined(ESP32)
28 // RMT 5.1 driver converts from nanoseconds to RMT ticks.
29 #if FASTLED_RMT5
30 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 1
31 #else
32 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 0
33 #endif
34 #else
35 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 0
36 #endif // FASTLED_TEENSY4
37#endif // FASTLED_CLOCKLESS_USES_NANOSECONDS
38
39
40// Allow overclocking of the clockless family of leds. 1.2 would be
41// 20% overclocking. In tests WS2812 can be overclocked at 20%, but
42// various manufacturers may be different. This is a global value
43// which is overridable by each supported chipset.
44#ifdef FASTLED_LED_OVERCLOCK
45#warning "FASTLED_LED_OVERCLOCK has been changed to FASTLED_OVERCLOCK. Please update your code."
46#define FASTLED_OVERCLOCK FASTLED_LED_OVERCLOCK
47#endif
48
49#ifndef FASTLED_OVERCLOCK
50#define FASTLED_OVERCLOCK 1.0
51#else
52#ifndef FASTLED_OVERCLOCK_SUPPRESS_WARNING
53#warning "FASTLED_OVERCLOCK is now active, #define FASTLED_OVERCLOCK_SUPPRESS_WARNING to disable this warning"
54#endif
55#endif
56
57// So many platforms have specialized WS2812 controllers. Why? Because they
58// are the cheapest chipsets use. So we special case this.
59#include "platforms/chipsets_specialized_ws2812.h"
60
63
64
65
70
71#if defined(ARDUINO) //&& defined(SoftwareSerial_h)
72
73
74#if defined(SoftwareSerial_h) || defined(__SoftwareSerial_h)
75#include <SoftwareSerial.h>
76
77#define HAS_PIXIE
78
80
84template<fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
85class PixieController : public CPixelLEDController<RGB_ORDER> {
86 SoftwareSerial Serial;
87 CMinWait<2000> mWait;
88
89public:
90 PixieController() : Serial(-1, DATA_PIN) {}
91
92protected:
94 virtual void init() {
95 Serial.begin(115200);
96 mWait.mark();
97 }
98
100 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
101 mWait.wait();
102 while(pixels.has(1)) {
103 fl::u8 r = pixels.loadAndScale0();
104 Serial.write(r);
105 fl::u8 g = pixels.loadAndScale1();
106 Serial.write(g);
107 fl::u8 b = pixels.loadAndScale2();
108 Serial.write(b);
109 pixels.advanceData();
110 pixels.stepDithering();
111 }
112 mWait.mark();
113 }
114
115};
116
117// template<SoftwareSerial & STREAM, EOrder RGB_ORDER = RGB>
118// class PixieController : public PixieBaseController<STREAM, RGB_ORDER> {
119// public:
120// virtual void init() {
121// STREAM.begin(115200);
122// }
123// };
124
126#endif
127#endif
128
129// Emulution layer to support RGBW leds on RGB controllers. This works by creating
130// a side buffer dedicated for the RGBW data. The RGB data is then converted to RGBW
131// and sent to the delegate controller for rendering as if it were RGB data.
133
134template <
135 typename CONTROLLER,
136 EOrder RGB_ORDER = GRB> // Default on WS2812>
138 : public CPixelLEDController<RGB_ORDER, CONTROLLER::LANES_VALUE,
139 CONTROLLER::MASK_VALUE> {
140 public:
141 // ControllerT is a helper class. It subclasses the device controller class
142 // and has three methods to call the three protected methods we use.
143 // This is janky, but redeclaring public methods protected in a derived class
144 // is janky, too.
145
146 // N.B., byte order must be RGB.
147 typedef CONTROLLER ControllerBaseT;
148 class ControllerT : public CONTROLLER {
149 friend class RGBWEmulatedController<CONTROLLER, RGB_ORDER>;
150 void *callBeginShowLeds(int size) { return ControllerBaseT::beginShowLeds(size); }
151 void callShow(CRGB *data, int nLeds, fl::u8 brightness) {
152 ControllerBaseT::show(data, nLeds, brightness);
153 }
154 void callEndShowLeds(void *data) { ControllerBaseT::endShowLeds(data); }
155 };
156
157
158 static const int LANES = CONTROLLER::LANES_VALUE;
159 static const uint32_t MASK = CONTROLLER::MASK_VALUE;
160
161 // The delegated controller must do no reordering.
162 static_assert(RGB == CONTROLLER::RGB_ORDER_VALUE, "The delegated controller MUST NOT do reordering");
163
165 this->setRgbw(rgbw);
166 };
168
169 virtual void *beginShowLeds(int size) override {
170 return mController.callBeginShowLeds(Rgbw::size_as_rgb(size));
171 }
172
173 virtual void endShowLeds(void *data) override {
174 return mController.callEndShowLeds(data);
175 }
176
178 // Ensure buffer is large enough
179 ensureBuffer(pixels.size());
180 Rgbw rgbw = this->getRgbw();
182 while (pixels.has(1)) {
183 pixels.stepDithering();
184 pixels.loadAndScaleRGBW(rgbw, data, data + 1, data + 2, data + 3);
185 data += 4;
186 pixels.advanceData();
187 }
188
189 // Force the device controller to a state where it passes data through
190 // unmodified: color correction, color temperature, dither, and brightness
191 // (passed as an argument to show()). Temporarily enable the controller,
192 // show the LEDs, and disable it again.
193 //
194 // The device controller is in the global controller list, so if we
195 // don't keep it disabled, it will refresh again with unknown brightness,
196 // temperature, etc.
197
198 mController.setCorrection(CRGB(255, 255, 255));
199 mController.setTemperature(CRGB(255, 255, 255));
200 mController.setDither(DISABLE_DITHER);
201
202 mController.setEnabled(true);
203 mController.callShow(mRGBWPixels, Rgbw::size_as_rgb(pixels.size()), 255);
204 mController.setEnabled(false);
205 }
206
207 private:
208 // Needed by the interface.
209 void init() override {
210 mController.init();
211 mController.setEnabled(false);
212 }
213
214 void ensureBuffer(int32_t num_leds) {
215 if (num_leds != mNumRGBLeds) {
216 mNumRGBLeds = num_leds;
217 // The delegate controller expects the raw pixel byte data in multiples of 3.
218 // In the case of src data not a multiple of 3, then we need to
219 // add pad bytes so that the delegate controller doesn't walk off the end
220 // of the array and invoke a buffer overflow panic.
221 uint32_t new_size = Rgbw::size_as_rgb(num_leds);
222 delete[] mRGBWPixels;
223 mRGBWPixels = new CRGB[new_size];
224 // showPixels may never clear the last two pixels.
225 for (uint32_t i = 0; i < new_size; i++) {
226 mRGBWPixels[i] = CRGB(0, 0, 0);
227 }
228
229 mController.setLeds(mRGBWPixels, new_size);
230 }
231 }
232
233 CRGB *mRGBWPixels = nullptr;
234 int32_t mNumRGBLeds = 0;
235 int32_t mNumRGBWLeds = 0;
236 ControllerT mController; // Real controller.
237};
238
242
244//
245// LPD8806 controller class - takes data/clock/select pin values (N.B. should take an SPI definition?)
246//
248
254template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(12) >
255class LPD8806Controller : public CPixelLEDController<RGB_ORDER> {
257
259 public:
260 // LPD8806 spec wants the high bit of every rgb data byte sent out to be set.
261 FASTLED_FORCE_INLINE static fl::u8 adjust(FASTLED_REGISTER fl::u8 data) { return ((data>>1) | 0x80) + ((data && (data<254)) & 0x01); }
262 FASTLED_FORCE_INLINE static void postBlock(int len, void* context = NULL) {
263 SPI* pSPI = static_cast<SPI*>(context);
264 pSPI->writeBytesValueRaw(0, ((len*3+63)>>6));
265 }
266
267 };
268
270
271public:
273 virtual void init() {
274 mSPI.init();
275 }
276
277protected:
278
280 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
281 mSPI.template writePixels<0, LPD8806_ADJUST, RGB_ORDER>(pixels, &mSPI);
282 }
283};
284
285
287//
288// WS2801 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
289//
291
297template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(1)>
298class WS2801Controller : public CPixelLEDController<RGB_ORDER> {
302
303public:
305
307 virtual void init() {
308 mSPI.init();
309 mWaitDelay.mark();
310 }
311
312protected:
313
315 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
316 mWaitDelay.wait();
317 mSPI.template writePixels<0, DATA_NOP, RGB_ORDER>(pixels, NULL);
318 mWaitDelay.mark();
319 }
320};
321
324template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(25)>
325class WS2803Controller : public WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {};
326
335template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(12)>
336class LPD6803Controller : public CPixelLEDController<RGB_ORDER> {
339
340 void startBoundary() { mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); }
341 void endBoundary(int nLeds) { int nDWords = (nLeds/32); do { mSPI.writeByte(0xFF); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nDWords--); }
342
343public:
345
346 virtual void init() {
347 mSPI.init();
348 }
349
350protected:
352 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
353 mSPI.select();
354
356 while(pixels.has(1)) {
357 FASTLED_REGISTER fl::u16 command;
358 command = 0x8000;
359 command |= (pixels.loadAndScale0() & 0xF8) << 7; // red is the high 5 bits
360 command |= (pixels.loadAndScale1() & 0xF8) << 2; // green is the middle 5 bits
361 mSPI.writeByte((command >> 8) & 0xFF);
362 command |= pixels.loadAndScale2() >> 3 ; // blue is the low 5 bits
363 mSPI.writeByte(command & 0xFF);
364
365 pixels.stepDithering();
366 pixels.advanceData();
367 }
368 endBoundary(pixels.size());
369 mSPI.waitFully();
370 mSPI.release();
371 }
372
373};
374
376//
377// APA102 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
378//
380
386template <
388 EOrder RGB_ORDER = RGB,
389 // APA102 has a bug where long strip can't handle full speed due to clock degredation.
390 // This only affects long strips, but then again if you have a short strip does 6 mhz actually slow
391 // you down? Probably not. And you can always bump it up for speed. Therefore we are prioritizing
392 // "just works" over "fastest possible" here.
393 // https://www.pjrc.com/why-apa102-leds-have-trouble-at-24-mhz/
394 uint32_t SPI_SPEED = DATA_RATE_MHZ(6),
396 uint32_t START_FRAME = 0x00000000,
397 uint32_t END_FRAME = 0xFF000000
398>
399class APA102Controller : public CPixelLEDController<RGB_ORDER> {
402
404 mSPI.writeWord(START_FRAME >> 16);
405 mSPI.writeWord(START_FRAME & 0xFFFF);
406 }
407 void endBoundary(int nLeds) {
408 int nDWords = (nLeds/32);
409 const fl::u8 b0 = fl::u8(END_FRAME >> 24 & 0x000000ff);
410 const fl::u8 b1 = fl::u8(END_FRAME >> 16 & 0x000000ff);
411 const fl::u8 b2 = fl::u8(END_FRAME >> 8 & 0x000000ff);
412 const fl::u8 b3 = fl::u8(END_FRAME >> 0 & 0x000000ff);
413 do {
414 mSPI.writeByte(b0);
415 mSPI.writeByte(b1);
416 mSPI.writeByte(b2);
417 mSPI.writeByte(b3);
418 } while(nDWords--);
419 }
420
422#ifdef FASTLED_SPI_BYTE_ONLY
423 mSPI.writeByte(0xE0 | brightness);
424 mSPI.writeByte(b0);
425 mSPI.writeByte(b1);
426 mSPI.writeByte(b2);
427#else
428 fl::u16 b = 0xE000 | (brightness << 8) | (fl::u16)b0;
429 mSPI.writeWord(b);
430 fl::u16 w = b1 << 8;
431 w |= b2;
432 mSPI.writeWord(w);
433#endif
434 }
435
437#ifdef FASTLED_SPI_BYTE_ONLY
438 mSPI.writeByte(b1);
439 mSPI.writeByte(b2);
440#else
441 mSPI.writeWord(fl::u16(b1) << 8 | b2);
442#endif
443 }
444
445public:
447
448 virtual void init() override {
449 mSPI.init();
450 }
451
452protected:
454 virtual void showPixels(PixelController<RGB_ORDER> & pixels) override {
455 switch (GAMMA_CORRECTION_MODE) {
457 showPixelsDefault(pixels);
458 break;
459 }
462 break;
463 }
464 }
465 }
466
467private:
468
471 fl::u8* out_s0, fl::u8* out_s1, fl::u8* out_s2, fl::u8* out_brightness) {
472#if FASTLED_HD_COLOR_MIXING
474 pixels.getHdScale(out_s0, out_s1, out_s2, &brightness);
475 struct Math {
476 static fl::u16 map(fl::u16 x, fl::u16 in_min, fl::u16 in_max, fl::u16 out_min, fl::u16 out_max) {
477 const fl::u16 run = in_max - in_min;
478 const fl::u16 rise = out_max - out_min;
479 const fl::u16 delta = x - in_min;
480 return (delta * rise) / run + out_min;
481 }
482 };
483 // *out_brightness = Math::map(brightness, 0, 255, 0, 31);
484 fl::u16 bri = Math::map(brightness, 0, 255, 0, 31);
485 if (bri == 0 && brightness != 0) {
486 // Fixes https://github.com/FastLED/FastLED/issues/1908
487 bri = 1;
488 }
489 *out_brightness = static_cast<fl::u8>(bri);
490 return;
491#else
492 fl::u8 s0, s1, s2;
493 pixels.loadAndScaleRGB(&s0, &s1, &s2);
494#if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
495 // This function is pure magic.
496 const fl::u16 maxBrightness = 0x1F;
497 fl::u16 brightness = ((((fl::u16)MAX(MAX(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1;
498 s0 = (maxBrightness * s0 + (brightness >> 1)) / brightness;
499 s1 = (maxBrightness * s1 + (brightness >> 1)) / brightness;
500 s2 = (maxBrightness * s2 + (brightness >> 1)) / brightness;
501#else
502 const fl::u8 brightness = 0x1F;
503#endif // FASTLED_USE_GLOBAL_BRIGHTNESS
504 *out_s0 = s0;
505 *out_s1 = s1;
506 *out_s2 = s2;
507 *out_brightness = static_cast<fl::u8>(brightness);
508#endif // FASTLED_HD_COLOR_MIXING
509 }
510
511 // Legacy showPixels implementation.
513 mSPI.select();
514 fl::u8 s0, s1, s2, global_brightness;
515 getGlobalBrightnessAndScalingFactors(pixels, &s0, &s1, &s2, &global_brightness);
517 while (pixels.has(1)) {
518 fl::u8 c0, c1, c2;
519 pixels.loadAndScaleRGB(&c0, &c1, &c2);
520 writeLed(global_brightness, c0, c1, c2);
521 pixels.stepDithering();
522 pixels.advanceData();
523 }
524 endBoundary(pixels.size());
525
526 mSPI.waitFully();
527 mSPI.release();
528 }
529
531 mSPI.select();
533 while (pixels.has(1)) {
534 // Load raw uncorrected r,g,b values.
535 fl::u8 brightness, c0, c1, c2; // c0-c2 is the RGB data re-ordered for pixel
536 pixels.loadAndScale_APA102_HD(&c0, &c1, &c2, &brightness);
537 writeLed(brightness, c0, c1, c2);
538 pixels.stepDithering();
539 pixels.advanceData();
540 }
541 endBoundary(pixels.size());
542 mSPI.waitFully();
543 mSPI.release();
544 }
545};
546
552template <
555 EOrder RGB_ORDER = RGB,
556 // APA102 has a bug where long strip can't handle full speed due to clock degredation.
557 // This only affects long strips, but then again if you have a short strip does 6 mhz actually slow
558 // you down? Probably not. And you can always bump it up for speed. Therefore we are prioritizing
559 // "just works" over "fastest possible" here.
560 // https://www.pjrc.com/why-apa102-leds-have-trouble-at-24-mhz/
561 uint32_t SPI_SPEED = DATA_RATE_MHZ(6)
562>
564 DATA_PIN,
565 CLOCK_PIN,
566 RGB_ORDER,
567 SPI_SPEED,
568 fl::kFiveBitGammaCorrectionMode_BitShift,
569 uint32_t(0x00000000),
570 uint32_t(0x00000000)> {
571public:
574};
575
581template <
584 EOrder RGB_ORDER = RGB,
585 uint32_t SPI_SPEED = DATA_RATE_MHZ(12)
586>
588 DATA_PIN,
589 CLOCK_PIN,
590 RGB_ORDER,
591 SPI_SPEED,
592 fl::kFiveBitGammaCorrectionMode_Null,
593 0x00000000,
594 0x00000000
595> {
596};
597
603template <
606 EOrder RGB_ORDER = RGB,
607 uint32_t SPI_SPEED = DATA_RATE_MHZ(12)
608>
610 DATA_PIN,
611 CLOCK_PIN,
612 RGB_ORDER,
613 SPI_SPEED,
614 fl::kFiveBitGammaCorrectionMode_BitShift,
615 0x00000000,
616 0x00000000
617> {
618};
619
620
622template <
625 EOrder RGB_ORDER = RGB,
626 uint32_t SPI_SPEED = DATA_RATE_MHZ(40)
627>
629 DATA_PIN,
630 CLOCK_PIN,
631 RGB_ORDER,
632 SPI_SPEED,
633 fl::kFiveBitGammaCorrectionMode_Null,
634 0x00000000,
635 0x00000000
636> {};
637
639template <
642 EOrder RGB_ORDER = RGB,
643 uint32_t SPI_SPEED = DATA_RATE_MHZ(40)
644>
646 DATA_PIN,
647 CLOCK_PIN,
648 RGB_ORDER,
649 SPI_SPEED> {
650};
651
652
654//
655// P9813 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
656//
658
664template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(10)>
665class P9813Controller : public CPixelLEDController<RGB_ORDER> {
668
669 void writeBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); }
670
672 FASTLED_REGISTER fl::u8 top = 0xC0 | ((~b & 0xC0) >> 2) | ((~g & 0xC0) >> 4) | ((~r & 0xC0) >> 6);
673 mSPI.writeByte(top); mSPI.writeByte(b); mSPI.writeByte(g); mSPI.writeByte(r);
674 }
675
676public:
678
679 virtual void init() {
680 mSPI.init();
681 }
682
683protected:
685 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
686 mSPI.select();
687
689 while(pixels.has(1)) {
690 writeLed(pixels.loadAndScale0(), pixels.loadAndScale1(), pixels.loadAndScale2());
691 pixels.advanceData();
692 pixels.stepDithering();
693 }
695 mSPI.waitFully();
696
697 mSPI.release();
698 }
699
700};
701
702
704//
705// SM16716 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
706//
708
714template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(16)>
715class SM16716Controller : public CPixelLEDController<RGB_ORDER> {
718
719 void writeHeader() {
720 // Write out 50 zeros to the spi line (6 blocks of 8 followed by two single bit writes)
721 mSPI.select();
722 mSPI.template writeBit<0>(0);
723 mSPI.writeByte(0);
724 mSPI.writeByte(0);
725 mSPI.writeByte(0);
726 mSPI.template writeBit<0>(0);
727 mSPI.writeByte(0);
728 mSPI.writeByte(0);
729 mSPI.writeByte(0);
730 mSPI.waitFully();
731 mSPI.release();
732 }
733
734public:
736
737 virtual void init() {
738 mSPI.init();
739 }
740
741protected:
743 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
744 // Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start
745 // of each triplet of bytes for rgb data
746 // writeHeader();
747 mSPI.template writePixels<FLAG_START_BIT, DATA_NOP, RGB_ORDER>(pixels, NULL);
748 writeHeader();
749 }
750
751};
752
754
755
757//
758// Clockless template instantiations - see clockless.h for how the timing values are used
759//
760
761#ifdef FASTLED_HAS_CLOCKLESS
783
784// Allow clock that clockless controller is based on to have different
785// frequency than the CPU.
786#if !defined(CLOCKLESS_FREQUENCY)
787 #define CLOCKLESS_FREQUENCY F_CPU
788#endif
789
790// We want to force all avr's to use the Trinket controller when running at 8Mhz, because even the 328's at 8Mhz
791// need the more tightly defined timeframes.
792#if defined(__LGT8F__) || (CLOCKLESS_FREQUENCY == 8000000 || CLOCKLESS_FREQUENCY == 16000000 || CLOCKLESS_FREQUENCY == 24000000) || defined(FASTLED_DOXYGEN) // || CLOCKLESS_FREQUENCY == 48000000 || CLOCKLESS_FREQUENCY == 96000000) // 125ns/clock
793
796#define FMUL (CLOCKLESS_FREQUENCY/8000000)
797
800template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
801class GE8822Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER, 4> {};
802
805template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
806class LPD1886Controller1250Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 3 * FMUL, 2 * FMUL, RGB_ORDER, 4> {};
807
810template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
811class LPD1886Controller1250Khz_8bit : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 3 * FMUL, 2 * FMUL, RGB_ORDER> {};
812
813#if !FASTLED_WS2812_HAS_SPECIAL_DRIVER
817template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
818class WS2812Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER> {};
819#endif
820
823template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
824class WS2815Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 9 * FMUL, 4 * FMUL, RGB_ORDER> {};
825
828template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
829class WS2811Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 4 * FMUL, 3 * FMUL, RGB_ORDER> {};
830
833template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
834class DP1903Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 8 * FMUL, 2 * FMUL, RGB_ORDER> {};
835
838template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
839class DP1903Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 4 * FMUL, 16 * FMUL, 4 * FMUL, RGB_ORDER> {};
840
843template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB> //not tested
844class WS2813Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 4 * FMUL, 3 * FMUL, RGB_ORDER> {};
845
848template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
849class WS2811Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 4 * FMUL, 10 * FMUL, 6 * FMUL, RGB_ORDER> {};
850
853template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
854class SK6822Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 8 * FMUL, 3 * FMUL, RGB_ORDER> {};
855
858template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
859class SM16703Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 4 * FMUL, 3 * FMUL, RGB_ORDER> {};
860
863template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
864class SK6812Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 3 * FMUL, 4 * FMUL, RGB_ORDER> {};
865
868template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
869class UCS1903Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 4 * FMUL, 12 * FMUL, 4 * FMUL, RGB_ORDER> {};
870
873template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
874class UCS1903BController800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 4 * FMUL, 4 * FMUL, RGB_ORDER> {};
875
878template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
879class UCS1904Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 3 * FMUL, 4 * FMUL, RGB_ORDER> {};
880
883template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
884class UCS2903Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 6 * FMUL, 2 * FMUL, RGB_ORDER> {};
885
888template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
889class TM1809Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER> {};
890
893template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
894class TM1803Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 6 * FMUL, 9 * FMUL, 6 * FMUL, RGB_ORDER> {};
895
898template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
899class TM1829Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER, 0, true, 500> {};
900
903template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
904class GW6205Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 6 * FMUL, 7 * FMUL, 6 * FMUL, RGB_ORDER, 4> {};
905
908template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
909class GW6205Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 4 * FMUL, 4 * FMUL, RGB_ORDER, 4> {};
910
913template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
914class PL9823Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 8 * FMUL, 3 * FMUL, RGB_ORDER> {};
915
916// UCS1912 - Note, never been tested, this is according to the datasheet
917template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
918class UCS1912Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 2 * FMUL, 8 * FMUL, 3 * FMUL, RGB_ORDER> {};
919
922template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
923class SM16824EController : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, 3 * FMUL, 9 * FMUL, 1 * FMUL, RGB_ORDER, 0, false, 200> {};
924
925
926#else
927
928
929
930// WS2812 can be overclocked pretty aggressively, however, there are
931// some excellent articles that you should read about WS2812 overclocking
932// and corruption for a large number of LEDs.
933// https://wp.josh.com/2014/05/16/why-you-should-give-your-neopixel-bits-room-to-breathe/
934// https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/
935#ifndef FASTLED_OVERCLOCK_WS2812
936#define FASTLED_OVERCLOCK_WS2812 FASTLED_OVERCLOCK
937#endif
938
939#ifndef FASTLED_OVERCLOCK_WS2811
940#define FASTLED_OVERCLOCK_WS2811 FASTLED_OVERCLOCK
941#endif
942
943#ifndef FASTLED_OVERCLOCK_WS2813
944#define FASTLED_OVERCLOCK_WS2813 FASTLED_OVERCLOCK
945#endif
946
947#ifndef FASTLED_OVERCLOCK_WS2815
948#define FASTLED_OVERCLOCK_WS2815 FASTLED_OVERCLOCK
949#endif
950
951#ifndef FASTLED_OVERCLOCK_SK6822
952#define FASTLED_OVERCLOCK_SK6822 FASTLED_OVERCLOCK
953#endif
954
955#ifndef FASTLED_OVERCLOCK_SK6812
956#define FASTLED_OVERCLOCK_SK6812 FASTLED_OVERCLOCK
957#endif
958
961#if FASTLED_CLOCKLESS_USES_NANOSECONDS
962// just use raw nanosecond values for the teensy4
963#define C_NS(_NS) _NS
964#else
965#define C_NS(_NS) (((_NS * ((CLOCKLESS_FREQUENCY / 1000000L)) + 999)) / 1000)
966#endif
967
968// Allow overclocking various LED chipsets in the clockless family.
969// Clocked chips like the APA102 don't need this because they allow
970// you to control the clock speed directly.
971#define C_NS_WS2812(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2812)))
972#define C_NS_WS2811(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2811)))
973#define C_NS_WS2813(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2813)))
974#define C_NS_WS2815(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2815)))
975#define C_NS_SK6822(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_SK6822)))
976#define C_NS_SK6812(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_SK6812)))
977
978
979
980// At T=0 : the line is raised hi to start a bit
981// At T=T1 : the line is dropped low to transmit a zero bit
982// At T=T1+T2 : the line is dropped low to transmit a one bit
983// At T=T1+T2+T3 : the cycle is concluded (next bit can be sent)
984//
985// Python script to calculate the values for T1, T2, and T3 for FastLED:
986// Note: there is a discussion on whether this python script is correct or not:
987// https://github.com/FastLED/FastLED/issues/1806
988//
989// print("Enter the values of T0H, T0L, T1H, T1L, in nanoseconds: ")
990// T0H = int(input(" T0H: "))
991// T0L = int(input(" T0L: "))
992// T1H = int(input(" T1H: "))
993// T1L = int(input(" T1L: "))
994//
995// duration = max(T0H + T0L, T1H + T1L)
996//
997// print("The max duration of the signal is: ", duration)
998//
999// T1 = T0H
1000// T2 = T1H
1001// T3 = duration - T0H - T0L
1002//
1003// print("T1: ", T1)
1004// print("T2: ", T2)
1005// print("T3: ", T3)
1006
1007
1008// GE8822 - 350ns 660ns 350ns
1009template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1010class GE8822Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(350), C_NS(660), C_NS(350), RGB_ORDER, 4> {};
1011
1012// GW6205@400khz - 800ns, 800ns, 800ns
1013template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1014class GW6205Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(800), C_NS(800), C_NS(800), RGB_ORDER, 4> {};
1015
1016// GW6205@400khz - 400ns, 400ns, 400ns
1017template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1018class GW6205Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(400), C_NS(400), C_NS(400), RGB_ORDER, 4> {};
1019
1020// UCS1903 - 500ns, 1500ns, 500ns
1021template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1022class UCS1903Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(500), C_NS(1500), C_NS(500), RGB_ORDER> {};
1023
1024// UCS1903B - 400ns, 450ns, 450ns
1025template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1026class UCS1903BController800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(400), C_NS(450), C_NS(450), RGB_ORDER> {};
1027
1028// UCS1904 - 400ns, 400ns, 450ns
1029template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1030class UCS1904Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(400), C_NS(400), C_NS(450), RGB_ORDER> {};
1031
1032// UCS2903 - 250ns, 750ns, 250ns
1033template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1034class UCS2903Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(250), C_NS(750), C_NS(250), RGB_ORDER> {};
1035
1036// TM1809 - 350ns, 350ns, 550ns
1037template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1038class TM1809Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(350), C_NS(350), C_NS(450), RGB_ORDER> {};
1039
1040// WS2811 - 320ns, 320ns, 640ns
1041template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1042class WS2811Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS_WS2811(320), C_NS_WS2811(320), C_NS_WS2811(640), RGB_ORDER> {};
1043
1044// WS2813 - 320ns, 320ns, 640ns
1045template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1046class WS2813Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS_WS2813(320), C_NS_WS2813(320), C_NS_WS2813(640), RGB_ORDER> {};
1047
1048#ifndef FASTLED_WS2812_T1
1049#define FASTLED_WS2812_T1 250
1050#endif
1051
1052#ifndef FASTLED_WS2812_T2
1053#define FASTLED_WS2812_T2 625
1054#endif
1055
1056#ifndef FASTLED_WS2812_T3
1057#define FASTLED_WS2812_T3 375
1058#endif
1059
1060
1061
1062#if !FASTLED_WS2812_HAS_SPECIAL_DRIVER
1063template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1065 DATA_PIN,
1066 C_NS_WS2812(FASTLED_WS2812_T1),
1067 C_NS_WS2812(FASTLED_WS2812_T2),
1068 C_NS_WS2812(FASTLED_WS2812_T3),
1069 RGB_ORDER> {};
1070#endif
1071
1072// WS2811@400khz - 800ns, 800ns, 900ns
1073template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1074class WS2811Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS_WS2811(800), C_NS_WS2811(800), C_NS_WS2811(900), RGB_ORDER> {};
1075
1076template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1077class WS2815Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS_WS2815(250), C_NS_WS2815(1090), C_NS_WS2815(550), RGB_ORDER> {};
1078
1079// 750NS, 750NS, 750NS
1080template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1081class TM1803Controller400Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(700), C_NS(1100), C_NS(700), RGB_ORDER> {};
1082
1083template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1084class TM1829Controller800Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(340), C_NS(340), C_NS(550), RGB_ORDER, 0, true, 500> {};
1085
1086template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1087class TM1829Controller1600Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(100), C_NS(300), C_NS(200), RGB_ORDER, 0, true, 500> {};
1088
1089template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1090class LPD1886Controller1250Khz : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(200), C_NS(400), C_NS(200), RGB_ORDER, 4> {};
1091
1092template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1093class LPD1886Controller1250Khz_8bit : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(200), C_NS(400), C_NS(200), RGB_ORDER> {};
1094
1095
1096template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1097class SK6822Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS_SK6822(375), C_NS_SK6822(1000), C_NS_SK6822(375), RGB_ORDER> {};
1098
1099template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1100class SK6812Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS_SK6812(300), C_NS_SK6812(300), C_NS_SK6812(600), RGB_ORDER> {};
1101
1102template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1103class SM16703Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(300), C_NS(600), C_NS(300), RGB_ORDER> {};
1104
1105template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1106class PL9823Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(350), C_NS(1010), C_NS(350), RGB_ORDER> {};
1107
1108// UCS1912 - Note, never been tested, this is according to the datasheet
1109template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1110class UCS1912Controller : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(250), C_NS(1000), C_NS(350), RGB_ORDER> {};
1111
1112// NEW LED! Help us test it!
1113// Under developement.
1114// SM16824E - 300ns, 900ns, 0ns
1115// * T0H: .3
1116// * T0L: .9
1117// * T1H: .9
1118// * T1L: .3
1119// * TRST: 200
1120template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1121class SM16824EController : public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(300), C_NS(900), C_NS(100), RGB_ORDER, 0, false, 200> {};
1122#endif
1124
1125
1126// WS2816 - is an emulated controller that emits 48 bit pixels by forwarding
1127// them to a platform specific WS2812 controller. The WS2812 controller
1128// has to output twice as many 24 bit pixels.
1129template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1131 : public CPixelLEDController<RGB_ORDER,
1132 WS2812Controller800Khz<DATA_PIN, RGB>::LANES_VALUE,
1133 WS2812Controller800Khz<DATA_PIN, RGB>::MASK_VALUE> {
1134
1135public:
1136
1137 // ControllerT is a helper class. It subclasses the device controller class
1138 // and has three methods to call the three protected methods we use.
1139 // This is janky, but redeclaring public methods protected in a derived class
1140 // is janky, too.
1141
1142 // N.B., byte order must be RGB.
1145 friend class WS2816Controller<DATA_PIN, RGB_ORDER>;
1146 void *callBeginShowLeds(int size) { return ControllerBaseT::beginShowLeds(size); }
1147 void callShow(CRGB *data, int nLeds, fl::u8 brightness) {
1148 ControllerBaseT::show(data, nLeds, brightness);
1149 }
1150 void callEndShowLeds(void *data) { ControllerBaseT::endShowLeds(data); }
1151 };
1152
1153 static const int LANES = ControllerT::LANES_VALUE;
1154 static const uint32_t MASK = ControllerT::MASK_VALUE;
1155
1158 mController.setLeds(nullptr, 0);
1159 delete [] mData;
1160 }
1161
1162 virtual void *beginShowLeds(int size) override {
1163 mController.setEnabled(true);
1164 void *result = mController.callBeginShowLeds(2 * size);
1165 mController.setEnabled(false);
1166 return result;
1167 }
1168
1169 virtual void endShowLeds(void *data) override {
1170 mController.setEnabled(true);
1171 mController.callEndShowLeds(data);
1172 mController.setEnabled(false);
1173 }
1174
1176 // Ensure buffer is large enough
1177 ensureBuffer(pixels.size());
1178
1179 // expand and copy all the pixels
1180 size_t out_index = 0;
1181 while (pixels.has(1)) {
1182 pixels.stepDithering();
1183
1184 fl::u16 s0, s1, s2;
1185 pixels.loadAndScale_WS2816_HD(&s0, &s1, &s2);
1186 fl::u8 b0_hi = s0 >> 8;
1187 fl::u8 b0_lo = s0 & 0xFF;
1188 fl::u8 b1_hi = s1 >> 8;
1189 fl::u8 b1_lo = s1 & 0xFF;
1190 fl::u8 b2_hi = s2 >> 8;
1191 fl::u8 b2_lo = s2 & 0xFF;
1192
1193 mData[out_index] = CRGB(b0_hi, b0_lo, b1_hi);
1194 mData[out_index + 1] = CRGB(b1_lo, b2_hi, b2_lo);
1195
1196 pixels.advanceData();
1197 out_index += 2;
1198 }
1199
1200 // ensure device controller won't modify color values
1201 mController.setCorrection(CRGB(255, 255, 255));
1202 mController.setTemperature(CRGB(255, 255, 255));
1203 mController.setDither(DISABLE_DITHER);
1204
1205 // output the data stream
1206 mController.setEnabled(true);
1207#ifdef BOUNCE_SUBCLASS
1208 mController.callShow(mData, 2 * pixels.size(), 255);
1209#else
1210 mController.show(mData, 2 * pixels.size(), 255);
1211#endif
1212 mController.setEnabled(false);
1213 }
1214
1215private:
1216 void init() override {
1217 mController.init();
1218 mController.setEnabled(false);
1219 }
1220
1221 void ensureBuffer(int size_8bit) {
1222 int size_16bit = 2 * size_8bit;
1223 if (mController.size() != size_16bit) {
1224 delete [] mData;
1225 CRGB *new_leds = new CRGB[size_16bit];
1226 mData = new_leds;
1227 mController.setLeds(new_leds, size_16bit);
1228 }
1229 }
1230
1233};
1234
1235
1236#endif
1238
1240
1241#endif
#define DATA_PIN
int x
Definition simple.h:92
Rgbw rgbw
UISlider brightness("Brightness", 128, 0, 255, 1)
#define FASTLED_CLOCKLESS_CONTROLLER
Definition chipsets.h:18
void showPixelsGammaBitShift(PixelController< RGB_ORDER > &pixels)
Definition chipsets.h:530
virtual void init() override
Initialize the LED controller.
Definition chipsets.h:448
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition chipsets.h:400
virtual void showPixels(PixelController< RGB_ORDER > &pixels) override
Send the LED data to the strip.
Definition chipsets.h:454
void showPixelsDefault(PixelController< RGB_ORDER > &pixels)
Definition chipsets.h:512
FASTLED_FORCE_INLINE void writeLed(fl::u8 brightness, fl::u8 b0, fl::u8 b1, fl::u8 b2)
Definition chipsets.h:421
static void getGlobalBrightnessAndScalingFactors(PixelController< RGB_ORDER > &pixels, fl::u8 *out_s0, fl::u8 *out_s1, fl::u8 *out_s2, fl::u8 *out_brightness)
Definition chipsets.h:469
FASTLED_FORCE_INLINE void write2Bytes(fl::u8 b1, fl::u8 b2)
Definition chipsets.h:436
void startBoundary()
Definition chipsets.h:403
void endBoundary(int nLeds)
Definition chipsets.h:407
APA102ControllerHD()=default
APA102ControllerHD(const APA102ControllerHD &)=delete
static void writeBytesValueRaw(uint8_t value, int len)
Write multiple bytes of the given value over SPI, without selecting the interface.
virtual int size()
How many LEDs does this controller manage?
Rgbw getRgbw() const
CLEDController & setRgbw(const Rgbw &arg=RgbwDefault::value())
virtual void init()=0
Initialize the LED controller.
void mark()
Reset the timestamp that marks the start of the wait period.
void wait()
Blocking delay until WAIT time since mark() has passed.
Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not e...
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels)=0
Send the LED data to the strip.
Template extension of the CLEDController class.
DP1903 controller class @ 400 KHz.
Definition chipsets.h:839
DP1903 controller class @ 800 KHz.
Definition chipsets.h:834
GE8822 controller class.
Definition chipsets.h:801
GW6205 controller class @ 400 KHz.
Definition chipsets.h:904
UCS1904 controller class @ 800 KHz.
Definition chipsets.h:909
HD107 is just the APA102 with a default 40Mhz clock rate.
Definition chipsets.h:636
HD107HD is just the APA102HD with a default 40Mhz clock rate.
Definition chipsets.h:649
LPD1886 controller class.
Definition chipsets.h:811
LPD1886 controller class.
Definition chipsets.h:806
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition chipsets.h:352
void startBoundary()
Definition chipsets.h:340
virtual void init()
Initialize the LED controller.
Definition chipsets.h:346
void endBoundary(int nLeds)
Definition chipsets.h:341
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition chipsets.h:337
static FASTLED_FORCE_INLINE fl::u8 adjust(FASTLED_REGISTER fl::u8 data)
Definition chipsets.h:261
static FASTLED_FORCE_INLINE void postBlock(int len, void *context=NULL)
Definition chipsets.h:262
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition chipsets.h:280
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition chipsets.h:256
virtual void init()
Initialize the LED controller.
Definition chipsets.h:273
void writeBoundary()
Definition chipsets.h:669
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition chipsets.h:666
FASTLED_FORCE_INLINE void writeLed(fl::u8 r, fl::u8 g, fl::u8 b)
Definition chipsets.h:671
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition chipsets.h:685
virtual void init()
Initialize the LED controller.
Definition chipsets.h:679
PL9823 controller class.
Definition chipsets.h:914
void callShow(CRGB *data, int nLeds, fl::u8 brightness)
Definition chipsets.h:151
virtual void * beginShowLeds(int size) override
Definition chipsets.h:169
ControllerT mController
Definition chipsets.h:236
void init() override
Initialize the LED controller.
Definition chipsets.h:209
static const int LANES
Definition chipsets.h:158
virtual void endShowLeds(void *data) override
Definition chipsets.h:173
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels) override
Send the LED data to the strip.
Definition chipsets.h:177
void ensureBuffer(int32_t num_leds)
Definition chipsets.h:214
RGBWEmulatedController(const Rgbw &rgbw=RgbwDefault())
Definition chipsets.h:164
static const uint32_t MASK
Definition chipsets.h:159
CONTROLLER ControllerBaseT
Definition chipsets.h:147
SK6812 controller class.
Definition chipsets.h:864
SK6822 controller class.
Definition chipsets.h:854
SK9822 controller class.
Definition chipsets.h:617
SK9822 controller class.
Definition chipsets.h:595
SM16703 controller class.
Definition chipsets.h:859
virtual void init()
Initialize the LED controller.
Definition chipsets.h:737
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition chipsets.h:743
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition chipsets.h:716
SM16824E controller class.
Definition chipsets.h:923
Hardware SPI output.
Definition fastspi.h:53
TM1803 controller class.
Definition chipsets.h:894
TM1809 controller class.
Definition chipsets.h:889
TM1829 controller class.
Definition chipsets.h:899
UCS1903B controller class.
Definition chipsets.h:874
UCS1903 controller class @ 400 KHz.
Definition chipsets.h:869
UCS1904 controller class.
Definition chipsets.h:879
UCS2903 controller class.
Definition chipsets.h:884
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition chipsets.h:315
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition chipsets.h:299
virtual void init()
Initialize the controller.
Definition chipsets.h:307
CMinWait< 1000 > mWaitDelay
Definition chipsets.h:301
WS2803 controller class.
Definition chipsets.h:325
WS2811 controller class @ 400 KHz.
Definition chipsets.h:849
WS2811 controller class @ 800 KHz.
Definition chipsets.h:829
WS2812 controller class @ 800 KHz.
Definition chipsets.h:818
WS2813 controller class.
Definition chipsets.h:844
WS2815 controller class @ 400 KHz.
Definition chipsets.h:824
void * callBeginShowLeds(int size)
Definition chipsets.h:1146
void callShow(CRGB *data, int nLeds, fl::u8 brightness)
Definition chipsets.h:1147
void callEndShowLeds(void *data)
Definition chipsets.h:1150
static const uint32_t MASK
Definition chipsets.h:1154
void ensureBuffer(int size_8bit)
Definition chipsets.h:1221
ControllerT mController
Definition chipsets.h:1232
static const int LANES
Definition chipsets.h:1153
virtual void * beginShowLeds(int size) override
Definition chipsets.h:1162
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels) override
Send the LED data to the strip.
Definition chipsets.h:1175
void init() override
Initialize the LED controller.
Definition chipsets.h:1216
WS2812Controller800Khz< DATA_PIN, RGB > ControllerBaseT
Definition chipsets.h:1143
virtual void endShowLeds(void *data) override
Definition chipsets.h:1169
Defines the red, green, and blue (RGB) pixel struct.
#define DISABLE_DITHER
Disable dithering.
Definition dither_mode.h:12
fl::EOrder EOrder
Definition eorder.h:9
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:16
@ RGB
Red, Green, Blue (0012)
Definition eorder.h:14
Defines color channel ordering enumerations.
#define DATA_RATE_MHZ(X)
Convert data rate from megahertz (MHz) to clock cycles per bit.
Definition fastspi.h:28
Declares functions for five-bit gamma correction.
#define FASTLED_FORCE_INLINE
Definition force_inline.h:6
#define MAX(a, b)
Definition math_macros.h:37
#define FASTLED_NAMESPACE_END
Definition namespace.h:23
#define FASTLED_NAMESPACE_BEGIN
Definition namespace.h:22
Implements the FastLED namespace macros.
unsigned char u8
Definition int.h:17
FiveBitGammaCorrectionMode
@ kFiveBitGammaCorrectionMode_Null
@ kFiveBitGammaCorrectionMode_BitShift
To * bit_cast_ptr(void *storage) noexcept
Definition bit_cast.h:54
Non-templated low level pixel data writing class.
Includes defintions for RGB and HSV pixels.
#define FASTLED_REGISTER
Helper macro to replace the deprecated 'register' keyword if we're using modern C++ where it's been r...
Definition register.h:9
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
FASTLED_FORCE_INLINE void loadAndScale_WS2816_HD(uint16_t *s0_out, uint16_t *s1_out, uint16_t *s2_out)
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 loadAndScale1(int lane, uint8_t scale)
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE uint8_t loadAndScale2(int lane, uint8_t scale)
non-template alias of loadAndScale<2>()
FASTLED_FORCE_INLINE void loadAndScaleRGB(uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out)
FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane, uint8_t scale)
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE int size()
Get the length of the LED strip.
FASTLED_FORCE_INLINE void loadAndScaleRGBW(Rgbw rgbw, uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out, uint8_t *b3_out)
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?
FASTLED_FORCE_INLINE void stepDithering()
Step the dithering forward.
Pixel controller class.
static uint32_t size_as_rgb(uint32_t num_of_rgbw_pixels)
Definition rgbw.h:39