FastLED 3.10.6
Loading...
Searching...
No Matches
FastLED.h
Go to the documentation of this file.
1#pragma once
2
3// IWYU pragma: private // no IWYU recommend for internal apis, obviously you can use this
4#ifndef __INC_FASTSPI_LED2_H
5#define __INC_FASTSPI_LED2_H
6
7
8
9#include "fl/stl/stdint.h"
10#include "fl/system/dll.h" // Will optionally compile in.
11#include "platforms/is_platform.h"
12
13// Include Arduino.h early and immediately normalize its math macros (min, max, abs,
14// round, radians, degrees, map). On Arduino platforms the IDE injects Arduino.h
15// before the sketch, so those macros are already active by the time FastLED.h is
16// processed. Pulling fl/system/arduino.h in here — before any internal FastLED headers —
17// ensures all subsequent headers see a clean, macro-free environment.
18// fl/stl/undef.h (included by fl/system/arduino.h) is intentionally re-includable, so a
19// second cleanup in fl/math/math.h (included later, after platform headers) will
20// catch any macros re-introduced by those platform headers.
21#if defined(ARDUINO)
22#include "fl/system/arduino.h"
23#endif
24
27
28#if defined(FL_IS_GCC) || defined(FL_IS_CLANG)
29#define FASTLED_HAS_PRAGMA_MESSAGE
30#endif
31
37#define FASTLED_VERSION 3010006
38#ifndef FASTLED_INTERNAL
39# ifdef FASTLED_SHOW_VERSION
40# ifdef FASTLED_HAS_PRAGMA_MESSAGE
41# pragma message "FastLED version 3.010.006"
42# else
43# warning FastLED version 3.010.006 (Not really a warning, just telling you here.)
44# endif
45# endif
46#endif
47// ESP32 I2S Driver: `FASTLED_ESP32_I2S` used to opt into the Yves
48// parallel-out clockless driver. Removed at FastLED#3526 Phase 2e — the
49// modern unified engine on `Bus::FLEX_IO, 0` is now the only I2S path.
50// Users who previously defined `-DFASTLED_ESP32_I2S=1` should drop the
51// flag; clockless output still routes through RMT by default. If the
52// modern I2S path is specifically desired, use
53// `FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>()`.
54#if defined(FASTLED_ESP32_I2S) && !defined(FASTLED_INTERNAL)
55#warning "-DFASTLED_ESP32_I2S is removed (FastLED#3526 Phase 2e). Drop the flag; the modern I2S engine is now on Bus::FLEX_IO, 0. Runtime select via FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>()."
56#endif
57
58// Pre-4.0 Teensy boards are end-of-life.
59//
60// Teensy LC and 3.0-3.6 are discontinued. FastLED still compiles for them and
61// we still fix reported bugs, but they get no hardware validation -- see
62// FastLED#3983, where bench testing is scoped to Teensy 4.0/4.1 only. Users on
63// these boards should know they are on an unvalidated path before they debug
64// something we cannot reproduce.
65//
66// Note the guard covers BOTH umbrellas: `FL_IS_TEENSY_3X` is only 3.0-3.6, and
67// Teensy LC sits beside it rather than inside it (see
68// platforms/arm/teensy/is_teensy.h). Testing 3X alone would silently miss the
69// LC, which is the most end-of-life board of the set.
70#if (defined(FL_IS_TEENSY_3X) || defined(FL_IS_TEENSY_LC)) && \
71 !defined(FASTLED_INTERNAL) && !defined(FL_TEENSY_EOL_SUPPRESS_WARNING)
72#warning "This Teensy (pre-4.0) is out of production and FastLED no longer hardware-validates it. If you hit a problem, try FastLED 3.10.3, the last release verified against these boards, and please file a report at https://github.com/FastLED/FastLED/issues -- we do still fix these. Define FL_TEENSY_EOL_SUPPRESS_WARNING to silence this."
73#endif
74
75// Legacy RMT4 backend is ESP-IDF 4.x only.
76//
77// On IDF 5.x the legacy TX and RX implementations no longer build: RMTMEM is not
78// exposed by the public headers, and both engines predate the current
79// IChannelDriver / RmtRxChannel contracts. `-DFASTLED_RMT5=0` there produced a
80// wall of unrelated compiler errors, and the old guard sent users chasing
81// -DESP32_ARDUINO_NO_RGB_BUILTIN=1, which gets past the guard but not past the
82// build. Reject the combination up front with one accurate diagnostic instead.
83// RMT5 is already the IDF 5.x default, so nothing that builds today is lost.
84// See FastLED#3936.
85//
86// Note the version test: FASTLED_RMT5 also defaults to 0 on IDF 4.x, where RMT4
87// is the correct native backend and must keep building.
88#if defined(FL_IS_ESP32)
89#include "platforms/esp/esp_version.h" // ok platform headers
90#include "platforms/esp/32/feature_flags/enabled.h" // ok platform headers
91#if FASTLED_RMT5 == 0 && FASTLED_ESP32_HAS_RMT && ESP_IDF_VERSION_5_OR_HIGHER
92#error "FASTLED_RMT5=0 (legacy RMT4 backend) is not supported on ESP-IDF 5.x or newer. Remove -DFASTLED_RMT5=0 to use the RMT5 backend, which is the default on this IDF. RMT4 remains available only when building against ESP-IDF 4.x. See https://github.com/FastLED/FastLED/issues/3936"
93#endif
94#endif
95
96
97#if !defined(FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS)
98#if defined(FL_IS_WASM)
99#define FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS 1
100#else
101#define FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS 0
102#endif
103#endif
104
105// Platforms that register real hardware channel drivers (clockless and/or SPI).
106// User-overridable: define before including FastLED.h to force on/off.
107#if !defined(FASTLED_HAS_CHANNELS)
108#if defined(FL_IS_ESP32) || defined(FL_IS_TEENSY_4X) || \
109 defined(FL_IS_RP) || defined(FL_IS_STM32) || \
110 defined(FL_IS_SAMD) || defined(FL_IS_NRF52)
111#define FASTLED_HAS_CHANNELS 1
112#else
113#define FASTLED_HAS_CHANNELS 0
114#endif
115#endif
116
117// Route SPI chipsets (APA102, SK9822, etc.) through the Channel API instead of
118// legacy APA102Controller/SPIOutput. Only enabled on platforms where
119// DATA_RATE_MHZ() returns Hz (not clock dividers) so that the SPI_DATA_RATE
120// template parameter can be passed directly to the channel encoder.
121#if !defined(FASTLED_SPI_USES_CHANNEL_API)
122#if FASTLED_HAS_CHANNELS && (defined(FL_IS_ESP32) || defined(FL_IS_TEENSY_4X) || \
123 defined(FL_IS_RP2040) || defined(FL_IS_RP2350))
124#define FASTLED_SPI_USES_CHANNEL_API 1
125#else
126#define FASTLED_SPI_USES_CHANNEL_API 0
127#endif
128#endif
129
130#ifndef __PROG_TYPES_COMPAT__
134#define __PROG_TYPES_COMPAT__
135#endif
136
137#ifdef FL_IS_WASM
138#include "platforms/wasm/js.h" // ok platform headers
139#include "platforms/wasm/led_sysdefs_wasm.h" // ok platform headers
140#include "platforms/wasm/compiler/Arduino.h" // ok platform headers
141#include "platforms/wasm/js_fetch.h" // ok platform headers
142#endif
143
144#ifdef SmartMatrix_h
145// IWYU pragma: begin_keep
146#include <SmartMatrix.h>
147// IWYU pragma: end_keep
148#endif
149
150#ifdef DmxSimple_h
151// IWYU pragma: begin_keep
152#include <DmxSimple.h>
153// IWYU pragma: end_keep
154#endif
155
156#ifdef DmxSerial_h
157// IWYU pragma: begin_keep
158#include <DMXSerial.h>
159// IWYU pragma: end_keep
160#endif
161
162#ifdef USE_OCTOWS2811
163// IWYU pragma: begin_keep
164#include <OctoWS2811.h>
165// IWYU pragma: end_keep
166#endif
167
168// Convenience includes for sketch inclusion
169#include "fl/task/executor.h"
171#include "fl/channels/rx.h"
172#include "fl/stl/array.h"
173#include "fl/stl/vector.h"
174#include "fl/stl/cstring.h"
175#include "fl/system/pin.h"
176
177
179#include "fl/stl/static_assert.h"
180#include "cpp_compat.h"
181
182#include "fastled_config.h"
183#include "led_sysdefs.h"
184
185// Include the internal FastLED header (provides core types without cycles)
186#include "fl/system/fastled.h"
187
188#include "fl/channels/channel.h"
190#include "fl/wdt/watchdog.h" // for fl::Watchdog (FastLED.watchdog() accessor)
191#include "fl/channels/manager.h"
192#include "fl/channels/config.h" // for ChannelConfig, MultiChannelConfig
193#include "fl/channels/bus.h" // for fl::Bus, fl::DefaultBus (Phase 3b, #2428)
194#include "fl/channels/bus_info.h" // for fl::deviceInfo (portable bus introspection)
195#include "fl/channels/bus_traits.h" // for fl::BusTraits, fl::BusSupports (Phase 3b, #2428)
196#include "fl/channels/channel_typed.h" // for fl::TypedChannel<B, Chipset> (Phase 3b, #2428)
197#include "fl/channels/slim_spi_bridge_controller.h" // for fl::SlimSpiBridgeController (#4585)
199#include "fl/stl/type_traits.h" // for fl::true_type/false_type (SPI addLeds<> dispatch, #4585)
200
201#include "fl/audio/input.h"
203
204// CFastLED::add(UIAudio&) only needs the name, which audio_manager.h forward
205// declares; the full UI headers (and the JSON UI they pull in on host/wasm)
206// are provided to sketches by the convenience block at the bottom of this
207// file, not to every library TU.
209
210// ============================================================================
211// C STRING FUNCTION USING DECLARATIONS
212// ============================================================================
213
219
220// Utility functions
221#include "fastled_delay.h"
222#include "bitswap.h"
223
224#include "lib8tion.h"
225
226// ============================================================================
227// MATH FUNCTION USING DECLARATIONS
228// ============================================================================
229
230// Arduino macros (min, max, abs, etc.) are cleaned up in two passes:
231// Pass 1 — top of FastLED.h (above): fl/system/arduino.h cleans up before internal headers.
232// Pass 2 — fl/math/math.h (below): cleans up any macros re-introduced by platform headers.
233// fl/stl/undef.h is intentionally re-includable to support both passes.
234
235#include "controller.h"
236#include "fastpin.h"
237#include "fastspi_types.h"
238#include "dmx.h"
239
240#include "platforms.h"
241
242// Default example pins; must follow platforms.h so board pin tables win.
243#include "platforms/default_pins.h"
244
245// Library Dependency Finder (LDF) hint headers
246// These headers use #if 0 blocks to hint library dependencies to the LDF scanner
247// without actually compiling the code. This works around LDF's limitation of scanning
248// headers without evaluating preprocessor paths.
249#include "platforms/ldf_headers.h"
250
251// Pass 2 macro cleanup: fl/math/math.h includes fl/stl/undef.h which undefs any
252// min/max/abs/round/radians/degrees/map macros re-introduced by platform headers above.
253// Then provides type-safe fl:: replacements brought into global scope via using below.
254#include "fl/math/math.h"
255
256// Bring fl:: math functions into global namespace for Arduino compatibility
257// Teensy platforms define their own template min/max in wiring.h (global namespace),
258// so we skip bringing fl::min/fl::max into global scope to avoid ambiguity.
259#if !defined(FL_IS_TEENSY)
260using fl::min;
261using fl::max;
262#endif
263using fl::abs;
264using fl::radians;
265using fl::degrees;
266
267// Note: Arduino map() function is defined in global namespace (platforms/stub/Arduino.h)
268// fl::map refers to the map container (red-black tree) and our map() function delegate.
269#include "fastled_progmem.h"
270#include "pixeltypes.h"
271#include "hsv2rgb.h"
272#include "colorutils.h"
273#include "pixelset.h"
274#include "colorpalettes.h"
275
276#include "noise.h"
277#include "power_mgt.h"
279
280#include "fastspi.h"
281#include "chipsets.h"
282#include "fl/chipsets/analog.h"
284
285#include "fl/gfx/leds.h"
286#include "fl/gfx/rgbw.h" // RGBW mode config (wrapped on CFastLED below)
287#include "fl/color/rgbw.h" // colorimetric profile facade
288
289// clockless.h removed - BulkClockless API has been superseded by Channel API
290
291// SPI chipset enumeration (modern type-safe enum class)
293
297 LPD6803 = static_cast<int>(fl::SpiChipset::LPD6803),
298 LPD8806 = static_cast<int>(fl::SpiChipset::LPD8806),
299 WS2801 = static_cast<int>(fl::SpiChipset::WS2801),
300 WS2803 = static_cast<int>(fl::SpiChipset::WS2803),
301 SM16716 = static_cast<int>(fl::SpiChipset::SM16716),
302 MY9221 = static_cast<int>(fl::SpiChipset::MY9221),
303 P9813 = static_cast<int>(fl::SpiChipset::P9813),
304 APA102 = static_cast<int>(fl::SpiChipset::APA102),
305 SK9822 = static_cast<int>(fl::SpiChipset::SK9822),
306 SK9822HD = static_cast<int>(fl::SpiChipset::SK9822HD),
307 DOTSTAR = static_cast<int>(fl::SpiChipset::DOTSTAR),
309 APA102HD = static_cast<int>(fl::SpiChipset::APA102HD),
310 HD107 = static_cast<int>(fl::SpiChipset::HD107),
311 HD107S = static_cast<int>(fl::SpiChipset::HD107S),
312 HD107HD = static_cast<int>(fl::SpiChipset::HD107HD),
313 HD108 = static_cast<int>(fl::SpiChipset::HD108),
314};
315
319
324
329
330#ifdef HAS_PIXIE
331template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
332#endif
333
334#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
339
342template<fl::u8 DATA_PIN> class NEOPIXEL : public WS2812Controller800Khz<DATA_PIN, GRB> {};
343
346template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
347class SM16703 : public SM16703Controller<DATA_PIN, RGB_ORDER> {};
348
351template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
352class SM16824E : public SM16824EController<DATA_PIN, RGB_ORDER> {};
353
356template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
357class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
358
364template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
365class TX1813N1 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
366
372template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
373class TM1812 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
374
377template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
378class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
379
384template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
385class TM1908 : public TM1908Controller<DATA_PIN, RGB_ORDER> {};
386
389template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
390class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
391
394template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
395class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {};
396
399template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
400class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {};
401
404template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
405class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {};
406
409template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
410class UCS1904 : public UCS1904Controller800Khz<DATA_PIN, RGB_ORDER> {};
411
414template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
415class UCS2903 : public UCS2903Controller<DATA_PIN, RGB_ORDER> {};
416
419template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
420class UCS7604 : public UCS7604Controller8bit<DATA_PIN, RGB_ORDER> {};
421
424template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
425class UCS7604HD : public UCS7604Controller16bit<DATA_PIN, RGB_ORDER> {};
426
430template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
431class UCS7604HD_1600 : public UCS7604Controller16bit1600<DATA_PIN, RGB_ORDER> {};
432
435template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
436class WS2812 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
437
439template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
440class WS2815 : public WS2815Controller<DATA_PIN, RGB_ORDER> {};
441
443template <fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
444class WS2816 : public WS2816Controller<DATA_PIN, RGB_ORDER> {};
445
448template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
449class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
450
453template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
454class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
455
461template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
462class OSTW2020C1E : public OSTW2020C1EController<DATA_PIN, RGB_ORDER> {};
463
466template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
467class WS2812BMiniV3 : public WS2812BMiniV3Controller<DATA_PIN, RGB_ORDER> {};
468
471template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
472class WS2812BV5 : public WS2812BV5Controller<DATA_PIN, RGB_ORDER> {};
473
480template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
481class GS1903 : public GS1903Controller<DATA_PIN, RGB_ORDER> {};
482
485template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
486class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
487
492template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
493class LC8816E : public LC8816EController<DATA_PIN, RGB_ORDER> {};
494
504template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
505class SK6812WWA : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
506
509template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
510class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
511
514template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
515class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
516
519template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
520class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
521
524template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
525class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
526
529template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
530class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
531
537template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
538class WS2814 : public WS2814Controller<DATA_PIN, RGB_ORDER> {};
539
545template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
546class WS2818 : public WS2818Controller<DATA_PIN, RGB_ORDER> {};
547
550template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
551class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
552
555template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
556class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
557
560template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
561class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
562
565template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
566class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
567
570template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
571class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
572
575template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
576class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
577
580template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
581class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
582
584template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
585class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
586
587#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
589template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
590#endif
591#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
593template<fl::EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
594#endif
595#endif
598
599
602#ifdef PORTA_FIRST_PIN
603 WS2811_PORTA,
604 WS2813_PORTA,
605 WS2811_400_PORTA,
606 TM1803_PORTA,
607 UCS1903_PORTA,
608#endif
609#ifdef PORTB_FIRST_PIN
610 WS2811_PORTB,
611 WS2813_PORTB,
612 WS2811_400_PORTB,
613 TM1803_PORTB,
614 UCS1903_PORTB,
615#endif
616#ifdef PORTC_FIRST_PIN
617 WS2811_PORTC,
618 WS2813_PORTC,
619 WS2811_400_PORTC,
620 TM1803_PORTC,
621 UCS1903_PORTC,
622#endif
623#ifdef PORTD_FIRST_PIN
624 WS2811_PORTD,
625 WS2813_PORTD,
626 WS2811_400_PORTD,
627 TM1803_PORTD,
628 UCS1903_PORTD,
629#endif
630#ifdef HAS_PORTDC
631 WS2811_PORTDC,
632 WS2813_PORTDC,
633 WS2811_400_PORTDC,
634 TM1803_PORTDC,
635 UCS1903_PORTDC,
636#endif
637};
638
639
646typedef fl::u8 (*power_func)(fl::u8 scale, fl::u32 data);
647
666enum class ClearFlags : fl::u32 {
667 NONE = 0,
668 CHANNELS = 1 << 0,
669 POWER_SETTINGS = 1 << 1,
670 BRIGHTNESS = 1 << 2,
671 REFRESH_RATE = 1 << 3,
672 FPS_COUNTER = 1 << 4,
674};
675
678 return static_cast<ClearFlags>(static_cast<fl::u32>(a) | static_cast<fl::u32>(b));
679}
680
683 return static_cast<ClearFlags>(static_cast<fl::u32>(a) & static_cast<fl::u32>(b));
684}
685
688 a = a | b;
689 return a;
690}
691
717#define FL_DITHER_ENABLE_MIN_REFRESH_HZ 100
718
723class CFastLED {
726 // int m_nControllers;
728 fl::u16 mNFPS;
729 fl::u32 mNMinMicros;
730 fl::u32 mNPowerData;
735
736public:
737 CFastLED();
738
750 void init();
751
752 // Useful when you want to know when an event like onFrameBegin or onFrameEnd is happening.
753 // This is disabled on AVR to save space.
756
764
779 static fl::Watchdog& watchdog();
780
785
788 void onBeginFrame() ;
789
792 void onEndShowLeds() ;
793
795
807 static ::CLEDController &addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0);
808
811
826 static void add(fl::ChannelPtr channel);
827
847 static fl::ChannelPtr add(const fl::ChannelConfig& config);
848
849 template<fl::ProfileId Profile>
850 static fl::ChannelPtr add(const fl::ChannelConfig& config) {
851 fl::ChannelPtr channel = fl::Channel::create<Profile>(config);
852 if (channel != nullptr) add(channel);
853 return channel;
854 }
855
876
894 static fl::vector<fl::ChannelPtr> add(fl::initializer_list<fl::ChannelConfig> configs);
895
915 static fl::vector<fl::ChannelPtr> add(const fl::MultiChannelConfig& multiConfig);
916
925 static fl::RxChannelPtr addRx(const fl::RxChannelConfig& config);
926
948
965
980
1005 static void enableAllDrivers();
1006
1023 static void remove(fl::ChannelPtr channel);
1024
1033 static void remove(fl::shared_ptr<fl::audio::Processor> processor);
1034
1036
1049 template<template<fl::u8, fl::u8, fl::u8> class CHIPSET,
1050 fl::u8 RED_PIN, fl::u8 GREEN_PIN, fl::u8 BLUE_PIN>
1051 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset,
1052 int nLedsIfOffset = 0) {
1054 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
1055 }
1056
1057
1077
1078
1079 // Base template: Causes a compile-time error if an unsupported CHIPSET is used
1080 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN>
1082 // Default implementation, will be specialized for supported chipsets
1083 static const bool IS_VALID = false;
1084 };
1085
1086 // Macro to define a mapping from the ESPIChipeset enum to the controller class
1087 // in it's various template configurations.
1088 #define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS) \
1089 template<fl::u8 DATA_PIN, fl::u8 CLOCK_PIN> \
1090 struct ClockedChipsetHelper<CHIPSET_ENUM, DATA_PIN, CLOCK_PIN> { \
1091 static const bool IS_VALID = true; \
1092 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN> ControllerType; \
1093 /* Controller type with RGB_ORDER specified */ \
1094 template<fl::EOrder RGB_ORDER> \
1095 struct CONTROLLER_CLASS_WITH_ORDER { \
1096 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER> ControllerType; \
1097 }; \
1098 /* Controller type with RGB_ORDER and spi frequency specified */ \
1099 template<fl::EOrder RGB_ORDER, fl::u32 FREQ> \
1100 struct CONTROLLER_CLASS_WITH_ORDER_AND_FREQ { \
1101 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER, FREQ> ControllerType; \
1102 }; \
1103 };
1104
1105 // Define specializations for each supported CHIPSET
1106 // Note: Using unscoped enum values for backwards compatibility
1114
1115 // Both DOTSTAR and APA102 use the same controller class
1118
1119 // Both DOTSTARHD and APA102HD use the same controller class
1122
1125
1127
1130
1131
1132 #if FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS
1136 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO> ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1137 // Instantiate the controller using ClockedChipsetHelper
1138 // Always USE WS2812 clockless controller since it's the common path.
1139 return addLeds<WS2812, DATA_PIN, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1140 }
1141
1143 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1144 // Always USE WS2812 clockless controller since it's the common path.
1145 return addLeds<WS2812, DATA_PIN, B>(data, nLedsOrOffset, nLedsIfOffset);
1146 }
1147
1148
1149 // The addLeds function using ChipsetHelper
1150 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1151 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1152 // Always USE WS2812 clockless controller since it's the common path.
1153 return addLeds<WS2812, DATA_PIN, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1154 }
1155
1156 #endif // FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS (fake-SPI overloads)
1157
1158 // Channel-API SPI entry points (#4585). Always declared (templates are only
1159 // instantiated on use) so host tests can pin the exact code path that
1160 // `addLeds<ESPIChipsets ...>()` takes when FASTLED_SPI_USES_CHANNEL_API=1,
1161 // even though the shared test PCH parses FastLED.h with the host default
1162 // (0). Under FASTLED_SPI_USES_CHANNEL_API the public addLeds<> overloads
1163 // below forward here verbatim.
1164 //
1165 // Compile-time dispatch (#4585, #4636): every SPI chipset routes through
1166 // the slim `fl::SlimSpiBridgeController`. MY9221 uses the bit-bang
1167 // `MY9221Controller` instead, because it is dual-edge (DDR) clocked and
1168 // cannot be carried as SPI bytes. No runtime `fl::Channel` is ever built
1169 // for legacy `addLeds<>`. C++11 has no `if constexpr`, so the two bodies
1170 // are separate overloads selected via a `fl::true_type`/`fl::false_type`
1171 // tag -- only the overload actually called gets instantiated, so the
1172 // never-taken branch never names `SlimSpiBridgeController<..., MY9221, ...>`.
1173 //
1174 // DATA_PIN / CLOCK_PIN / RATE / VARIANT exist only to key the
1175 // function-local statics exactly like the old per-`addLeds<>`-instantiation
1176 // `static ChannelPtr sChannel` was keyed: two strips of the same chipset on
1177 // different pins (or via different overloads) must get distinct controllers.
1178 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT,
1180 static ::CLEDController &addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset,
1181 const fl::SpiChipsetConfig &spiCfg, fl::true_type /*useSlim*/) {
1183 return addLeds(&sCtrl, data, nLedsOrOffset, nLedsIfOffset);
1184 }
1185
1186 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT,
1187 fl::EOrder RGB_ORDER, fl::Bus B, fl::u8 B_WHICH>
1188 static ::CLEDController &addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset,
1189 const fl::SpiChipsetConfig &spiCfg, fl::false_type /*isMY9221 -> bit-bang*/) {
1190 (void)spiCfg;
1191 static MY9221Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, (RATE ? RATE : DATA_RATE_MHZ(1))> sCtrl;
1192 // Register (and bind the LED buffer) only once per specialization; a
1193 // repeated call must not rebind the shared controller's buffer.
1194 static bool sRegistered = false;
1195 if (sRegistered) {
1196 return sCtrl;
1197 }
1198 sRegistered = true;
1199 return addLeds(&sCtrl, data, nLedsOrOffset, nLedsIfOffset);
1200 }
1201
1203 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1204 ::CLEDController &addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1206 static_cast<fl::SpiChipset>(CHIPSET), SPI_DATA_RATE);
1207 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1209 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, SPI_DATA_RATE, 0, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1210 }
1211
1213 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1221
1223 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1224 static ::CLEDController &addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1226 static_cast<fl::SpiChipset>(CHIPSET));
1227 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1228 // HD108 defaults to GRB; all other SPI chipsets default to RGB.
1229 constexpr fl::EOrder order =
1231 ? GRB : RGB;
1233 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, 0, 2, order, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1234 }
1235
1237 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1238 ::CLEDController& addLedsSpiChannel(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1240 static_cast<fl::SpiChipset>(CHIPSET));
1241 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1243 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, 0, 3, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1244 }
1245
1246 #if FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS
1247 // Fake-SPI overloads declared above.
1248 #elif FASTLED_SPI_USES_CHANNEL_API
1249
1251 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1252 ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1254 }
1255
1257 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1258 ::CLEDController &addLeds(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) {
1260 }
1261
1263 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1264 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1265 return addLedsSpiChannel<CHIPSET, DATA_PIN, CLOCK_PIN, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset);
1266 }
1267
1269 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1270 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1271 return addLedsSpiChannel<CHIPSET, DATA_PIN, CLOCK_PIN, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset);
1272 }
1273
1274 #else
1275
1277 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO> ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1279 // Instantiate the controller using ClockedChipsetHelper
1281 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1282 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
1283 static ControllerTypeWithFreq c;
1284 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1285 }
1286
1289 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO>
1290 ::CLEDController &addLeds(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) {
1293 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1294 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
1295 static ControllerTypeWithFreq c;
1296 c.setSpiBus(spiBus);
1297 return addLeds(&c, data, nLeds, 0);
1298 }
1299
1301 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1304 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1305 typedef typename CHIP::ControllerType ControllerType;
1306 static ControllerType c;
1307 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1308 }
1309
1311 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1312 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1315 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1316 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
1317 static ControllerTypeWithOrder c;
1318 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1319 }
1320 #endif
1321
1322
1323#ifdef SPI_DATA
1324 template<ESPIChipsets CHIPSET, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1325 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB, B>(data, nLedsOrOffset, nLedsIfOffset);
1326 }
1327
1328 template<ESPIChipsets CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1329 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1330 }
1331
1332 template<ESPIChipsets CHIPSET, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1333 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE, B>(data, nLedsOrOffset, nLedsIfOffset);
1334 }
1335
1336#endif
1338
1339#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
1343 template<typename ControllerType>
1344 static inline ::CLEDController& addLedsImpl(ControllerType* controller, CRGB *data, int nLedsOrOffset, int nLedsIfOffset) {
1345 ::CLEDController* pLed = static_cast<::CLEDController*>(controller);
1346 return addLeds(pLed, data, nLedsOrOffset, nLedsIfOffset);
1347 }
1368
1370 template<template<fl::u8, fl::EOrder> class CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1371 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1374 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1375 }
1376
1377 template<fl::ProfileId PROFILE, template<fl::u8, fl::EOrder> class CHIPSET,
1379 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1380 FL_STATIC_ASSERT(PROFILE == fl::ProfileId::WS2812B, "Unsupported color profile");
1382 using Controller = fl::StaticProfileClocklessController<fl::profiles::WS2812B,
1384 static Controller controller;
1385 return addLedsImpl(&controller, data, nLedsOrOffset, nLedsIfOffset);
1386 }
1387
1389 template<template<fl::u8, fl::EOrder> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1390 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1392 static CHIPSET<DATA_PIN, RGB> c;
1393 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1394 }
1395
1397 template<template<fl::u8> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1398 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1400 static CHIPSET<DATA_PIN> c;
1401 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1402 }
1403
1404 template<template<fl::u8> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1405 static ::CLEDController &addLeds(fl::Leds& leds, int nLedsOrOffset, int nLedsIfOffset = 0) {
1406 CRGB* rgb = leds;
1407 return addLeds<CHIPSET, DATA_PIN, B>(rgb, nLedsOrOffset, nLedsIfOffset);
1408 }
1409
1410#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
1411 template<fl::u8 NUM_LANES, template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER=RGB, fl::Bus B = fl::Bus::AUTO>
1412 static ::CLEDController &addLeds(CRGB *data, int nLeds) {
1414 static fl::__FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
1415 return addLeds(&c, data, nLeds);
1416 }
1417#endif
1418
1419 #ifdef FASTSPI_USE_DMX_SIMPLE
1420 template<EClocklessChipsets CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER=RGB, fl::Bus B = fl::Bus::AUTO>
1421 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1422 {
1424 switch(CHIPSET) {
1425 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1426 }
1427 }
1428 #endif
1430#endif
1431
1452
1454 template<template<fl::EOrder RGB_ORDER> class CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1455 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1457 static CHIPSET<RGB_ORDER> c;
1458 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1459 }
1460
1462 template<template<fl::EOrder RGB_ORDER> class CHIPSET, fl::Bus B = fl::Bus::AUTO>
1463 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1465 static CHIPSET<RGB> c;
1466 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1467 }
1468
1469#ifdef USE_OCTOWS2811
1473 template<OWS2811 CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1474 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1475 {
1477 switch(CHIPSET) {
1478 case OCTOWS2811: { static fl::COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1479 case OCTOWS2811_400: { static fl::COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1480#ifdef WS2813_800kHz
1481 case OCTOWS2813: { static fl::COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1482#endif
1483 }
1484 }
1485
1489 template<OWS2811 CHIPSET, fl::Bus B = fl::Bus::AUTO>
1490 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1491 {
1492 return addLeds<CHIPSET,GRB,B>(data,nLedsOrOffset,nLedsIfOffset);
1493 }
1494
1495#endif
1496
1497#ifdef USE_WS2812SERIAL
1501 template<SWS2812 CHIPSET, int DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1502 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1503 {
1505 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
1506 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
1507 }
1508#endif
1509
1510#ifdef SmartMatrix_h
1513 template<ESM CHIPSET, fl::Bus B = fl::Bus::AUTO>
1514 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1515 {
1517 switch(CHIPSET) {
1518 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1519 }
1520 }
1521#endif
1523
1524
1525#ifdef FASTLED_HAS_BLOCKLESS
1526
1547
1549 template<EBlockChipsets CHIPSET, int NUM_LANES, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1550 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1552 switch(CHIPSET) {
1553 #ifdef PORTA_FIRST_PIN
1554 case WS2811_PORTA: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1555 case WS2811_400_PORTA: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1556 case WS2813_PORTA: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1557 case TM1803_PORTA: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1558 case UCS1903_PORTA: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1559 #endif
1560 #ifdef PORTB_FIRST_PIN
1561 case WS2811_PORTB: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1562 case WS2811_400_PORTB: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1563 case WS2813_PORTB: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1564 case TM1803_PORTB: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1565 case UCS1903_PORTB: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1566 #endif
1567 #ifdef PORTC_FIRST_PIN
1568 case WS2811_PORTC: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1569 case WS2811_400_PORTC: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1570 case WS2813_PORTC: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1571 case TM1803_PORTC: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1572 case UCS1903_PORTC: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1573 #endif
1574 #ifdef PORTD_FIRST_PIN
1575 case WS2811_PORTD: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1576 case WS2811_400_PORTD: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1577 case WS2813_PORTD: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1578 case TM1803_PORTD: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1579 case UCS1903_PORTD: return addLeds(new fl::InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1580 #endif
1581 #ifdef HAS_PORTDC
1582 case WS2811_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1583 case WS2811_400_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1584 case WS2813_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1585 case TM1803_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1586 case UCS1903_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1587 #endif
1588 }
1589 }
1590
1592 template<EBlockChipsets CHIPSET, int NUM_LANES, fl::Bus B = fl::Bus::AUTO>
1593 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1594 return addLeds<CHIPSET,NUM_LANES,GRB,B>(data,nLedsOrOffset,nLedsIfOffset);
1595 }
1596
1597#endif
1598
1602
1606
1610
1617 void setDriverEnabled(const char* name, bool enabled);
1618
1643 template<fl::Bus B, fl::u8 Which = 0>
1647
1659 bool setExclusiveDriver(fl::Bus bus, fl::u8 which = 0);
1660
1664 bool isDriverEnabled(const char* name) const;
1665
1668 fl::size getDriverCount() const;
1669
1674
1676
1683 void wait();
1684
1688 bool wait(fl::u32 timeout_ms);
1689
1693 inline void setMaxPowerInVoltsAndMilliamps(fl::u8 volts, fl::u32 milliamps) { setMaxPowerInMilliWatts(volts * milliamps); }
1694
1697 inline void setMaxPowerInMilliWatts(fl::u32 milliwatts) {
1698 mNPowerData = milliwatts;
1699#if FL_COLOR_PIPELINE_SHARED
1700 fl::activeFramePowerDispatch() = fl::framePowerDispatch();
1701 mPPowerFunc = fl::activeFramePowerDispatch()->showBrightness;
1702#else
1704#endif
1705 }
1706
1715 void setHdFieldFloor(fl::u8 min_field);
1717 fl::u8 getHdFieldFloor() const;
1718
1724
1728 bool isPowerLimited() const;
1729
1733
1742 inline void setPowerModel(const PowerModelRGB& model) {
1743 set_power_model(model);
1744 }
1745
1755 inline void setPowerScalingExponent(float exponent) {
1757 }
1758
1762 inline float getPowerScalingExponent() const {
1764 }
1765
1766private:
1767 // Forward shims for the tiered-wait spin budget (#2818). Full impl
1768 // lives in src/fl/channels/detail/wait_spin_budget.{h,cpp.hpp}.
1769 // Declared here so we don't drag the channel-detail include graph
1770 // into FastLED.h.
1771 static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT;
1772 static fl::u32 _getWaitSpinBudgetUs() FL_NO_EXCEPT;
1773public:
1774
1788 inline void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT {
1789 _setWaitSpinBudgetUs(budget_us);
1790 }
1791
1793 inline fl::u32 getWaitSpinBudgetUs() const FL_NO_EXCEPT {
1794 return _getWaitSpinBudgetUs();
1795 }
1796
1801 inline void setPowerModel(const PowerModelRGBW& model) {
1802 set_power_model(model);
1803 }
1804
1809 inline void setPowerModel(const PowerModelRGBWW& model) {
1810 set_power_model(model);
1811 }
1812
1816 return get_power_model();
1817 }
1818
1857 fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter = true) const;
1858
1860
1869
1887
1892
1894
1901 void show(fl::u8 scale);
1902
1905 void show() { show(mScale); }
1906
1907 // Called automatically at the end of show().
1908 void onEndFrame();
1909
1913 void clear(bool writeData = false);
1914
1936 static void clear(ClearFlags flags);
1937
1939 void clearData();
1940
1944 void showColor(const CRGB & color, fl::u8 scale);
1945
1948 void showColor(const CRGB & color) { showColor(color, mScale); }
1949
1954 void delay(unsigned long ms);
1955
1959 void setTemperature(const CRGB & temp);
1960
1964 void setCorrection(const CRGB & correction);
1965
1969 void setDither(fl::u8 ditherMode = BINARY_DITHER);
1970
1985
1993 void setMaxRefreshRate(fl::u16 refresh, bool constrain=false);
1994
1999 void countFPS(int nFrames=25);
2000
2003 fl::u16 getFPS() { return mNFPS; }
2004
2007 int count();
2008
2012
2015 int size();
2016
2019 CRGB *leds();
2020};
2021
2023#define FastSPI_LED FastLED
2025#define FastSPI_LED2 FastLED
2026#ifndef LEDS
2028#define LEDS FastLED
2029#endif
2030
2032extern CFastLED FastLED;
2033
2037#ifndef HAS_HARDWARE_PIN_SUPPORT
2038#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
2039#define NO_HARDWARE_PIN_SUPPORT
2040#endif
2041
2042
2043#endif
2044
2045
2047
2048#if !defined(FASTLED_INTERNAL) && !defined(FASTLED_LEAN_AND_MEAN)
2049
2050#include "fl/stl/string.h" // Awesome Str class that has stack allocation and heap overflow, copy on write.
2051#include "fl/math/xymap.h" // XYMap class for mapping 2D coordinates on seperintine matrices.
2052
2053#include "fl/math/math.h" // fl::clamp, fl::map_range, fl::min, fl::max, etc.
2054
2055#include "fl/log/log.h" // FL_WARN("time now: %s", millis()), FL_WARN_IF(...), FL_PRINT(...), FL_LOG_*() category-specific logging
2056#include "fl/system/serial.h" // Arduino-compatible Serial API: fl::Serial.print(), fl::Serial.read(), etc.
2057#include "fl/stl/assert.h" // FASTLED_ASSERT(condition, "message");
2058#include "fl/stl/sstream.h" // fl::sstream for string stream operations
2059
2060// The remote RPC system (fl/remote/remote.h) is opt-in: it pulls the JSON
2061// parser, the RPC server and the scheduler (57 headers) into every sketch
2062// that includes FastLED.h. Sketches that use it include it directly, or
2063// define FL_INCLUDE_REMOTE before including FastLED.h.
2064#if defined(FL_INCLUDE_REMOTE)
2065#include "fl/remote/remote.h" // Remote RPC system for JSON-based function calls
2066#endif
2067
2068// provides:
2069// fl::vector<T> - Standard heap vector
2070// fl::vector_inlined<T,N> - Allocate on stack N elements, then overflow to heap vector.
2071// fl::vector_fixed<T,N> - Stack allocated fixed size vector, elements will fail to add when full.
2072#include "fl/stl/vector.h"
2073
2074// Flexible callbacks in the style of std::function.
2075#include "fl/stl/function.h"
2076
2077// Clears the led data and other objects.
2078// CRGB leds[NUM_LEDS];
2079// fl::clear(leds)
2080#include "fl/gfx/clear.h"
2081
2082// Leds has a CRGB block and an XYMap
2083#include "fl/gfx/leds.h"
2084
2085#include "fl/channels/spi.h" // SPI device and multi-lane SPI support (1-16 lanes)
2086
2087#include "fl/ui/ui.h" // Provides UIButton, UISlider, UICheckbox, UINumberField and UITitle, UIDescription, UIHelp, UIGroup.
2088using fl::UITitle;
2089using fl::UIDescription;
2090using fl::UIHelp;
2091using fl::UIButton; // These names are unique enough that we don't need to namespace them
2092using fl::UICheckbox;
2093using fl::UINumberField;
2094using fl::UISlider;
2095using fl::UIDropdown;
2096using fl::UIGroup;
2097using fl::XYMap;
2098using fl::round; // Template version avoids conflicts with ::round
2099// Only expose fl::delay as global delay() on non-hardware platforms (stub/WASM).
2100// On real Arduino platforms, Arduino's native delay(uint32_t) is already in scope;
2101// importing fl::delay there causes an ambiguous-overload error for any third-party
2102// library (e.g. IRremote) that calls the unqualified delay().
2103// Users who need fl::delay's async-task-pumping behaviour can call fl::delay() or
2104// fl::delayMs() explicitly.
2105#if defined(FASTLED_STUB_IMPL)
2106using fl::delay;
2107#endif
2108
2109// Common fl:: type aliases for global namespace convenience
2110template<typename T> using fl_vector = fl::vector<T>;
2111template<typename Key, typename Value, typename Compare = fl::less<Key>> using fl_map = fl::flat_map<Key, Value, Compare>;
2112using fl_string = fl::string;
2113
2114// Note: delayMicroseconds and delayMillis are provided by Arduino core
2115// The fl:: namespace versions are available for explicit use when needed
2116
2117#define FASTLED_TITLE(text) fl::UITitle g_title(text)
2118#define FASTLED_DESCRIPTION(text) fl::UIDescription g_description(text)
2119#define FASTLED_HELP(text) fl::UIHelp g_help(text)
2120
2121
2122#endif // FASTLED_INTERNAL && !FASTLED_LEAN_AND_MEAN
2123
2124
2125
2126// Experimental: loop() hijacking.
2127//
2128// EngineEvents requires that FastLED.show() be invoked.
2129// If the user skips that then certain updates will be skipped.
2130//
2131// Right now this isn't a big deal, but in the future it could be.
2132//
2133// Therefore this experiment is done so that this loop() hijack trick
2134// can be used to insert code at the start of every loop(), such as a
2135// scoped object that forces a begin and end frame event.
2136//
2137// It's possible to hijack the loop() via a macro so that
2138// extra code can be injected at the start of every frame.
2139// When FASTLED_LOOP_RUNS_ASYNC == 1
2140// then use loop() to also run the async.
2141//
2142// EXAMPLE:
2143// #define FASTLED_LOOP_RUNS_ASYNC 1
2144// #include "FastLED.h"
2145// void loop() {
2146// FL_WARN("async will run in the loop");
2147// delay(500);
2148// }
2149
2150#ifndef FASTLED_LOOP_RUNS_ASYNC
2151#define FASTLED_LOOP_RUNS_ASYNC 0
2152#endif
2153
2154#if FASTLED_LOOP_RUNS_ASYNC == 1
2155// The loop is set as a macro that re-defines the user loop function
2156// to sketch_loop()
2157#define loop() \
2158 sketch_loop(); \
2159 void loop() { sketch_loop(); fl::task::run(); } \
2160 void sketch_loop()
2161#endif
2162
2163// Backdoor to get the size of the CLedController object. The one place
2164// that includes this just uses extern to declare the function.
2165// Declaration moved to src/fl/system/fastled.h
#define BRIGHTNESS
int x
Definition simple.h:92
#define DATA_PIN
Definition ClientReal.h:82
#define CHIPSET
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
CLEDController * controller
fl::UISlider scale("Scale", 4,.1, 4,.1)
#define RGB_ORDER
Three-pin PWM controller for non-addressable RGB LEDs and strips.
Functions for doing a rotation of bits/bytes used by parallel output.
Portable compile-time identifiers for LED channel buses.
Portable bus/device introspection.
Per-driver traits keyed on fl::Bus.
ESP32-P4 Parallel IO (PARLIO) LED channel.
Phase 3b templated channel facade – Channel<Bus, Chipset> with compile-time bus/chipset enforcement.
Multi-lane SPI interface for LED output Hardware (SPI_HW): 1-8 parallel data lanes Software (SPI_BITB...
Contains the bulk of the definitions for the various LED chipsets supported.
APA102 high definition controller class.
Definition apa102.h:311
APA102 controller class.
Definition apa102.h:42
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world (legacy path).
Definition FastLED.h:1312
static void enableAllDrivers()
Enroll every channel driver available on this platform with ChannelManager.
power_func mPPowerFunc
function for overriding brightness when using FastLED.show();
Definition FastLED.h:731
fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter=true) const
Get estimated power consumption in milliwatts.
_FL_MAP_CLOCKED_CHIPSET(LPD6803, LPD6803Controller) _FL_MAP_CLOCKED_CHIPSET(LPD8806
void setExclusiveDriver() FL_NO_EXCEPT
Register a single driver at a priority above the platform default (compile-time TU-linking variant).
Definition FastLED.h:1644
void onEndFrame()
static fl::vector< fl::ChannelPtr > & channels()
stored ChannelPtrs to keep them alive
void setHdFieldFloor(fl::u8 min_field)
Lowest 5-bit current field the colour-managed APA102-HD path may use (B1's flicker floor,...
void setDriverEnabled(const char *name, bool enabled)
Enable or disable a channel driver by name at runtime.
static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
int size()
Get the number of leds in the first controller.
void setMaxPowerInVoltsAndMilliamps(fl::u8 volts, fl::u32 milliamps)
Set the maximum power to be used, given in volts and milliamps.
Definition FastLED.h:1693
CRGB * leds()
Get a pointer to led data for the first controller.
bool isDriverEnabled(const char *name) const
Check if a driver is enabled by name.
void setPowerModel(const PowerModelRGBWW &model)
Definition FastLED.h:1809
void onEndShowLeds()
Manually trigger the end show LEDs event.
void setMaxRefreshRate(fl::u16 refresh, bool constrain=false)
Set the maximum refresh rate.
static fl::RxChannelPtr addRx(const fl::RxChannelConfig &config)
Add an RX channel with runtime configuration.
void setTemperature(const CRGB &temp)
Set a global color temperature.
bool colorManagementStrict() const FL_NO_EXCEPT
Definition FastLED.h:1976
void show()
Update all our controllers with the current led colors.
Definition FastLED.h:1905
fl::u32 getWaitSpinBudgetUs() const FL_NO_EXCEPT
Get the current tiered-wait spin budget (microseconds).
Definition FastLED.h:1793
fl::u8 getBrightness()
Get the current global brightness setting.
Definition FastLED.h:1605
void showColor(const CRGB &color)
Set all leds on all controllers to the given color.
Definition FastLED.h:1948
void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
Override the channel-manager tiered-wait spin budget (microseconds).
Definition FastLED.h:1788
void onBeginFrame()
Manually trigger the begin frame event.
static fl::u32 _getWaitSpinBudgetUs() FL_NO_EXCEPT
static void remove(fl::ChannelPtr channel)
Remove a channel from the LED controller list.
::CLEDController & addLedsSpiChannel(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus)
Add an SPI controller with an explicit ESP-IDF SPI host.
Definition FastLED.h:1214
void showColor(const CRGB &color, fl::u8 scale)
Set all leds on all controllers to the given color/scale.
fl::u8 getLastShowBrightness() const
Brightness the most recent show() / showColor() actually applied, after the power limiter set by setM...
void removeListener(fl::EngineEvents::Listener *listener)
Definition FastLED.h:755
void setPowerModel(const PowerModelRGB &model)
Definition FastLED.h:1742
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController via Channel API (default speed).
Definition FastLED.h:1238
static fl::ChannelPtr add(const fl::ChannelConfig &config)
Definition FastLED.h:850
float getPowerScalingExponent() const
Get the configured brightness-to-power response exponent.
Definition FastLED.h:1762
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
CLEDController & operator[](int x)
Get a reference to a registered controller.
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController via Channel API (default RGB order and speed).
Definition FastLED.h:1224
void setMaxPowerInMilliWatts(fl::u32 milliwatts)
Set the maximum power to be used, given in milliwatts.
Definition FastLED.h:1697
void delay(unsigned long ms)
Delay for the given number of milliseconds.
fl::u8 getHdFieldFloor() const
static ::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world (legacy path).
Definition FastLED.h:1301
const fl::DiodeProfile * getRgbwColorimetricProfile() const FL_NO_EXCEPT
Currently active RGBW colorimetric profile (defaults to &fl::kRgbwDefaultProfile).
Definition FastLED.h:1889
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController via Channel API.
Definition FastLED.h:1204
void setPowerScalingExponent(float exponent)
Set a non-linear brightness-to-power response exponent.
Definition FastLED.h:1755
void setBrightness(fl::u8 scale)
Set the global brightness scaling.
Definition FastLED.h:1601
bool isPowerLimited() const
True if the power limiter lowered the brightness of the most recent show() / showColor() below what i...
void setColorManagementStrict(bool strict) FL_NO_EXCEPT
In strict mode a channel that requests color management without an emitter profile reports a rejected...
Definition FastLED.h:1973
fl::u8 mScale
the current global brightness scale setting
Definition FastLED.h:727
::CLEDController & addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::false_type)
Definition FastLED.h:1188
void setDither(fl::u8 ditherMode=BINARY_DITHER)
Set the dithering mode.
fl::size getDriverCount() const
Get count of registered channel drivers.
static fl::Watchdog & watchdog()
Access the unified cross-platform watchdog timer.
void setRgbwColorimetricProfile(const fl::DiodeProfile *profile) FL_NO_EXCEPT
Install a legacy fallback RGBW diode chromaticity profile for scalar colorimetric calls.
Definition FastLED.h:1884
void setDefaultSourceProfile(const fl::SourceProfile &profile) FL_NO_EXCEPT
Definition FastLED.h:1979
fl::u32 mNPowerData
max power use parameter
Definition FastLED.h:730
::CLEDController & addLeds(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus)
Add an SPI controller on a selected ESP-IDF host.
Definition FastLED.h:1290
fl::u16 mNFPS
tracking for current frames per second (FPS) value
Definition FastLED.h:728
fl::u8 mLastShownScale
brightness the last show()/showColor() applied, after the power limiter
Definition FastLED.h:733
fl::u32 mNMinMicros
minimum µs between frames, used for capping frame rates
Definition FastLED.h:729
void init()
Initialize platform-specific subsystems.
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a 3rd party library based CLEDController instance to the world.
Definition FastLED.h:1455
static void add(fl::ChannelPtr channel)
Add a Channel-based LED controller (from ChannelPtr)
void clearData()
Clear out the local data array.
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add an SPI based CLEDController instance to the world (legacy path).
Definition FastLED.h:1277
void addListener(fl::EngineEvents::Listener *listener)
Definition FastLED.h:754
fl::u8 mLastRequestedScale
brightness the last show()/showColor() was asked for
Definition FastLED.h:732
const fl::SourceProfile & defaultSourceProfile() const FL_NO_EXCEPT
Definition FastLED.h:1982
PowerModelRGB getPowerModel() const
Get current RGB power model.
Definition FastLED.h:1815
int count()
Get how many controllers have been registered.
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Definition FastLED.h:1051
void setPowerModel(const PowerModelRGBW &model)
Definition FastLED.h:1801
void wait()
Wait for all channel bus transmissions to complete.
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
void setCorrection(const CRGB &correction)
Set a global color correction.
fl::u16 getFPS()
Get the number of frames/second being written out.
Definition FastLED.h:2003
::CLEDController & addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
LPD8806Controller WS2803Controller MY9221Controller APA102Controller APA102ControllerHD APA102Controller HD108Controller SK9822ControllerHD ::CLEDController & addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::true_type)
Definition FastLED.h:1180
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a 3rd party library based CLEDController instance to the world.
Definition FastLED.h:1463
fl::span< const fl::DriverInfo > getDriverInfos() const
Get full state of all registered channel drivers.
static fl::ChannelEvents & channelEvents()
Access the channel event system.
and refresh rates, and provides access functions for driving led data to controllers via the show() /...
Definition FastLED.h:723
DMX512 based LED controller class, using the DMXSerial library.
Definition dmx.h:67
DMX512 based LED controller class, using the DmxSimple library.
Definition dmx.h:29
LPD6803 controller class (LPD1101).
Definition lpd880x.h:109
LPD8806 controller class.
Definition lpd880x.h:29
MY9221 controller class.
Definition my9221.h:46
P9813 controller class.
Definition p9813.h:26
SK9822 controller class.
Definition apa102.h:358
SK9822 controller class.
Definition apa102.h:336
SM16716 controller class.
Definition sm16716.h:25
WS2801 controller class.
Definition ws2801.h:25
WS2803 controller class.
Definition ws2801.h:93
void setExclusiveDriver() FL_NO_EXCEPT
Register a single driver at a priority above the platform default and disable all others (compile-tim...
Definition manager.h:356
static void removeListener(Listener *listener) FL_NO_EXCEPT
static void addListener(Listener *listener, int priority=0) FL_NO_EXCEPT
Shared legacy addLeds<ESPIChipsets ...>() bridge controller over an IChannelDriver,...
Unified cross-platform watchdog interface.
Definition watchdog.h:123
fl::CLEDController CLEDController
Declarations for the predefined color palettes supplied by FastLED.
Compatibility functions based on C++ version.
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Definition dither_mode.h:16
FastLED dynamic library interface - lightweight header for external callers.
Defines the DMX512-based LED controllers.
constexpr EOrder GRB
Definition eorder.h:19
constexpr EOrder RGB
Definition eorder.h:17
Task executor — runs registered task runners and manages the run loop.
#define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS)
Definition FastLED.h:1088
ClearFlags
Flags for FastLED.clear() to control what state gets cleared/reset.
Definition FastLED.h:666
@ CHANNELS
Remove all channels from controller list.
Definition FastLED.h:668
@ CHANNEL_ENGINES
Clear all channel drivers from ChannelManager.
Definition FastLED.h:673
@ POWER_SETTINGS
Reset power management (setMaxPowerInMilliWatts)
Definition FastLED.h:669
@ FPS_COUNTER
Reset FPS tracking counter to 0.
Definition FastLED.h:672
@ NONE
Clear nothing (no-op)
Definition FastLED.h:667
@ REFRESH_RATE
Reset refresh rate limiting to unlimited.
Definition FastLED.h:671
ClearFlags & operator|=(ClearFlags &a, ClearFlags b)
Enable bitwise OR assignment for ClearFlags.
Definition FastLED.h:687
SWS2812
WS2812Serial Library controller type.
Definition FastLED.h:328
@ WS2812SERIAL
Definition FastLED.h:328
ClearFlags operator|(ClearFlags a, ClearFlags b)
Enable bitwise OR for ClearFlags.
Definition FastLED.h:677
OWS2811
Octo WS2811 LED Library controller types.
Definition FastLED.h:323
@ OCTOWS2811
Definition FastLED.h:323
@ OCTOWS2813
Definition FastLED.h:323
@ OCTOWS2811_400
Definition FastLED.h:323
ClearFlags operator&(ClearFlags a, ClearFlags b)
Enable bitwise AND for ClearFlags.
Definition FastLED.h:682
ESPIChipsets
Backwards compatibility enum - allows old code to use unscoped names (e.g., APA102 instead of fl::Spi...
Definition FastLED.h:296
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:309
@ P9813
P9813 LED chipset.
Definition FastLED.h:303
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
Definition FastLED.h:306
@ SK9822
SK9822 LED chipset.
Definition FastLED.h:305
@ MY9221
MY9221 12-channel LED driver (dual-edge clocked; 4 RGB LEDs per chip)
Definition FastLED.h:302
@ WS2803
WS2803 LED chipset.
Definition FastLED.h:300
@ HD107
Same as APA102, but in turbo 40-mhz mode.
Definition FastLED.h:310
@ HD107S
Marketed HD107S part name; alias of HD107.
Definition FastLED.h:311
@ WS2801
WS2801 LED chipset.
Definition FastLED.h:299
@ DOTSTAR
APA102 LED chipset alias.
Definition FastLED.h:307
@ APA102
APA102 LED chipset.
Definition FastLED.h:304
@ LPD8806
LPD8806 LED chipset.
Definition FastLED.h:298
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
Definition FastLED.h:312
@ LPD6803
LPD6803 LED chipset.
Definition FastLED.h:297
@ DOTSTARHD
APA102HD LED chipset alias.
Definition FastLED.h:308
@ SM16716
SM16716 LED chipset.
Definition FastLED.h:301
@ HD108
16-bit variant of HD107, always gamma corrected. No SD (standard definition) option available - all H...
Definition FastLED.h:313
ESM
Smart Matrix Library controller type.
Definition FastLED.h:318
@ SMART_MATRIX
Definition FastLED.h:318
EBlockChipsets
Blockless output port enum.
Definition FastLED.h:601
fl::u8(* power_func)(fl::u8 scale, fl::u32 data)
Typedef for a power consumption calculation function.
Definition FastLED.h:646
Contains definitions that can be used to configure FastLED at compile time.
Utility functions and classes for managing delay cycles.
Wrapper definitions to allow seamless use of PROGMEM in environments that have it.
Backward compatibility header - use fl/fastpin.h directly.
#define DATA_RATE_MHZ
Definition fastspi.h:95
Serial peripheral interface (SPI) definitions per platform.
Data types and constants used by SPI interfaces.
Public color namespace facade for RGBW colorimetric profile APIs.
Functions for red, green, blue, white (RGBW) output.
Internal FastLED header for implementation files.
fl::CRGB CRGB
Definition crgb.h:25
fl::u8 calculate_max_brightness_for_power_mW(const CRGB *ledbuffer, fl::u16 numLeds, fl::u8 target_brightness, fl::u32 max_power_mW)
Determines the highest brightness level you can use and still stay under the specified power budget f...
void set_power_model(const PowerModelRGB &model)
Set custom RGB LED power consumption model.
float get_power_scaling_exponent()
Get the current brightness-to-power response exponent.
void set_power_scaling_exponent(float exponent)
Set a non-linear brightness-to-power response exponent.
PowerModelRGB get_power_model()
Get current RGB power model.
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.
Centralized logging categories for FastLED hardware interfaces and subsystems.
Unified manager for channel drivers with priority-based fallback.
bool & colorProfileStrictMode() FL_NO_EXCEPT
SourceProfile & defaultSourceProfile() FL_NO_EXCEPT
static constexpr EmitterProfile WS2812B
unsigned char u8
Definition stdint.h:131
Esp32SpiBus
ESP-IDF SPI host selection for an individual clocked LED controller.
Definition spi_bus.h:18
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
void delay(u32 ms, bool run_async=true) FL_NO_EXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Definition delay.h:98
ChannelManager & channelManager()
Get the global ChannelManager singleton instance.
FL_DISABLE_WARNING_PUSH unsigned char * B
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Definition math.h:71
integral_constant< bool, false > false_type
Definition type_traits.h:28
enable_if<!is_integral< T >::value, T >::type round(T value) FL_NO_EXCEPT
Definition math.h:319
void busKeepAlive() FL_NO_EXCEPT
Definition bus_traits.h:123
Bus
Portable public bus selector.
Definition bus.h:27
@ AUTO
Definition bus.h:28
const DiodeProfile * get_rgbw_colorimetric_profile() FL_NO_EXCEPT
Definition rgbw.cpp.hpp:209
void set_rgbw_colorimetric_profile(const DiodeProfile *profile) FL_NO_EXCEPT
Definition rgbw.cpp.hpp:202
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
Definition eorder.h:13
PowerCodecPolicy powerChannelCodecPolicy(const CLEDController &controller) FL_NO_EXCEPT
Identify the channel's final current/quantization choice without adding a virtual slot or storage to ...
constexpr T degrees(T rad) FL_NO_EXCEPT
Definition math.h:527
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NO_EXCEPT
SpiChipset
LED chipsets with SPI interface (clocked protocols) Modern type-safe enum class - prefer this for new...
@ SM16716
SM16716 LED chipset.
@ LPD6803
LPD6803 LED chipset.
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
@ HD107
Same as APA102, but in turbo 40-mhz mode.
@ DOTSTARHD
APA102HD LED chipset alias.
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
@ HD107S
Marketed HD107S part name; protocol-compatible alias of HD107.
@ SK9822
SK9822 LED chipset.
@ DOTSTAR
APA102 LED chipset alias.
@ P9813
P9813 LED chipset.
@ APA102
APA102 LED chipset.
@ HD108
16-bit variant of HD107, always gamma corrected. No SD (standard definition) option available - all H...
@ LPD8806
LPD8806 LED chipset.
@ WS2803
WS2803 LED chipset.
@ MY9221
MY9221 12-channel LED driver (dual-edge clocked; 4 RGB LEDs per chip)
@ WS2801
WS2801 LED chipset.
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
integral_constant< bool, true > true_type
Definition type_traits.h:27
constexpr T radians(T deg) FL_NO_EXCEPT
Definition math.h:522
Base definition for an LED controller.
Definition crgb.hpp:179
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.
Common RX interfaces and shared types.
#define FL_NO_EXCEPT
Shared "slim bridge" legacy addLeds<ESPIChipsets ...>() controller for the SPI channel API – driver-a...
SPI LED chipset enumeration.
#define FL_STATIC_ASSERT(...)
Portable compile-time assertion wrapper.
static const bool IS_VALID
Definition FastLED.h:1083
RGB LED power consumption model Used for standard 3-channel LEDs (WS2812, WS2812B,...
Definition power_mgt.h:29
RGBW LED power consumption model Used for 4-channel LEDs (SK6812 RGBW and similar).
Definition power_mgt.h:57
RGBWW LED power consumption model (RGB + warm white + cool white).
Definition power_mgt.h:98
Configuration for a single LED channel.
Definition config.h:167
Singleton event router for Channel lifecycle events.
A source declaration, not a container or an output-device selection.
SPI chipset configuration (data + clock pins)
Definition config.h:103
static SpiEncoder spiEncoderForChipset(SpiChipset chipset, u32 speed_hz_override=0) FL_NO_EXCEPT
Look up the default SpiEncoder for a given chipset.
Definition spi.h:161
SPI encoder configuration for LED protocols.
Definition spi.h:38
Aggregator header for the fl/ui/ family of per-element UI types.
Unified cross-platform Watchdog Timer API for FastLED.