FastLED 3.9.7
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 3009007
20#ifndef FASTLED_INTERNAL
21# ifdef FASTLED_SHOW_VERSION
22# ifdef FASTLED_HAS_PRAGMA_MESSAGE
23# pragma message "FastLED version 3.009.007"
24# else
25# warning FastLED version 3.009.007 (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
108
111enum ESM { SMART_MATRIX };
112
116enum OWS2811 { OCTOWS2811,OCTOWS2811_400, OCTOWS2813};
117
121enum SWS2812 { WS2812SERIAL };
122
123#ifdef HAS_PIXIE
124template<uint8_t DATA_PIN, EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
125#endif
126
127#ifdef FASTLED_HAS_CLOCKLESS
132
135template<uint8_t DATA_PIN> class NEOPIXEL : public WS2812Controller800Khz<DATA_PIN, GRB> {};
136
139template<uint8_t DATA_PIN, EOrder RGB_ORDER>
140class SM16703 : public SM16703Controller<DATA_PIN, RGB_ORDER> {};
141
144template<uint8_t DATA_PIN, EOrder RGB_ORDER>
145class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
146
149template<uint8_t DATA_PIN, EOrder RGB_ORDER>
150class TM1812 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
151
154template<uint8_t DATA_PIN, EOrder RGB_ORDER>
155class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
156
159template<uint8_t DATA_PIN, EOrder RGB_ORDER>
160class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
161
164template<uint8_t DATA_PIN, EOrder RGB_ORDER>
165class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {};
166
169template<uint8_t DATA_PIN, EOrder RGB_ORDER>
170class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {};
171
174template<uint8_t DATA_PIN, EOrder RGB_ORDER>
175class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {};
176
179template<uint8_t DATA_PIN, EOrder RGB_ORDER>
180class UCS1904 : public UCS1904Controller800Khz<DATA_PIN, RGB_ORDER> {};
181
184template<uint8_t DATA_PIN, EOrder RGB_ORDER>
185class UCS2903 : public UCS2903Controller<DATA_PIN, RGB_ORDER> {};
186
189template<uint8_t DATA_PIN, EOrder RGB_ORDER>
190class WS2812 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
191
193template<uint8_t DATA_PIN, EOrder RGB_ORDER>
194class WS2815 : public WS2815Controller<DATA_PIN, RGB_ORDER> {};
195
198template<uint8_t DATA_PIN, EOrder RGB_ORDER>
199class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
200
203template<uint8_t DATA_PIN, EOrder RGB_ORDER>
204class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
205
208template<uint8_t DATA_PIN, EOrder RGB_ORDER>
209class GS1903 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
210
213template<uint8_t DATA_PIN, EOrder RGB_ORDER>
214class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
215
218template<uint8_t DATA_PIN, EOrder RGB_ORDER>
219class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
220
223template<uint8_t DATA_PIN, EOrder RGB_ORDER>
224class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
225
228template<uint8_t DATA_PIN, EOrder RGB_ORDER>
229class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
230
233template<uint8_t DATA_PIN, EOrder RGB_ORDER>
234class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
235
238template<uint8_t DATA_PIN, EOrder RGB_ORDER>
239class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
240
243template<uint8_t DATA_PIN, EOrder RGB_ORDER>
244class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
245
248template<uint8_t DATA_PIN, EOrder RGB_ORDER>
249class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
250
253template<uint8_t DATA_PIN, EOrder RGB_ORDER>
254class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
255
258template<uint8_t DATA_PIN, EOrder RGB_ORDER>
259class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
260
263template<uint8_t DATA_PIN, EOrder RGB_ORDER>
264class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
265
268template<uint8_t DATA_PIN, EOrder RGB_ORDER>
269class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
270
273template<uint8_t DATA_PIN, EOrder RGB_ORDER>
274class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
275
277template<uint8_t DATA_PIN, EOrder RGB_ORDER>
278class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
279
280#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
282template<uint8_t DATA_PIN, EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
283#endif
284#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
286template<EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
287#endif
288#endif
291
292
295#ifdef PORTA_FIRST_PIN
296 WS2811_PORTA,
297 WS2813_PORTA,
298 WS2811_400_PORTA,
299 TM1803_PORTA,
300 UCS1903_PORTA,
301#endif
302#ifdef PORTB_FIRST_PIN
303 WS2811_PORTB,
304 WS2813_PORTB,
305 WS2811_400_PORTB,
306 TM1803_PORTB,
307 UCS1903_PORTB,
308#endif
309#ifdef PORTC_FIRST_PIN
310 WS2811_PORTC,
311 WS2813_PORTC,
312 WS2811_400_PORTC,
313 TM1803_PORTC,
314 UCS1903_PORTC,
315#endif
316#ifdef PORTD_FIRST_PIN
317 WS2811_PORTD,
318 WS2813_PORTD,
319 WS2811_400_PORTD,
320 TM1803_PORTD,
321 UCS1903_PORTD,
322#endif
323#ifdef HAS_PORTDC
324 WS2811_PORTDC,
325 WS2813_PORTDC,
326 WS2811_400_PORTDC,
327 TM1803_PORTDC,
328 UCS1903_PORTDC,
329#endif
330};
331
332#if defined(LIB8_ATTINY)
333#define NUM_CONTROLLERS 2
334#else
337#define NUM_CONTROLLERS 8
338#endif
339
346typedef uint8_t (*power_func)(uint8_t scale, uint32_t data);
347
354class CFastLED {
355 // int m_nControllers;
356 uint8_t m_Scale;
357 uint16_t m_nFPS;
358 uint32_t m_nMinMicros;
359 uint32_t m_nPowerData;
360 power_func m_pPowerFunc;
361
362public:
363 CFastLED();
364
365 // Useful when you want to know when an event like onFrameBegin or onFrameEnd is happening.
366 // This is disabled on AVR to save space.
367 void addListener(fl::EngineEvents::Listener *listener) { fl::EngineEvents::addListener(listener); }
368 void removeListener(fl::EngineEvents::Listener *listener) { fl::EngineEvents::removeListener(listener); }
369
381 static CLEDController &addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0);
382
402
403
404 // Base template: Causes a compile-time error if an unsupported CHIPSET is used
405 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN>
407 // Default implementation, will be specialized for supported chipsets
408 static const bool IS_VALID = false;
409 };
410
411 // Macro to define a mapping from the ESPIChipeset enum to the controller class
412 // in it's various template configurations.
413 #define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS) \
414 template<uint8_t DATA_PIN, uint8_t CLOCK_PIN> \
415 struct ClockedChipsetHelper<CHIPSET_ENUM, DATA_PIN, CLOCK_PIN> { \
416 static const bool IS_VALID = true; \
417 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN> ControllerType; \
418 /* Controller type with RGB_ORDER specified */ \
419 template<EOrder RGB_ORDER> \
420 struct CONTROLLER_CLASS_WITH_ORDER { \
421 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER> ControllerType; \
422 }; \
423 /* Controller type with RGB_ORDER and spi frequency specified */ \
424 template<EOrder RGB_ORDER, uint32_t FREQ> \
425 struct CONTROLLER_CLASS_WITH_ORDER_AND_FREQ { \
426 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER, FREQ> ControllerType; \
427 }; \
428 };
429
430 // Define specializations for each supported CHIPSET
431 _FL_MAP_CLOCKED_CHIPSET(LPD6803, LPD6803Controller)
432 _FL_MAP_CLOCKED_CHIPSET(LPD8806, LPD8806Controller)
433 _FL_MAP_CLOCKED_CHIPSET(WS2801, WS2801Controller)
434 _FL_MAP_CLOCKED_CHIPSET(WS2803, WS2803Controller)
435 _FL_MAP_CLOCKED_CHIPSET(SM16716, SM16716Controller)
436 _FL_MAP_CLOCKED_CHIPSET(P9813, P9813Controller)
437
438 // Both DOTSTAR and APA102 use the same controller class
439 _FL_MAP_CLOCKED_CHIPSET(DOTSTAR, APA102Controller)
440 _FL_MAP_CLOCKED_CHIPSET(APA102, APA102Controller)
441
442 // Both DOTSTARHD and APA102HD use the same controller class
443 _FL_MAP_CLOCKED_CHIPSET(DOTSTARHD, APA102ControllerHD)
444 _FL_MAP_CLOCKED_CHIPSET(APA102HD, APA102ControllerHD)
445
446 _FL_MAP_CLOCKED_CHIPSET(SK9822, SK9822Controller)
447 _FL_MAP_CLOCKED_CHIPSET(SK9822HD, SK9822ControllerHD)
448
449
450
451 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) {
452 // Instantiate the controller using ClockedChipsetHelper
454 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
455 static_assert(CHIP::IS_VALID, "Unsupported chipset");
456 static ControllerTypeWithFreq c;
457 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
458 }
459
461 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
463 typedef typename CHIP::ControllerType ControllerType;
464 static_assert(CHIP::IS_VALID, "Unsupported chipset");
465 static ControllerType c;
466 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
467 }
468
469
470 // The addLeds function using ChipsetHelper
471 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER>
472 CLEDController& addLeds(struct CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
473 typedef ClockedChipsetHelper<CHIPSET, DATA_PIN, CLOCK_PIN> CHIP;
474 static_assert(CHIP::IS_VALID, "Unsupported chipset");
475 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
476 static ControllerTypeWithOrder c;
477 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
478 }
479
480
481#ifdef SPI_DATA
482 template<ESPIChipsets CHIPSET> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
483 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB>(data, nLedsOrOffset, nLedsIfOffset);
484 }
485
486 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
487 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER>(data, nLedsOrOffset, nLedsIfOffset);
488 }
489
490 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
491 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE>(data, nLedsOrOffset, nLedsIfOffset);
492 }
493
494#endif
496
497#ifdef FASTLED_HAS_CLOCKLESS
518
520 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
521 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
522 static CHIPSET<DATA_PIN, RGB_ORDER> c;
523 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
524 }
525
527 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN>
528 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
529 static CHIPSET<DATA_PIN, RGB> c;
530 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
531 }
532
534 template<template<uint8_t DATA_PIN> class CHIPSET, uint8_t DATA_PIN>
535 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
536 static CHIPSET<DATA_PIN> c;
537 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
538 }
539
540#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
541 template<uint8_t NUM_LANES, template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
542 static CLEDController &addLeds(struct CRGB *data, int nLeds) {
543 static __FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
544 return addLeds(&c, data, nLeds);
545 }
546#endif
547
548 #ifdef FASTSPI_USE_DMX_SIMPLE
549 template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
550 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
551 {
552 switch(CHIPSET) {
553 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
554 }
555 }
556 #endif
558#endif
559
580
582 template<template<EOrder RGB_ORDER> class CHIPSET, EOrder RGB_ORDER>
583 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
584 static CHIPSET<RGB_ORDER> c;
585 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
586 }
587
589 template<template<EOrder RGB_ORDER> class CHIPSET>
590 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
591 static CHIPSET<RGB> c;
592 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
593 }
594
595#ifdef USE_OCTOWS2811
599 template<OWS2811 CHIPSET, EOrder RGB_ORDER>
600 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
601 {
602 switch(CHIPSET) {
603 case OCTOWS2811: { static COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
604 case OCTOWS2811_400: { static COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
605#ifdef WS2813_800kHz
606 case OCTOWS2813: { static COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
607#endif
608 }
609 }
610
614 template<OWS2811 CHIPSET>
615 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
616 {
617 return addLeds<CHIPSET,GRB>(data,nLedsOrOffset,nLedsIfOffset);
618 }
619
620#endif
621
622#ifdef USE_WS2812SERIAL
626 template<SWS2812 CHIPSET, int DATA_PIN, EOrder RGB_ORDER>
627 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
628 {
629 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
630 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
631 }
632#endif
633
634#ifdef SmartMatrix_h
637 template<ESM CHIPSET>
638 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
639 {
640 switch(CHIPSET) {
641 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
642 }
643 }
644#endif
646
647
648#ifdef FASTLED_HAS_BLOCKLESS
649
670
672 template<EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
673 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
674 switch(CHIPSET) {
675 #ifdef PORTA_FIRST_PIN
676 case WS2811_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
677 case WS2811_400_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
678 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);
679 case TM1803_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
680 case UCS1903_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
681 #endif
682 #ifdef PORTB_FIRST_PIN
683 case WS2811_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
684 case WS2811_400_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
685 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);
686 case TM1803_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
687 case UCS1903_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
688 #endif
689 #ifdef PORTC_FIRST_PIN
690 case WS2811_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
691 case WS2811_400_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
692 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);
693 case TM1803_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
694 case UCS1903_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
695 #endif
696 #ifdef PORTD_FIRST_PIN
697 case WS2811_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
698 case WS2811_400_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
699 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);
700 case TM1803_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
701 case UCS1903_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
702 #endif
703 #ifdef HAS_PORTDC
704 case WS2811_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
705 case WS2811_400_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
706 case WS2813_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
707 case TM1803_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
708 case UCS1903_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
709 #endif
710 }
711 }
712
714 template<EBlockChipsets CHIPSET, int NUM_LANES>
715 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
716 return addLeds<CHIPSET,NUM_LANES,GRB>(data,nLedsOrOffset,nLedsIfOffset);
717 }
719#endif
720
723 void setBrightness(uint8_t scale) { m_Scale = scale; }
724
727 uint8_t getBrightness() { return m_Scale; }
728
732 inline void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps) { setMaxPowerInMilliWatts(volts * milliamps); }
733
736 inline void setMaxPowerInMilliWatts(uint32_t milliwatts) { m_pPowerFunc = &calculate_max_brightness_for_power_mW; m_nPowerData = milliwatts; }
737
740 void show(uint8_t scale);
741
743 void show() { show(m_Scale); }
744
748 void clear(bool writeData = false);
749
751 void clearData();
752
756 void showColor(const struct CRGB & color, uint8_t scale);
757
760 void showColor(const struct CRGB & color) { showColor(color, m_Scale); }
761
766 void delay(unsigned long ms);
767
771 void setTemperature(const struct CRGB & temp);
772
776 void setCorrection(const struct CRGB & correction);
777
781 void setDither(uint8_t ditherMode = BINARY_DITHER);
782
790 void setMaxRefreshRate(uint16_t refresh, bool constrain=false);
791
796 void countFPS(int nFrames=25);
797
800 uint16_t getFPS() { return m_nFPS; }
801
804 int count();
805
808 CLEDController & operator[](int x);
809
812 int size();
813
816 CRGB *leds();
817};
818
820#define FastSPI_LED FastLED
822#define FastSPI_LED2 FastLED
823#ifndef LEDS
825#define LEDS FastLED
826#endif
827
829extern CFastLED FastLED;
830
834#ifndef HAS_HARDWARE_PIN_SUPPORT
835#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
836#define NO_HARDWARE_PIN_SUPPORT
837#endif
838
839
841
842#endif
843
844#ifdef FASTLED_UI
845// As a convenience, include the UI headers and bring them into the global namespace
846#include "fl/ui.h"
847using fl::Button;
848using fl::Checkbox;
849using fl::NumberField;
850using fl::Slider;
851#define FASTLED_TITLE(text) fl::Title g_title(text)
852#define FASTLED_DESCRIPTION(text) fl::Description g_description(text)
853#endif // FASTLED_UI
854
SWS2812
WS2812Serial Library controller type.
Definition FastLED.h:121
OWS2811
Octo WS2811 LED Library controller types.
Definition FastLED.h:116
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
uint8_t(* power_func)(uint8_t scale, uint32_t data)
Typedef for a power consumption calculation function.
Definition FastLED.h:346
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
@ 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:111
EBlockChipsets
Blockless output port enum.
Definition FastLED.h:294
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:497
APA102 controller class.
Definition chipsets.h:331
APA104 controller class.
Definition FastLED.h:244
APA106 controller class.
Definition FastLED.h:224
High level controller interface for FastLED.
Definition FastLED.h:354
int size()
Get the number of leds in the first controller.
Definition FastLED.cpp:71
void setMaxRefreshRate(uint16_t refresh, bool constrain=false)
Set the maximum refresh rate.
Definition FastLED.cpp:295
CRGB * leds()
Get a pointer to led data for the first controller.
Definition FastLED.cpp:75
void setTemperature(const struct CRGB &temp)
Set a global color temperature.
Definition FastLED.cpp:204
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world.
Definition FastLED.h:461
void show()
Update all our controllers with the current led colors.
Definition FastLED.h:743
void showColor(const struct CRGB &color)
Set all leds on all controllers to the given color.
Definition FastLED.h:760
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
Definition FastLED.cpp:279
CLEDController & operator[](int x)
Get a reference to a registered controller.
Definition FastLED.cpp:136
void delay(unsigned long ms)
Delay for the given number of milliseconds.
Definition FastLED.cpp:190
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:723
void showColor(const struct CRGB &color, uint8_t scale)
Set all leds on all controllers to the given color/scale.
Definition FastLED.cpp:148
void setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode.
Definition FastLED.cpp:220
void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps)
Set the maximum power to be used, given in volts and milliamps.
Definition FastLED.h:732
uint16_t getFPS()
Get the number of frames/second being written out.
Definition FastLED.h:800
void setMaxPowerInMilliWatts(uint32_t milliwatts)
Set the maximum power to be used, given in milliwatts.
Definition FastLED.h:736
uint8_t getBrightness()
Get the current global brightness setting.
Definition FastLED.h:727
void clearData()
Clear out the local data array.
Definition FastLED.cpp:182
void setCorrection(const struct CRGB &correction)
Set a global color correction.
Definition FastLED.cpp:212
int count()
Get how many controllers have been registered.
Definition FastLED.cpp:126
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:590
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
Definition FastLED.cpp:175
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a clockless based CLEDController instance to the world.
Definition FastLED.h:528
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
Base definition for an LED controller.
DMX512 based LED controller class, using the DMXSerial library.
Definition FastLED.h:286
DMX512 based LED controller class, using the DmxSimple library.
Definition FastLED.h:282
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:697
GE8822 controller class.
Definition FastLED.h:254
GS1903 controller class.
Definition FastLED.h:209
GW6205_400 controller class.
Definition FastLED.h:264
GW6205 controller class @ 400 KHz.
Definition chipsets.h:798
UCS1904 controller class @ 800 KHz.
Definition chipsets.h:803
GW6205 controller class.
Definition FastLED.h:259
LPD1886_8BIT controller class.
Definition FastLED.h:274
LPD1886 controller class.
Definition chipsets.h:707
LPD1886 controller class.
Definition chipsets.h:702
LPD1886 controller class.
Definition FastLED.h:269
LPD6803 controller class (LPD1101).
Definition chipsets.h:268
LPD8806 controller class.
Definition chipsets.h:187
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:135
P9813 controller class.
Definition chipsets.h:561
PL9823 controller class.
Definition chipsets.h:808
PL9823 controller class.
Definition FastLED.h:229
SK6812 controller class.
Definition chipsets.h:758
SK6812 controller class.
Definition FastLED.h:214
SK6822 controller class.
Definition chipsets.h:748
SK6822 controller class.
Definition FastLED.h:219
SK9822 controller class.
Definition chipsets.h:544
SK9822 controller class.
Definition chipsets.h:522
SM16703 controller class.
Definition chipsets.h:753
SM16703 controller class.
Definition FastLED.h:140
SM16716 controller class.
Definition chipsets.h:611
TM1803 controller class.
Definition chipsets.h:788
TM1803 controller class.
Definition FastLED.h:165
TM1804 controller class.
Definition FastLED.h:160
TM1809 controller class.
Definition chipsets.h:783
TM1809 controller class.
Definition FastLED.h:155
TM1812 controller class.
Definition FastLED.h:150
TM1829 controller class.
Definition chipsets.h:793
TM1829 controller class.
Definition FastLED.h:145
UCS1903B controller class.
Definition chipsets.h:768
UCS1903B controller class.
Definition FastLED.h:175
UCS1903 controller class @ 400 KHz.
Definition chipsets.h:763
UCS1903 controller class.
Definition FastLED.h:170
UCS1904 controller class.
Definition chipsets.h:773
UCS1904 controller class.
Definition FastLED.h:180
UCS1912 controller class.
Definition FastLED.h:278
UCS2903 controller class.
Definition chipsets.h:778
UCS2903 controller class.
Definition FastLED.h:185
WS2801 controller class.
Definition chipsets.h:230
WS2803 controller class.
Definition chipsets.h:257
WS2811_400 controller class.
Definition FastLED.h:249
WS2811 controller class @ 400 KHz.
Definition chipsets.h:743
WS2811 controller class @ 800 KHz.
Definition chipsets.h:723
WS2811 controller class.
Definition FastLED.h:234
WS2812B controller class.
Definition FastLED.h:204
WS2812 controller class @ 800 KHz.
Definition chipsets.h:713
WS2812 controller class.
Definition FastLED.h:190
WS2813 controller class.
Definition chipsets.h:738
WS2813 controller class.
Definition FastLED.h:239
WS2815 controller class @ 400 KHz.
Definition chipsets.h:718
WS2815 controller class.
Definition FastLED.h:194
WS2852 controller class.
Definition FastLED.h:199
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