FastLED 3.9.13
Loading...
Searching...
No Matches
FastLED.h
Go to the documentation of this file.
1#pragma once
2#ifndef __INC_FASTSPI_LED2_H
3#define __INC_FASTSPI_LED2_H
4
5#include <stdint.h>
6
9
10#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
11#define FASTLED_HAS_PRAGMA_MESSAGE
12#endif
13
19#define FASTLED_VERSION 3009013
20#ifndef FASTLED_INTERNAL
21# ifdef FASTLED_SHOW_VERSION
22# ifdef FASTLED_HAS_PRAGMA_MESSAGE
23# pragma message "FastLED version 3.009.013"
24# else
25# warning FastLED version 3.009.013 (Not really a warning, just telling you here.)
26# endif
27# endif
28#endif
29
30#ifndef __PROG_TYPES_COMPAT__
34#define __PROG_TYPES_COMPAT__
35#endif
36
37#ifdef SmartMatrix_h
38#include <SmartMatrix.h>
39#endif
40
41#ifdef DmxSimple_h
42#include <DmxSimple.h>
43#endif
44
45#ifdef DmxSerial_h
46#include <DMXSerial.h>
47#endif
48
49#ifdef USE_OCTOWS2811
50#include <OctoWS2811.h>
51#endif
52
53
54
55#include "fl/force_inline.h"
56#include "cpp_compat.h"
57
58#include "fastled_config.h"
59#include "led_sysdefs.h"
60
61// Utility functions
62#include "fastled_delay.h"
63#include "bitswap.h"
64
65#include "controller.h"
66#include "fastpin.h"
67#include "fastspi_types.h"
68#include "dmx.h"
69
70#include "platforms.h"
71#include "fastled_progmem.h"
72
73#include "lib8tion.h"
74#include "pixeltypes.h"
75#include "hsv2rgb.h"
76#include "colorutils.h"
77#include "pixelset.h"
78#include "colorpalettes.h"
79
80#include "noise.h"
81#include "power_mgt.h"
82
83#include "fastspi.h"
84#include "chipsets.h"
85#include "fl/engine_events.h"
86
88
89// Backdoor to get the size of the CLedController object. The one place
90// that includes this just uses extern to declare the function.
91uint16_t cled_contoller_size();
92
111
114enum ESM { SMART_MATRIX };
115
119enum OWS2811 { OCTOWS2811,OCTOWS2811_400, OCTOWS2813};
120
124enum SWS2812 { WS2812SERIAL };
125
126#ifdef HAS_PIXIE
127template<uint8_t DATA_PIN, EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
128#endif
129
130#ifdef FASTLED_HAS_CLOCKLESS
135
138template<uint8_t DATA_PIN> class NEOPIXEL : public WS2812Controller800Khz<DATA_PIN, GRB> {};
139
142template<uint8_t DATA_PIN, EOrder RGB_ORDER>
143class SM16703 : public SM16703Controller<DATA_PIN, RGB_ORDER> {};
144
147template<uint8_t DATA_PIN, EOrder RGB_ORDER>
148class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
149
152template<uint8_t DATA_PIN, EOrder RGB_ORDER>
153class TM1812 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
154
157template<uint8_t DATA_PIN, EOrder RGB_ORDER>
158class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
159
162template<uint8_t DATA_PIN, EOrder RGB_ORDER>
163class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
164
167template<uint8_t DATA_PIN, EOrder RGB_ORDER>
168class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {};
169
172template<uint8_t DATA_PIN, EOrder RGB_ORDER>
173class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {};
174
177template<uint8_t DATA_PIN, EOrder RGB_ORDER>
178class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {};
179
182template<uint8_t DATA_PIN, EOrder RGB_ORDER>
183class UCS1904 : public UCS1904Controller800Khz<DATA_PIN, RGB_ORDER> {};
184
187template<uint8_t DATA_PIN, EOrder RGB_ORDER>
188class UCS2903 : public UCS2903Controller<DATA_PIN, RGB_ORDER> {};
189
192template<uint8_t DATA_PIN, EOrder RGB_ORDER>
193class WS2812 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
194
196template<uint8_t DATA_PIN, EOrder RGB_ORDER>
197class WS2815 : public WS2815Controller<DATA_PIN, RGB_ORDER> {};
198
200template <uint8_t DATA_PIN, EOrder RGB_ORDER>
201class WS2816 : public WS2816Controller<DATA_PIN, RGB_ORDER> {};
202
205template<uint8_t DATA_PIN, EOrder RGB_ORDER>
206class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
207
210template<uint8_t DATA_PIN, EOrder RGB_ORDER>
211class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
212
215template<uint8_t DATA_PIN, EOrder RGB_ORDER>
216class GS1903 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
217
220template<uint8_t DATA_PIN, EOrder RGB_ORDER>
221class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
222
225template<uint8_t DATA_PIN, EOrder RGB_ORDER>
226class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
227
230template<uint8_t DATA_PIN, EOrder RGB_ORDER>
231class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
232
235template<uint8_t DATA_PIN, EOrder RGB_ORDER>
236class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
237
240template<uint8_t DATA_PIN, EOrder RGB_ORDER>
241class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
242
245template<uint8_t DATA_PIN, EOrder RGB_ORDER>
246class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
247
250template<uint8_t DATA_PIN, EOrder RGB_ORDER>
251class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
252
255template<uint8_t DATA_PIN, EOrder RGB_ORDER>
256class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
257
260template<uint8_t DATA_PIN, EOrder RGB_ORDER>
261class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
262
265template<uint8_t DATA_PIN, EOrder RGB_ORDER>
266class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
267
270template<uint8_t DATA_PIN, EOrder RGB_ORDER>
271class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
272
275template<uint8_t DATA_PIN, EOrder RGB_ORDER>
276class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
277
280template<uint8_t DATA_PIN, EOrder RGB_ORDER>
281class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
282
284template<uint8_t DATA_PIN, EOrder RGB_ORDER>
285class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
286
287#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
289template<uint8_t DATA_PIN, EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
290#endif
291#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
293template<EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
294#endif
295#endif
298
299
302#ifdef PORTA_FIRST_PIN
303 WS2811_PORTA,
304 WS2813_PORTA,
305 WS2811_400_PORTA,
306 TM1803_PORTA,
307 UCS1903_PORTA,
308#endif
309#ifdef PORTB_FIRST_PIN
310 WS2811_PORTB,
311 WS2813_PORTB,
312 WS2811_400_PORTB,
313 TM1803_PORTB,
314 UCS1903_PORTB,
315#endif
316#ifdef PORTC_FIRST_PIN
317 WS2811_PORTC,
318 WS2813_PORTC,
319 WS2811_400_PORTC,
320 TM1803_PORTC,
321 UCS1903_PORTC,
322#endif
323#ifdef PORTD_FIRST_PIN
324 WS2811_PORTD,
325 WS2813_PORTD,
326 WS2811_400_PORTD,
327 TM1803_PORTD,
328 UCS1903_PORTD,
329#endif
330#ifdef HAS_PORTDC
331 WS2811_PORTDC,
332 WS2813_PORTDC,
333 WS2811_400_PORTDC,
334 TM1803_PORTDC,
335 UCS1903_PORTDC,
336#endif
337};
338
345typedef uint8_t (*power_func)(uint8_t scale, uint32_t data);
346
353class CFastLED {
354 // int m_nControllers;
355 uint8_t m_Scale;
356 uint16_t m_nFPS;
357 uint32_t m_nMinMicros;
358 uint32_t m_nPowerData;
359 power_func m_pPowerFunc;
360
361public:
362 CFastLED();
363
364 // Useful when you want to know when an event like onFrameBegin or onFrameEnd is happening.
365 // This is disabled on AVR to save space.
366 void addListener(fl::EngineEvents::Listener *listener) { fl::EngineEvents::addListener(listener); }
367 void removeListener(fl::EngineEvents::Listener *listener) { fl::EngineEvents::removeListener(listener); }
368
380 static CLEDController &addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0);
381
401
402
403 // Base template: Causes a compile-time error if an unsupported CHIPSET is used
404 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN>
406 // Default implementation, will be specialized for supported chipsets
407 static const bool IS_VALID = false;
408 };
409
410 // Macro to define a mapping from the ESPIChipeset enum to the controller class
411 // in it's various template configurations.
412 #define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS) \
413 template<uint8_t DATA_PIN, uint8_t CLOCK_PIN> \
414 struct ClockedChipsetHelper<CHIPSET_ENUM, DATA_PIN, CLOCK_PIN> { \
415 static const bool IS_VALID = true; \
416 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN> ControllerType; \
417 /* Controller type with RGB_ORDER specified */ \
418 template<EOrder RGB_ORDER> \
419 struct CONTROLLER_CLASS_WITH_ORDER { \
420 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER> ControllerType; \
421 }; \
422 /* Controller type with RGB_ORDER and spi frequency specified */ \
423 template<EOrder RGB_ORDER, uint32_t FREQ> \
424 struct CONTROLLER_CLASS_WITH_ORDER_AND_FREQ { \
425 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER, FREQ> ControllerType; \
426 }; \
427 };
428
429 // Define specializations for each supported CHIPSET
430 _FL_MAP_CLOCKED_CHIPSET(LPD6803, LPD6803Controller)
431 _FL_MAP_CLOCKED_CHIPSET(LPD8806, LPD8806Controller)
432 _FL_MAP_CLOCKED_CHIPSET(WS2801, WS2801Controller)
433 _FL_MAP_CLOCKED_CHIPSET(WS2803, WS2803Controller)
434 _FL_MAP_CLOCKED_CHIPSET(SM16716, SM16716Controller)
435 _FL_MAP_CLOCKED_CHIPSET(P9813, P9813Controller)
436
437 // Both DOTSTAR and APA102 use the same controller class
438 _FL_MAP_CLOCKED_CHIPSET(DOTSTAR, APA102Controller)
439 _FL_MAP_CLOCKED_CHIPSET(APA102, APA102Controller)
440
441 // Both DOTSTARHD and APA102HD use the same controller class
442 _FL_MAP_CLOCKED_CHIPSET(DOTSTARHD, APA102ControllerHD)
443 _FL_MAP_CLOCKED_CHIPSET(APA102HD, APA102ControllerHD)
444
445 _FL_MAP_CLOCKED_CHIPSET(HD107, APA102Controller)
446 _FL_MAP_CLOCKED_CHIPSET(HD107HD, APA102ControllerHD)
447
448 _FL_MAP_CLOCKED_CHIPSET(SK9822, SK9822Controller)
449 _FL_MAP_CLOCKED_CHIPSET(SK9822HD, SK9822ControllerHD)
450
451
452
453 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
454 // Instantiate the controller using ClockedChipsetHelper
456 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
457 static_assert(CHIP::IS_VALID, "Unsupported chipset");
458 static ControllerTypeWithFreq c;
459 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
460 }
461
463 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
465 typedef typename CHIP::ControllerType ControllerType;
466 static_assert(CHIP::IS_VALID, "Unsupported chipset");
467 static ControllerType c;
468 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
469 }
470
471
472 // The addLeds function using ChipsetHelper
473 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER>
474 CLEDController& addLeds(struct CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
475 typedef ClockedChipsetHelper<CHIPSET, DATA_PIN, CLOCK_PIN> CHIP;
476 static_assert(CHIP::IS_VALID, "Unsupported chipset");
477 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
478 static ControllerTypeWithOrder c;
479 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
480 }
481
482
483#ifdef SPI_DATA
484 template<ESPIChipsets CHIPSET> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
485 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB>(data, nLedsOrOffset, nLedsIfOffset);
486 }
487
488 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
489 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER>(data, nLedsOrOffset, nLedsIfOffset);
490 }
491
492 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
493 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE>(data, nLedsOrOffset, nLedsIfOffset);
494 }
495
496#endif
498
499#ifdef FASTLED_HAS_CLOCKLESS
520
522 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
523 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
524 static CHIPSET<DATA_PIN, RGB_ORDER> c;
525 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
526 }
527
529 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN>
530 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
531 static CHIPSET<DATA_PIN, RGB> c;
532 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
533 }
534
536 template<template<uint8_t DATA_PIN> class CHIPSET, uint8_t DATA_PIN>
537 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
538 static CHIPSET<DATA_PIN> c;
539 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
540 }
541
542#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
543 template<uint8_t NUM_LANES, template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
544 static CLEDController &addLeds(struct CRGB *data, int nLeds) {
545 static __FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
546 return addLeds(&c, data, nLeds);
547 }
548#endif
549
550 #ifdef FASTSPI_USE_DMX_SIMPLE
551 template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
552 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
553 {
554 switch(CHIPSET) {
555 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
556 }
557 }
558 #endif
560#endif
561
582
584 template<template<EOrder RGB_ORDER> class CHIPSET, EOrder RGB_ORDER>
585 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
586 static CHIPSET<RGB_ORDER> c;
587 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
588 }
589
591 template<template<EOrder RGB_ORDER> class CHIPSET>
592 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
593 static CHIPSET<RGB> c;
594 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
595 }
596
597#ifdef USE_OCTOWS2811
601 template<OWS2811 CHIPSET, EOrder RGB_ORDER>
602 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
603 {
604 switch(CHIPSET) {
605 case OCTOWS2811: { static COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
606 case OCTOWS2811_400: { static COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
607#ifdef WS2813_800kHz
608 case OCTOWS2813: { static COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
609#endif
610 }
611 }
612
616 template<OWS2811 CHIPSET>
617 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
618 {
619 return addLeds<CHIPSET,GRB>(data,nLedsOrOffset,nLedsIfOffset);
620 }
621
622#endif
623
624#ifdef USE_WS2812SERIAL
628 template<SWS2812 CHIPSET, int DATA_PIN, EOrder RGB_ORDER>
629 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
630 {
631 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
632 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
633 }
634#endif
635
636#ifdef SmartMatrix_h
639 template<ESM CHIPSET>
640 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
641 {
642 switch(CHIPSET) {
643 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
644 }
645 }
646#endif
648
649
650#ifdef FASTLED_HAS_BLOCKLESS
651
672
674 template<EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
675 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
676 switch(CHIPSET) {
677 #ifdef PORTA_FIRST_PIN
678 case WS2811_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
679 case WS2811_400_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
680 case WS2813_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
681 case TM1803_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
682 case UCS1903_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
683 #endif
684 #ifdef PORTB_FIRST_PIN
685 case WS2811_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
686 case WS2811_400_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
687 case WS2813_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
688 case TM1803_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
689 case UCS1903_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
690 #endif
691 #ifdef PORTC_FIRST_PIN
692 case WS2811_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
693 case WS2811_400_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
694 case WS2813_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
695 case TM1803_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
696 case UCS1903_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
697 #endif
698 #ifdef PORTD_FIRST_PIN
699 case WS2811_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
700 case WS2811_400_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
701 case WS2813_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
702 case TM1803_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
703 case UCS1903_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
704 #endif
705 #ifdef HAS_PORTDC
706 case WS2811_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
707 case WS2811_400_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
708 case WS2813_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
709 case TM1803_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
710 case UCS1903_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
711 #endif
712 }
713 }
714
716 template<EBlockChipsets CHIPSET, int NUM_LANES>
717 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
718 return addLeds<CHIPSET,NUM_LANES,GRB>(data,nLedsOrOffset,nLedsIfOffset);
719 }
721#endif
722
725 void setBrightness(uint8_t scale) { m_Scale = scale; }
726
729 uint8_t getBrightness() { return m_Scale; }
730
734 inline void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps) { setMaxPowerInMilliWatts(volts * milliamps); }
735
738 inline void setMaxPowerInMilliWatts(uint32_t milliwatts) { m_pPowerFunc = &calculate_max_brightness_for_power_mW; m_nPowerData = milliwatts; }
739
742 void show(uint8_t scale);
743
745 void show() { show(m_Scale); }
746
750 void clear(bool writeData = false);
751
753 void clearData();
754
758 void showColor(const struct CRGB & color, uint8_t scale);
759
762 void showColor(const struct CRGB & color) { showColor(color, m_Scale); }
763
768 void delay(unsigned long ms);
769
773 void setTemperature(const struct CRGB & temp);
774
778 void setCorrection(const struct CRGB & correction);
779
783 void setDither(uint8_t ditherMode = BINARY_DITHER);
784
792 void setMaxRefreshRate(uint16_t refresh, bool constrain=false);
793
798 void countFPS(int nFrames=25);
799
802 uint16_t getFPS() { return m_nFPS; }
803
806 int count();
807
810 CLEDController & operator[](int x);
811
814 int size();
815
818 CRGB *leds();
819};
820
822#define FastSPI_LED FastLED
824#define FastSPI_LED2 FastLED
825#ifndef LEDS
827#define LEDS FastLED
828#endif
829
831extern CFastLED FastLED;
832
836#ifndef HAS_HARDWARE_PIN_SUPPORT
837#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
838#define NO_HARDWARE_PIN_SUPPORT
839#endif
840
841
843
844#endif
845
846#ifdef FASTLED_UI
847// As a convenience, include the UI headers and bring them into the global namespace
848#include "fl/ui.h"
849using fl::UIButton;
850using fl::UICheckbox;
852using fl::UISlider;
853#define FASTLED_TITLE(text) fl::UITitle g_title(text)
854#define FASTLED_DESCRIPTION(text) fl::UIDescription g_description(text)
855#endif // FASTLED_UI
856
SWS2812
WS2812Serial Library controller type.
Definition FastLED.h:124
OWS2811
Octo WS2811 LED Library controller types.
Definition FastLED.h:119
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:57
uint8_t(* power_func)(uint8_t scale, uint32_t data)
Typedef for a power consumption calculation function.
Definition FastLED.h:345
ESPIChipsets
LED chipsets with SPI interface.
Definition FastLED.h:94
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:106
@ P9813
P9813 LED chipset.
Definition FastLED.h:100
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
Definition FastLED.h:103
@ SK9822
SK9822 LED chipset.
Definition FastLED.h:102
@ WS2803
WS2803 LED chipset.
Definition FastLED.h:98
@ WS2801
WS2801 LED chipset.
Definition FastLED.h:97
@ DOTSTAR
APA102 LED chipset alias.
Definition FastLED.h:104
@ APA102
APA102 LED chipset.
Definition FastLED.h:101
@ LPD8806
LPD8806 LED chipset.
Definition FastLED.h:96
@ HD107HD
Same as APA102, but in turbo 40-mhz mode.
Definition FastLED.h:108
@ LPD6803
LPD6803 LED chipset.
Definition FastLED.h:95
@ DOTSTARHD
APA102HD LED chipset alias.
Definition FastLED.h:105
@ SM16716
SM16716 LED chipset.
Definition FastLED.h:99
ESM
Smart Matrix Library controller type.
Definition FastLED.h:114
EBlockChipsets
Blockless output port enum.
Definition FastLED.h:301
Functions for doing a rotation of bits/bytes used by parallel output.
Contains the bulk of the definitions for the various LED chipsets supported.
APA102 high definition controller class.
Definition chipsets.h:536
APA102 controller class.
Definition chipsets.h:371
APA104 controller class.
Definition FastLED.h:251
APA106 controller class.
Definition FastLED.h:231
High level controller interface for FastLED.
Definition FastLED.h:353
int size()
Get the number of leds in the first controller.
Definition FastLED.cpp:83
void setMaxRefreshRate(uint16_t refresh, bool constrain=false)
Set the maximum refresh rate.
Definition FastLED.cpp:338
CRGB * leds()
Get a pointer to led data for the first controller.
Definition FastLED.cpp:87
void setTemperature(const struct CRGB &temp)
Set a global color temperature.
Definition FastLED.cpp:247
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world.
Definition FastLED.h:463
void show()
Update all our controllers with the current led colors.
Definition FastLED.h:745
void showColor(const struct CRGB &color)
Set all leds on all controllers to the given color.
Definition FastLED.h:762
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
Definition FastLED.cpp:322
CLEDController & operator[](int x)
Get a reference to a registered controller.
Definition FastLED.cpp:164
void delay(unsigned long ms)
Delay for the given number of milliseconds.
Definition FastLED.cpp:233
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:725
void showColor(const struct CRGB &color, uint8_t scale)
Set all leds on all controllers to the given color/scale.
Definition FastLED.cpp:176
void setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode.
Definition FastLED.cpp:263
void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps)
Set the maximum power to be used, given in volts and milliamps.
Definition FastLED.h:734
uint16_t getFPS()
Get the number of frames/second being written out.
Definition FastLED.h:802
void setMaxPowerInMilliWatts(uint32_t milliwatts)
Set the maximum power to be used, given in milliwatts.
Definition FastLED.h:738
uint8_t getBrightness()
Get the current global brightness setting.
Definition FastLED.h:729
void clearData()
Clear out the local data array.
Definition FastLED.cpp:225
void setCorrection(const struct CRGB &correction)
Set a global color correction.
Definition FastLED.cpp:255
int count()
Get how many controllers have been registered.
Definition FastLED.cpp:154
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a 3rd party library based CLEDController instance to the world.
Definition FastLED.h:592
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
Definition FastLED.cpp:218
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a clockless based CLEDController instance to the world.
Definition FastLED.h:530
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:91
Base definition for an LED controller.
DMX512 based LED controller class, using the DMXSerial library.
Definition FastLED.h:293
DMX512 based LED controller class, using the DmxSimple library.
Definition FastLED.h:289
DMX512 based LED controller class, using the DMXSerial library.
Definition dmx.h:64
DMX512 based LED controller class, using the DmxSimple library.
Definition dmx.h:28
GE8822 controller class.
Definition chipsets.h:767
GE8822 controller class.
Definition FastLED.h:261
GS1903 controller class.
Definition FastLED.h:216
GW6205_400 controller class.
Definition FastLED.h:271
GW6205 controller class @ 400 KHz.
Definition chipsets.h:868
UCS1904 controller class @ 800 KHz.
Definition chipsets.h:873
GW6205 controller class.
Definition FastLED.h:266
LPD1886_8BIT controller class.
Definition FastLED.h:281
LPD1886 controller class.
Definition chipsets.h:777
LPD1886 controller class.
Definition chipsets.h:772
LPD1886 controller class.
Definition FastLED.h:276
LPD6803 controller class (LPD1101).
Definition chipsets.h:308
LPD8806 controller class.
Definition chipsets.h:227
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:138
P9813 controller class.
Definition chipsets.h:631
PL9823 controller class.
Definition chipsets.h:878
PL9823 controller class.
Definition FastLED.h:236
SK6812 controller class.
Definition chipsets.h:828
SK6812 controller class.
Definition FastLED.h:221
SK6822 controller class.
Definition chipsets.h:818
SK6822 controller class.
Definition FastLED.h:226
SK9822 controller class.
Definition chipsets.h:583
SK9822 controller class.
Definition chipsets.h:561
SM16703 controller class.
Definition chipsets.h:823
SM16703 controller class.
Definition FastLED.h:143
SM16716 controller class.
Definition chipsets.h:681
TM1803 controller class.
Definition chipsets.h:858
TM1803 controller class.
Definition FastLED.h:168
TM1804 controller class.
Definition FastLED.h:163
TM1809 controller class.
Definition chipsets.h:853
TM1809 controller class.
Definition FastLED.h:158
TM1812 controller class.
Definition FastLED.h:153
TM1829 controller class.
Definition chipsets.h:863
TM1829 controller class.
Definition FastLED.h:148
UCS1903B controller class.
Definition chipsets.h:838
UCS1903B controller class.
Definition FastLED.h:178
UCS1903 controller class @ 400 KHz.
Definition chipsets.h:833
UCS1903 controller class.
Definition FastLED.h:173
UCS1904 controller class.
Definition chipsets.h:843
UCS1904 controller class.
Definition FastLED.h:183
UCS1912 controller class.
Definition FastLED.h:285
UCS2903 controller class.
Definition chipsets.h:848
UCS2903 controller class.
Definition FastLED.h:188
WS2801 controller class.
Definition chipsets.h:270
WS2803 controller class.
Definition chipsets.h:297
WS2811_400 controller class.
Definition FastLED.h:256
WS2811 controller class @ 400 KHz.
Definition chipsets.h:813
WS2811 controller class @ 800 KHz.
Definition chipsets.h:793
WS2811 controller class.
Definition FastLED.h:241
WS2812B controller class.
Definition FastLED.h:211
WS2812 controller class @ 800 KHz.
Definition chipsets.h:783
WS2812 controller class.
Definition FastLED.h:193
WS2813 controller class.
Definition chipsets.h:808
WS2813 controller class.
Definition FastLED.h:246
WS2815 controller class @ 400 KHz.
Definition chipsets.h:788
WS2815 controller class.
Definition FastLED.h:197
WS2816 controller class.
Definition FastLED.h:201
WS2852 controller class.
Definition FastLED.h:206
Declarations for the predefined color palettes supplied by FastLED.
Utility functions for color fill, palettes, blending, and more.
deprecated: base definitions used by led controllers for writing out led data
Compatibility functions based on C++ version.
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Definition dither_mode.h:13
Defines the DMX512-based LED controllers.
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
Definition eorder.h:14
@ RGB
Red, Green, Blue (0012)
Definition eorder.h:15
Contains definitions that can be used to configure FastLED at compile time.
Utility functions and classes for managing delay cycles.
#define NS(_NS)
Convert from nanoseconds to number of clock cycles.
Wrapper definitions to allow seamless use of PROGMEM in environments that have it.
Class base definitions for defining fast pin access.
Serial peripheral interface (SPI) definitions per platform.
Data types and constants used by SPI interfaces.
uint8_t calculate_max_brightness_for_power_mW(const CRGB *ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_mW)
Determines the highest brightness level you can use and still stay under the specified power budget f...
Definition power_mgt.cpp:95
Functions to convert from the HSV colorspace to the RGB colorspace.
Determines which platform system definitions to include.
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14
Functions to generate and fill arrays with noise.
Declares classes for managing logical groups of LEDs.
Includes defintions for RGB and HSV pixels.
Determines which platforms headers to include.
Functions to limit the power used by FastLED.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54