FastLED 3.9.3
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 3009003
20#ifndef FASTLED_INTERNAL
21# ifdef FASTLED_SHOW_VERSION
22# ifdef FASTLED_HAS_PRAGMA_MESSAGE
23# pragma message "FastLED version 3.009.003"
24# else
25# warning FastLED version 3.009.003 (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 "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 "engine_events.h"
86
87FASTLED_NAMESPACE_BEGIN
88
89
90
91
107
110enum ESM { SMART_MATRIX };
111
115enum OWS2811 { OCTOWS2811,OCTOWS2811_400, OCTOWS2813};
116
120enum SWS2812 { WS2812SERIAL };
121
122#ifdef HAS_PIXIE
123template<uint8_t DATA_PIN, EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
124#endif
125
126#ifdef FASTLED_HAS_CLOCKLESS
131
134template<uint8_t DATA_PIN> class NEOPIXEL : public WS2812Controller800Khz<DATA_PIN, GRB> {};
135
138template<uint8_t DATA_PIN, EOrder RGB_ORDER>
139class SM16703 : public SM16703Controller<DATA_PIN, RGB_ORDER> {};
140
143template<uint8_t DATA_PIN, EOrder RGB_ORDER>
144class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
145
148template<uint8_t DATA_PIN, EOrder RGB_ORDER>
149class TM1812 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
150
153template<uint8_t DATA_PIN, EOrder RGB_ORDER>
154class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
155
158template<uint8_t DATA_PIN, EOrder RGB_ORDER>
159class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
160
163template<uint8_t DATA_PIN, EOrder RGB_ORDER>
164class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {};
165
168template<uint8_t DATA_PIN, EOrder RGB_ORDER>
169class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {};
170
173template<uint8_t DATA_PIN, EOrder RGB_ORDER>
174class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {};
175
178template<uint8_t DATA_PIN, EOrder RGB_ORDER>
179class UCS1904 : public UCS1904Controller800Khz<DATA_PIN, RGB_ORDER> {};
180
183template<uint8_t DATA_PIN, EOrder RGB_ORDER>
184class UCS2903 : public UCS2903Controller<DATA_PIN, RGB_ORDER> {};
185
188template<uint8_t DATA_PIN, EOrder RGB_ORDER>
189class WS2812 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
190
192template<uint8_t DATA_PIN, EOrder RGB_ORDER>
193class WS2815 : public WS2815Controller<DATA_PIN, RGB_ORDER> {};
194
197template<uint8_t DATA_PIN, EOrder RGB_ORDER>
198class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
199
202template<uint8_t DATA_PIN, EOrder RGB_ORDER>
203class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
204
207template<uint8_t DATA_PIN, EOrder RGB_ORDER>
208class GS1903 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
209
212template<uint8_t DATA_PIN, EOrder RGB_ORDER>
213class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
214
217template<uint8_t DATA_PIN, EOrder RGB_ORDER>
218class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
219
222template<uint8_t DATA_PIN, EOrder RGB_ORDER>
223class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
224
227template<uint8_t DATA_PIN, EOrder RGB_ORDER>
228class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
229
232template<uint8_t DATA_PIN, EOrder RGB_ORDER>
233class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
234
237template<uint8_t DATA_PIN, EOrder RGB_ORDER>
238class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
239
242template<uint8_t DATA_PIN, EOrder RGB_ORDER>
243class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
244
247template<uint8_t DATA_PIN, EOrder RGB_ORDER>
248class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
249
252template<uint8_t DATA_PIN, EOrder RGB_ORDER>
253class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
254
257template<uint8_t DATA_PIN, EOrder RGB_ORDER>
258class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
259
262template<uint8_t DATA_PIN, EOrder RGB_ORDER>
263class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
264
267template<uint8_t DATA_PIN, EOrder RGB_ORDER>
268class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
269
272template<uint8_t DATA_PIN, EOrder RGB_ORDER>
273class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
274
276template<uint8_t DATA_PIN, EOrder RGB_ORDER>
277class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
278
279#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
281template<uint8_t DATA_PIN, EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
282#endif
283#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
285template<EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
286#endif
287#endif
290
291
294#ifdef PORTA_FIRST_PIN
295 WS2811_PORTA,
296 WS2813_PORTA,
297 WS2811_400_PORTA,
298 TM1803_PORTA,
299 UCS1903_PORTA,
300#endif
301#ifdef PORTB_FIRST_PIN
302 WS2811_PORTB,
303 WS2813_PORTB,
304 WS2811_400_PORTB,
305 TM1803_PORTB,
306 UCS1903_PORTB,
307#endif
308#ifdef PORTC_FIRST_PIN
309 WS2811_PORTC,
310 WS2813_PORTC,
311 WS2811_400_PORTC,
312 TM1803_PORTC,
313 UCS1903_PORTC,
314#endif
315#ifdef PORTD_FIRST_PIN
316 WS2811_PORTD,
317 WS2813_PORTD,
318 WS2811_400_PORTD,
319 TM1803_PORTD,
320 UCS1903_PORTD,
321#endif
322#ifdef HAS_PORTDC
323 WS2811_PORTDC,
324 WS2813_PORTDC,
325 WS2811_400_PORTDC,
326 TM1803_PORTDC,
327 UCS1903_PORTDC,
328#endif
329};
330
331#if defined(LIB8_ATTINY)
332#define NUM_CONTROLLERS 2
333#else
336#define NUM_CONTROLLERS 8
337#endif
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(EngineEvents::Listener *listener) { EngineEvents::addListener(listener); }
367 void removeListener(EngineEvents::Listener *listener) { 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(SK9822, SK9822Controller)
446 _FL_MAP_CLOCKED_CHIPSET(SK9822HD, SK9822ControllerHD)
447
448
449
450 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) {
451 // Instantiate the controller using ClockedChipsetHelper
453 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
454 static_assert(CHIP::IS_VALID, "Unsupported chipset");
455 static ControllerTypeWithFreq c;
456 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
457 }
458
460 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
462 typedef typename CHIP::ControllerType ControllerType;
463 static_assert(CHIP::IS_VALID, "Unsupported chipset");
464 static ControllerType c;
465 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
466 }
467
468
469 // The addLeds function using ChipsetHelper
470 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER>
471 CLEDController& addLeds(struct CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
472 typedef ClockedChipsetHelper<CHIPSET, DATA_PIN, CLOCK_PIN> CHIP;
473 static_assert(CHIP::IS_VALID, "Unsupported chipset");
474 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
475 static ControllerTypeWithOrder c;
476 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
477 }
478
479
480#ifdef SPI_DATA
481 template<ESPIChipsets CHIPSET> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
482 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB>(data, nLedsOrOffset, nLedsIfOffset);
483 }
484
485 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
486 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER>(data, nLedsOrOffset, nLedsIfOffset);
487 }
488
489 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
490 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE>(data, nLedsOrOffset, nLedsIfOffset);
491 }
492
493#endif
495
496#ifdef FASTLED_HAS_CLOCKLESS
517
519 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
520 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
521 static CHIPSET<DATA_PIN, RGB_ORDER> c;
522 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
523 }
524
526 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN>
527 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
528 static CHIPSET<DATA_PIN, RGB> c;
529 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
530 }
531
533 template<template<uint8_t DATA_PIN> class CHIPSET, uint8_t DATA_PIN>
534 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
535 static CHIPSET<DATA_PIN> c;
536 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
537 }
538
539#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
540 template<uint8_t NUM_LANES, template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
541 static CLEDController &addLeds(struct CRGB *data, int nLeds) {
542 static __FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
543 return addLeds(&c, data, nLeds);
544 }
545#endif
546
547 #ifdef FASTSPI_USE_DMX_SIMPLE
548 template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
549 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
550 {
551 switch(CHIPSET) {
552 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
553 }
554 }
555 #endif
557#endif
558
579
581 template<template<EOrder RGB_ORDER> class CHIPSET, EOrder RGB_ORDER>
582 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
583 static CHIPSET<RGB_ORDER> c;
584 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
585 }
586
588 template<template<EOrder RGB_ORDER> class CHIPSET>
589 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
590 static CHIPSET<RGB> c;
591 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
592 }
593
594#ifdef USE_OCTOWS2811
598 template<OWS2811 CHIPSET, EOrder RGB_ORDER>
599 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
600 {
601 switch(CHIPSET) {
602 case OCTOWS2811: { static COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
603 case OCTOWS2811_400: { static COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
604#ifdef WS2813_800kHz
605 case OCTOWS2813: { static COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
606#endif
607 }
608 }
609
613 template<OWS2811 CHIPSET>
614 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
615 {
616 return addLeds<CHIPSET,GRB>(data,nLedsOrOffset,nLedsIfOffset);
617 }
618
619#endif
620
621#ifdef USE_WS2812SERIAL
625 template<SWS2812 CHIPSET, int DATA_PIN, EOrder RGB_ORDER>
626 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
627 {
628 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
629 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
630 }
631#endif
632
633#ifdef SmartMatrix_h
636 template<ESM CHIPSET>
637 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
638 {
639 switch(CHIPSET) {
640 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
641 }
642 }
643#endif
645
646
647#ifdef FASTLED_HAS_BLOCKLESS
648
669
671 template<EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
672 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
673 switch(CHIPSET) {
674 #ifdef PORTA_FIRST_PIN
675 case WS2811_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
676 case WS2811_400_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
677 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);
678 case TM1803_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
679 case UCS1903_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
680 #endif
681 #ifdef PORTB_FIRST_PIN
682 case WS2811_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
683 case WS2811_400_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
684 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);
685 case TM1803_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
686 case UCS1903_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
687 #endif
688 #ifdef PORTC_FIRST_PIN
689 case WS2811_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
690 case WS2811_400_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
691 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);
692 case TM1803_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
693 case UCS1903_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
694 #endif
695 #ifdef PORTD_FIRST_PIN
696 case WS2811_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
697 case WS2811_400_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
698 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);
699 case TM1803_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
700 case UCS1903_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
701 #endif
702 #ifdef HAS_PORTDC
703 case WS2811_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
704 case WS2811_400_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
705 case WS2813_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
706 case TM1803_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
707 case UCS1903_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
708 #endif
709 }
710 }
711
713 template<EBlockChipsets CHIPSET, int NUM_LANES>
714 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
715 return addLeds<CHIPSET,NUM_LANES,GRB>(data,nLedsOrOffset,nLedsIfOffset);
716 }
718#endif
719
722 void setBrightness(uint8_t scale) { m_Scale = scale; }
723
726 uint8_t getBrightness() { return m_Scale; }
727
731 inline void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps) { setMaxPowerInMilliWatts(volts * milliamps); }
732
735 inline void setMaxPowerInMilliWatts(uint32_t milliwatts) { m_pPowerFunc = &calculate_max_brightness_for_power_mW; m_nPowerData = milliwatts; }
736
739 void show(uint8_t scale);
740
742 void show() { show(m_Scale); }
743
747 void clear(bool writeData = false);
748
750 void clearData();
751
755 void showColor(const struct CRGB & color, uint8_t scale);
756
759 void showColor(const struct CRGB & color) { showColor(color, m_Scale); }
760
765 void delay(unsigned long ms);
766
770 void setTemperature(const struct CRGB & temp);
771
775 void setCorrection(const struct CRGB & correction);
776
780 void setDither(uint8_t ditherMode = BINARY_DITHER);
781
789 void setMaxRefreshRate(uint16_t refresh, bool constrain=false);
790
795 void countFPS(int nFrames=25);
796
799 uint16_t getFPS() { return m_nFPS; }
800
803 int count();
804
807 CLEDController & operator[](int x);
808
811 int size();
812
815 CRGB *leds();
816};
817
819#define FastSPI_LED FastLED
821#define FastSPI_LED2 FastLED
822#ifndef LEDS
824#define LEDS FastLED
825#endif
826
828extern CFastLED FastLED;
829
833#ifndef HAS_HARDWARE_PIN_SUPPORT
834#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
835#define NO_HARDWARE_PIN_SUPPORT
836#endif
837
838
839FASTLED_NAMESPACE_END
840
841#endif
842
843#if !defined(FASTLED_INTERNAL)
844FASTLED_USING_NAMESPACE
845#endif
SWS2812
WS2812Serial Library controller type.
Definition FastLED.h:120
OWS2811
Octo WS2811 LED Library controller types.
Definition FastLED.h:115
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:33
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:93
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:105
@ P9813
P9813 LED chipset.
Definition FastLED.h:99
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
Definition FastLED.h:102
@ SK9822
SK9822 LED chipset.
Definition FastLED.h:101
@ WS2803
WS2803 LED chipset.
Definition FastLED.h:97
@ WS2801
WS2801 LED chipset.
Definition FastLED.h:96
@ DOTSTAR
APA102 LED chipset alias.
Definition FastLED.h:103
@ APA102
APA102 LED chipset.
Definition FastLED.h:100
@ LPD8806
LPD8806 LED chipset.
Definition FastLED.h:95
@ LPD6803
LPD6803 LED chipset.
Definition FastLED.h:94
@ DOTSTARHD
APA102HD LED chipset alias.
Definition FastLED.h:104
@ SM16716
SM16716 LED chipset.
Definition FastLED.h:98
ESM
Smart Matrix Library controller type.
Definition FastLED.h:110
EBlockChipsets
Blockless output port enum.
Definition FastLED.h:293
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:243
APA106 controller class.
Definition FastLED.h:223
High level controller interface for FastLED.
Definition FastLED.h:353
int size()
Get the number of leds in the first controller.
Definition FastLED.cpp:59
void setMaxRefreshRate(uint16_t refresh, bool constrain=false)
Set the maximum refresh rate.
Definition FastLED.cpp:283
CRGB * leds()
Get a pointer to led data for the first controller.
Definition FastLED.cpp:63
void setTemperature(const struct CRGB &temp)
Set a global color temperature.
Definition FastLED.cpp:192
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world.
Definition FastLED.h:460
void show()
Update all our controllers with the current led colors.
Definition FastLED.h:742
void showColor(const struct CRGB &color)
Set all leds on all controllers to the given color.
Definition FastLED.h:759
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
Definition FastLED.cpp:267
CLEDController & operator[](int x)
Get a reference to a registered controller.
Definition FastLED.cpp:124
void delay(unsigned long ms)
Delay for the given number of milliseconds.
Definition FastLED.cpp:178
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:722
void showColor(const struct CRGB &color, uint8_t scale)
Set all leds on all controllers to the given color/scale.
Definition FastLED.cpp:136
void setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode.
Definition FastLED.cpp:208
void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps)
Set the maximum power to be used, given in volts and milliamps.
Definition FastLED.h:731
uint16_t getFPS()
Get the number of frames/second being written out.
Definition FastLED.h:799
void setMaxPowerInMilliWatts(uint32_t milliwatts)
Set the maximum power to be used, given in milliwatts.
Definition FastLED.h:735
uint8_t getBrightness()
Get the current global brightness setting.
Definition FastLED.h:726
void clearData()
Clear out the local data array.
Definition FastLED.cpp:170
void setCorrection(const struct CRGB &correction)
Set a global color correction.
Definition FastLED.cpp:200
int count()
Get how many controllers have been registered.
Definition FastLED.cpp:114
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:589
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
Definition FastLED.cpp:163
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a clockless based CLEDController instance to the world.
Definition FastLED.h:527
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:67
Base definition for an LED controller.
DMX512 based LED controller class, using the DMXSerial library.
Definition FastLED.h:285
DMX512 based LED controller class, using the DmxSimple library.
Definition FastLED.h:281
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:253
GS1903 controller class.
Definition FastLED.h:208
GW6205_400 controller class.
Definition FastLED.h:263
GW6205 controller class @ 400 KHz.
Definition chipsets.h:798
UCS1904 controller class @ 800 KHz.
Definition chipsets.h:803
GW6205 controller class.
Definition FastLED.h:258
LPD1886_8BIT controller class.
Definition FastLED.h:273
LPD1886 controller class.
Definition chipsets.h:707
LPD1886 controller class.
Definition chipsets.h:702
LPD1886 controller class.
Definition FastLED.h:268
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:134
P9813 controller class.
Definition chipsets.h:561
PL9823 controller class.
Definition chipsets.h:808
PL9823 controller class.
Definition FastLED.h:228
SK6812 controller class.
Definition chipsets.h:758
SK6812 controller class.
Definition FastLED.h:213
SK6822 controller class.
Definition chipsets.h:748
SK6822 controller class.
Definition FastLED.h:218
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:139
SM16716 controller class.
Definition chipsets.h:611
TM1803 controller class.
Definition chipsets.h:788
TM1803 controller class.
Definition FastLED.h:164
TM1804 controller class.
Definition FastLED.h:159
TM1809 controller class.
Definition chipsets.h:783
TM1809 controller class.
Definition FastLED.h:154
TM1812 controller class.
Definition FastLED.h:149
TM1829 controller class.
Definition chipsets.h:793
TM1829 controller class.
Definition FastLED.h:144
UCS1903B controller class.
Definition chipsets.h:768
UCS1903B controller class.
Definition FastLED.h:174
UCS1903 controller class @ 400 KHz.
Definition chipsets.h:763
UCS1903 controller class.
Definition FastLED.h:169
UCS1904 controller class.
Definition chipsets.h:773
UCS1904 controller class.
Definition FastLED.h:179
UCS1912 controller class.
Definition FastLED.h:277
UCS2903 controller class.
Definition chipsets.h:778
UCS2903 controller class.
Definition FastLED.h:184
WS2801 controller class.
Definition chipsets.h:230
WS2803 controller class.
Definition chipsets.h:257
WS2811_400 controller class.
Definition FastLED.h:248
WS2811 controller class @ 400 KHz.
Definition chipsets.h:743
WS2811 controller class @ 800 KHz.
Definition chipsets.h:723
WS2811 controller class.
Definition FastLED.h:233
WS2812B controller class.
Definition FastLED.h:203
WS2812 controller class @ 800 KHz.
Definition chipsets.h:713
WS2812 controller class.
Definition FastLED.h:189
WS2813 controller class.
Definition chipsets.h:738
WS2813 controller class.
Definition FastLED.h:238
WS2815 controller class @ 400 KHz.
Definition chipsets.h:718
WS2815 controller class.
Definition FastLED.h:193
WS2852 controller class.
Definition FastLED.h:198
Declarations for the predefined color palettes supplied by FastLED.
Utility functions for color fill, palettes, blending, and more.
base definitions used by led controllers for writing out led data
Compatibility functions based on C++ version.
Defines the DMX512-based LED controllers.
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.
Functions to generate and fill arrays with noise.
Declares classes for managing logical groups of LEDs.
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:39