FastLED 3.9.12
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 3009012
20#ifndef FASTLED_INTERNAL
21# ifdef FASTLED_SHOW_VERSION
22# ifdef FASTLED_HAS_PRAGMA_MESSAGE
23# pragma message "FastLED version 3.009.012"
24# else
25# warning FastLED version 3.009.012 (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
197template <uint8_t DATA_PIN, EOrder RGB_ORDER>
198class WS2816 : public WS2816Controller<DATA_PIN, RGB_ORDER> {};
199
202template<uint8_t DATA_PIN, EOrder RGB_ORDER>
203class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
204
207template<uint8_t DATA_PIN, EOrder RGB_ORDER>
208class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
209
212template<uint8_t DATA_PIN, EOrder RGB_ORDER>
213class GS1903 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
214
217template<uint8_t DATA_PIN, EOrder RGB_ORDER>
218class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
219
222template<uint8_t DATA_PIN, EOrder RGB_ORDER>
223class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
224
227template<uint8_t DATA_PIN, EOrder RGB_ORDER>
228class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
229
232template<uint8_t DATA_PIN, EOrder RGB_ORDER>
233class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
234
237template<uint8_t DATA_PIN, EOrder RGB_ORDER>
238class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
239
242template<uint8_t DATA_PIN, EOrder RGB_ORDER>
243class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
244
247template<uint8_t DATA_PIN, EOrder RGB_ORDER>
248class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
249
252template<uint8_t DATA_PIN, EOrder RGB_ORDER>
253class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
254
257template<uint8_t DATA_PIN, EOrder RGB_ORDER>
258class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
259
262template<uint8_t DATA_PIN, EOrder RGB_ORDER>
263class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
264
267template<uint8_t DATA_PIN, EOrder RGB_ORDER>
268class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
269
272template<uint8_t DATA_PIN, EOrder RGB_ORDER>
273class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
274
277template<uint8_t DATA_PIN, EOrder RGB_ORDER>
278class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
279
281template<uint8_t DATA_PIN, EOrder RGB_ORDER>
282class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
283
284#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
286template<uint8_t DATA_PIN, EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
287#endif
288#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
290template<EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
291#endif
292#endif
295
296
299#ifdef PORTA_FIRST_PIN
300 WS2811_PORTA,
301 WS2813_PORTA,
302 WS2811_400_PORTA,
303 TM1803_PORTA,
304 UCS1903_PORTA,
305#endif
306#ifdef PORTB_FIRST_PIN
307 WS2811_PORTB,
308 WS2813_PORTB,
309 WS2811_400_PORTB,
310 TM1803_PORTB,
311 UCS1903_PORTB,
312#endif
313#ifdef PORTC_FIRST_PIN
314 WS2811_PORTC,
315 WS2813_PORTC,
316 WS2811_400_PORTC,
317 TM1803_PORTC,
318 UCS1903_PORTC,
319#endif
320#ifdef PORTD_FIRST_PIN
321 WS2811_PORTD,
322 WS2813_PORTD,
323 WS2811_400_PORTD,
324 TM1803_PORTD,
325 UCS1903_PORTD,
326#endif
327#ifdef HAS_PORTDC
328 WS2811_PORTDC,
329 WS2813_PORTDC,
330 WS2811_400_PORTDC,
331 TM1803_PORTDC,
332 UCS1903_PORTDC,
333#endif
334};
335
342typedef uint8_t (*power_func)(uint8_t scale, uint32_t data);
343
350class CFastLED {
351 // int m_nControllers;
352 uint8_t m_Scale;
353 uint16_t m_nFPS;
354 uint32_t m_nMinMicros;
355 uint32_t m_nPowerData;
356 power_func m_pPowerFunc;
357
358public:
359 CFastLED();
360
361 // Useful when you want to know when an event like onFrameBegin or onFrameEnd is happening.
362 // This is disabled on AVR to save space.
363 void addListener(fl::EngineEvents::Listener *listener) { fl::EngineEvents::addListener(listener); }
364 void removeListener(fl::EngineEvents::Listener *listener) { fl::EngineEvents::removeListener(listener); }
365
377 static CLEDController &addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0);
378
398
399
400 // Base template: Causes a compile-time error if an unsupported CHIPSET is used
401 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN>
403 // Default implementation, will be specialized for supported chipsets
404 static const bool IS_VALID = false;
405 };
406
407 // Macro to define a mapping from the ESPIChipeset enum to the controller class
408 // in it's various template configurations.
409 #define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS) \
410 template<uint8_t DATA_PIN, uint8_t CLOCK_PIN> \
411 struct ClockedChipsetHelper<CHIPSET_ENUM, DATA_PIN, CLOCK_PIN> { \
412 static const bool IS_VALID = true; \
413 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN> ControllerType; \
414 /* Controller type with RGB_ORDER specified */ \
415 template<EOrder RGB_ORDER> \
416 struct CONTROLLER_CLASS_WITH_ORDER { \
417 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER> ControllerType; \
418 }; \
419 /* Controller type with RGB_ORDER and spi frequency specified */ \
420 template<EOrder RGB_ORDER, uint32_t FREQ> \
421 struct CONTROLLER_CLASS_WITH_ORDER_AND_FREQ { \
422 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER, FREQ> ControllerType; \
423 }; \
424 };
425
426 // Define specializations for each supported CHIPSET
427 _FL_MAP_CLOCKED_CHIPSET(LPD6803, LPD6803Controller)
428 _FL_MAP_CLOCKED_CHIPSET(LPD8806, LPD8806Controller)
429 _FL_MAP_CLOCKED_CHIPSET(WS2801, WS2801Controller)
430 _FL_MAP_CLOCKED_CHIPSET(WS2803, WS2803Controller)
431 _FL_MAP_CLOCKED_CHIPSET(SM16716, SM16716Controller)
432 _FL_MAP_CLOCKED_CHIPSET(P9813, P9813Controller)
433
434 // Both DOTSTAR and APA102 use the same controller class
435 _FL_MAP_CLOCKED_CHIPSET(DOTSTAR, APA102Controller)
436 _FL_MAP_CLOCKED_CHIPSET(APA102, APA102Controller)
437
438 // Both DOTSTARHD and APA102HD use the same controller class
439 _FL_MAP_CLOCKED_CHIPSET(DOTSTARHD, APA102ControllerHD)
440 _FL_MAP_CLOCKED_CHIPSET(APA102HD, APA102ControllerHD)
441
442 _FL_MAP_CLOCKED_CHIPSET(SK9822, SK9822Controller)
443 _FL_MAP_CLOCKED_CHIPSET(SK9822HD, SK9822ControllerHD)
444
445
446
447 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) {
448 // Instantiate the controller using ClockedChipsetHelper
450 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
451 static_assert(CHIP::IS_VALID, "Unsupported chipset");
452 static ControllerTypeWithFreq c;
453 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
454 }
455
457 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
459 typedef typename CHIP::ControllerType ControllerType;
460 static_assert(CHIP::IS_VALID, "Unsupported chipset");
461 static ControllerType c;
462 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
463 }
464
465
466 // The addLeds function using ChipsetHelper
467 template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER>
468 CLEDController& addLeds(struct CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
469 typedef ClockedChipsetHelper<CHIPSET, DATA_PIN, CLOCK_PIN> CHIP;
470 static_assert(CHIP::IS_VALID, "Unsupported chipset");
471 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
472 static ControllerTypeWithOrder c;
473 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
474 }
475
476
477#ifdef SPI_DATA
478 template<ESPIChipsets CHIPSET> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
479 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB>(data, nLedsOrOffset, nLedsIfOffset);
480 }
481
482 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
483 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER>(data, nLedsOrOffset, nLedsIfOffset);
484 }
485
486 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
487 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE>(data, nLedsOrOffset, nLedsIfOffset);
488 }
489
490#endif
492
493#ifdef FASTLED_HAS_CLOCKLESS
514
516 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
517 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
518 static CHIPSET<DATA_PIN, RGB_ORDER> c;
519 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
520 }
521
523 template<template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN>
524 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
525 static CHIPSET<DATA_PIN, RGB> c;
526 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
527 }
528
530 template<template<uint8_t DATA_PIN> class CHIPSET, uint8_t DATA_PIN>
531 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
532 static CHIPSET<DATA_PIN> c;
533 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
534 }
535
536#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
537 template<uint8_t NUM_LANES, template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
538 static CLEDController &addLeds(struct CRGB *data, int nLeds) {
539 static __FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
540 return addLeds(&c, data, nLeds);
541 }
542#endif
543
544 #ifdef FASTSPI_USE_DMX_SIMPLE
545 template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
546 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
547 {
548 switch(CHIPSET) {
549 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
550 }
551 }
552 #endif
554#endif
555
576
578 template<template<EOrder RGB_ORDER> class CHIPSET, EOrder RGB_ORDER>
579 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
580 static CHIPSET<RGB_ORDER> c;
581 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
582 }
583
585 template<template<EOrder RGB_ORDER> class CHIPSET>
586 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
587 static CHIPSET<RGB> c;
588 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
589 }
590
591#ifdef USE_OCTOWS2811
595 template<OWS2811 CHIPSET, EOrder RGB_ORDER>
596 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
597 {
598 switch(CHIPSET) {
599 case OCTOWS2811: { static COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
600 case OCTOWS2811_400: { static COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
601#ifdef WS2813_800kHz
602 case OCTOWS2813: { static COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
603#endif
604 }
605 }
606
610 template<OWS2811 CHIPSET>
611 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
612 {
613 return addLeds<CHIPSET,GRB>(data,nLedsOrOffset,nLedsIfOffset);
614 }
615
616#endif
617
618#ifdef USE_WS2812SERIAL
622 template<SWS2812 CHIPSET, int DATA_PIN, EOrder RGB_ORDER>
623 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
624 {
625 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
626 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
627 }
628#endif
629
630#ifdef SmartMatrix_h
633 template<ESM CHIPSET>
634 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
635 {
636 switch(CHIPSET) {
637 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
638 }
639 }
640#endif
642
643
644#ifdef FASTLED_HAS_BLOCKLESS
645
666
668 template<EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
669 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
670 switch(CHIPSET) {
671 #ifdef PORTA_FIRST_PIN
672 case WS2811_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
673 case WS2811_400_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
674 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);
675 case TM1803_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
676 case UCS1903_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
677 #endif
678 #ifdef PORTB_FIRST_PIN
679 case WS2811_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
680 case WS2811_400_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
681 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);
682 case TM1803_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
683 case UCS1903_PORTB: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
684 #endif
685 #ifdef PORTC_FIRST_PIN
686 case WS2811_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
687 case WS2811_400_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
688 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);
689 case TM1803_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
690 case UCS1903_PORTC: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
691 #endif
692 #ifdef PORTD_FIRST_PIN
693 case WS2811_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
694 case WS2811_400_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
695 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);
696 case TM1803_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
697 case UCS1903_PORTD: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
698 #endif
699 #ifdef HAS_PORTDC
700 case WS2811_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
701 case WS2811_400_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
702 case WS2813_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
703 case TM1803_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
704 case UCS1903_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
705 #endif
706 }
707 }
708
710 template<EBlockChipsets CHIPSET, int NUM_LANES>
711 static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
712 return addLeds<CHIPSET,NUM_LANES,GRB>(data,nLedsOrOffset,nLedsIfOffset);
713 }
715#endif
716
719 void setBrightness(uint8_t scale) { m_Scale = scale; }
720
723 uint8_t getBrightness() { return m_Scale; }
724
728 inline void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps) { setMaxPowerInMilliWatts(volts * milliamps); }
729
732 inline void setMaxPowerInMilliWatts(uint32_t milliwatts) { m_pPowerFunc = &calculate_max_brightness_for_power_mW; m_nPowerData = milliwatts; }
733
736 void show(uint8_t scale);
737
739 void show() { show(m_Scale); }
740
744 void clear(bool writeData = false);
745
747 void clearData();
748
752 void showColor(const struct CRGB & color, uint8_t scale);
753
756 void showColor(const struct CRGB & color) { showColor(color, m_Scale); }
757
762 void delay(unsigned long ms);
763
767 void setTemperature(const struct CRGB & temp);
768
772 void setCorrection(const struct CRGB & correction);
773
777 void setDither(uint8_t ditherMode = BINARY_DITHER);
778
786 void setMaxRefreshRate(uint16_t refresh, bool constrain=false);
787
792 void countFPS(int nFrames=25);
793
796 uint16_t getFPS() { return m_nFPS; }
797
800 int count();
801
804 CLEDController & operator[](int x);
805
808 int size();
809
812 CRGB *leds();
813};
814
816#define FastSPI_LED FastLED
818#define FastSPI_LED2 FastLED
819#ifndef LEDS
821#define LEDS FastLED
822#endif
823
825extern CFastLED FastLED;
826
830#ifndef HAS_HARDWARE_PIN_SUPPORT
831#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
832#define NO_HARDWARE_PIN_SUPPORT
833#endif
834
835
837
838#endif
839
840#ifdef FASTLED_UI
841// As a convenience, include the UI headers and bring them into the global namespace
842#include "fl/ui.h"
843using fl::UIButton;
844using fl::UICheckbox;
846using fl::UISlider;
847#define FASTLED_TITLE(text) fl::UITitle g_title(text)
848#define FASTLED_DESCRIPTION(text) fl::UIDescription g_description(text)
849#endif // FASTLED_UI
850
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:342
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:298
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:508
APA102 controller class.
Definition chipsets.h:343
APA104 controller class.
Definition FastLED.h:248
APA106 controller class.
Definition FastLED.h:228
High level controller interface for FastLED.
Definition FastLED.h:350
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:301
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:210
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world.
Definition FastLED.h:457
void show()
Update all our controllers with the current led colors.
Definition FastLED.h:739
void showColor(const struct CRGB &color)
Set all leds on all controllers to the given color.
Definition FastLED.h:756
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
Definition FastLED.cpp:285
CLEDController & operator[](int x)
Get a reference to a registered controller.
Definition FastLED.cpp:142
void delay(unsigned long ms)
Delay for the given number of milliseconds.
Definition FastLED.cpp:196
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:719
void showColor(const struct CRGB &color, uint8_t scale)
Set all leds on all controllers to the given color/scale.
Definition FastLED.cpp:154
void setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode.
Definition FastLED.cpp:226
void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps)
Set the maximum power to be used, given in volts and milliamps.
Definition FastLED.h:728
uint16_t getFPS()
Get the number of frames/second being written out.
Definition FastLED.h:796
void setMaxPowerInMilliWatts(uint32_t milliwatts)
Set the maximum power to be used, given in milliwatts.
Definition FastLED.h:732
uint8_t getBrightness()
Get the current global brightness setting.
Definition FastLED.h:723
void clearData()
Clear out the local data array.
Definition FastLED.cpp:188
void setCorrection(const struct CRGB &correction)
Set a global color correction.
Definition FastLED.cpp:218
int count()
Get how many controllers have been registered.
Definition FastLED.cpp:132
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:586
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
Definition FastLED.cpp:181
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a clockless based CLEDController instance to the world.
Definition FastLED.h:524
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:290
DMX512 based LED controller class, using the DmxSimple library.
Definition FastLED.h:286
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:708
GE8822 controller class.
Definition FastLED.h:258
GS1903 controller class.
Definition FastLED.h:213
GW6205_400 controller class.
Definition FastLED.h:268
GW6205 controller class @ 400 KHz.
Definition chipsets.h:809
UCS1904 controller class @ 800 KHz.
Definition chipsets.h:814
GW6205 controller class.
Definition FastLED.h:263
LPD1886_8BIT controller class.
Definition FastLED.h:278
LPD1886 controller class.
Definition chipsets.h:718
LPD1886 controller class.
Definition chipsets.h:713
LPD1886 controller class.
Definition FastLED.h:273
LPD6803 controller class (LPD1101).
Definition chipsets.h:280
LPD8806 controller class.
Definition chipsets.h:199
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:135
P9813 controller class.
Definition chipsets.h:572
PL9823 controller class.
Definition chipsets.h:819
PL9823 controller class.
Definition FastLED.h:233
SK6812 controller class.
Definition chipsets.h:769
SK6812 controller class.
Definition FastLED.h:218
SK6822 controller class.
Definition chipsets.h:759
SK6822 controller class.
Definition FastLED.h:223
SK9822 controller class.
Definition chipsets.h:555
SK9822 controller class.
Definition chipsets.h:533
SM16703 controller class.
Definition chipsets.h:764
SM16703 controller class.
Definition FastLED.h:140
SM16716 controller class.
Definition chipsets.h:622
TM1803 controller class.
Definition chipsets.h:799
TM1803 controller class.
Definition FastLED.h:165
TM1804 controller class.
Definition FastLED.h:160
TM1809 controller class.
Definition chipsets.h:794
TM1809 controller class.
Definition FastLED.h:155
TM1812 controller class.
Definition FastLED.h:150
TM1829 controller class.
Definition chipsets.h:804
TM1829 controller class.
Definition FastLED.h:145
UCS1903B controller class.
Definition chipsets.h:779
UCS1903B controller class.
Definition FastLED.h:175
UCS1903 controller class @ 400 KHz.
Definition chipsets.h:774
UCS1903 controller class.
Definition FastLED.h:170
UCS1904 controller class.
Definition chipsets.h:784
UCS1904 controller class.
Definition FastLED.h:180
UCS1912 controller class.
Definition FastLED.h:282
UCS2903 controller class.
Definition chipsets.h:789
UCS2903 controller class.
Definition FastLED.h:185
WS2801 controller class.
Definition chipsets.h:242
WS2803 controller class.
Definition chipsets.h:269
WS2811_400 controller class.
Definition FastLED.h:253
WS2811 controller class @ 400 KHz.
Definition chipsets.h:754
WS2811 controller class @ 800 KHz.
Definition chipsets.h:734
WS2811 controller class.
Definition FastLED.h:238
WS2812B controller class.
Definition FastLED.h:208
WS2812 controller class @ 800 KHz.
Definition chipsets.h:724
WS2812 controller class.
Definition FastLED.h:190
WS2813 controller class.
Definition chipsets.h:749
WS2813 controller class.
Definition FastLED.h:243
WS2815 controller class @ 400 KHz.
Definition chipsets.h:729
WS2815 controller class.
Definition FastLED.h:194
WS2816 controller class.
Definition FastLED.h:198
WS2852 controller class.
Definition FastLED.h:203
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