FastLED 3.10.9
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// Other Arduino platforms need framework declarations before platform headers.
14// ESP32 supplies those declarations through native SDK headers; an application's
15// Arduino includes remain application-owned. fl/math/math.h below normalizes
16// any math macros introduced by application or platform headers.
17#if defined(ARDUINO) && !defined(FL_IS_ESP32)
18#include "fl/system/arduino.h"
19#endif
20
23
24#if defined(FL_IS_GCC) || defined(FL_IS_CLANG)
25#define FASTLED_HAS_PRAGMA_MESSAGE
26#endif
27
33#define FASTLED_VERSION 3010009
34#ifndef FASTLED_INTERNAL
35# ifdef FASTLED_SHOW_VERSION
36# ifdef FASTLED_HAS_PRAGMA_MESSAGE
37# pragma message "FastLED version 3.010.009"
38# else
39# warning FastLED version 3.010.009 (Not really a warning, just telling you here.)
40# endif
41# endif
42#endif
43// ESP32 I2S Driver: `FASTLED_ESP32_I2S` used to opt into the Yves
44// parallel-out clockless driver. Removed at FastLED#3526 Phase 2e — the
45// modern unified engine on `Bus::FLEX_IO, 0` is now the only I2S path.
46// Users who previously defined `-DFASTLED_ESP32_I2S=1` should drop the
47// flag; clockless output still routes through RMT by default. If the
48// modern I2S path is specifically desired, use
49// `FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>()`.
50#if defined(FASTLED_ESP32_I2S) && !defined(FASTLED_INTERNAL)
51#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>()."
52#endif
53
54// Pre-4.0 Teensy boards are end-of-life.
55//
56// Teensy LC and 3.0-3.6 are discontinued. FastLED still compiles for them and
57// we still fix reported bugs, but they get no hardware validation -- see
58// FastLED#3983, where bench testing is scoped to Teensy 4.0/4.1 only. Users on
59// these boards should know they are on an unvalidated path before they debug
60// something we cannot reproduce.
61//
62// Note the guard covers BOTH umbrellas: `FL_IS_TEENSY_3X` is only 3.0-3.6, and
63// Teensy LC sits beside it rather than inside it (see
64// platforms/arm/teensy/is_teensy.h). Testing 3X alone would silently miss the
65// LC, which is the most end-of-life board of the set.
66#if (defined(FL_IS_TEENSY_3X) || defined(FL_IS_TEENSY_LC)) && \
67 !defined(FASTLED_INTERNAL) && !defined(FL_TEENSY_EOL_SUPPRESS_WARNING)
68#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."
69#endif
70
71// Legacy RMT4 backend is ESP-IDF 4.x only.
72//
73// On IDF 5.x the legacy TX and RX implementations no longer build: RMTMEM is not
74// exposed by the public headers, and both engines predate the current
75// IChannelDriver / RmtRxChannel contracts. `-DFASTLED_RMT5=0` there produced a
76// wall of unrelated compiler errors, and the old guard sent users chasing
77// -DESP32_ARDUINO_NO_RGB_BUILTIN=1, which gets past the guard but not past the
78// build. Reject the combination up front with one accurate diagnostic instead.
79// RMT5 is already the IDF 5.x default, so nothing that builds today is lost.
80// See FastLED#3936.
81//
82// Note the version test: FASTLED_RMT5 also defaults to 0 on IDF 4.x, where RMT4
83// is the correct native backend and must keep building.
84#if defined(FL_IS_ESP32)
85#include "platforms/esp/esp_version.h" // ok platform headers
86#include "platforms/esp/32/feature_flags/enabled.h" // ok platform headers
87#include "platforms/esp/32/esp32_lazy_serial0_main.h" // ok platform headers
88#if FASTLED_RMT5 == 0 && FASTLED_ESP32_HAS_RMT && ESP_IDF_VERSION_5_OR_HIGHER
89#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"
90#endif
91#endif
92
93
94#if !defined(FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS)
95#if defined(FL_IS_WASM)
96#define FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS 1
97#else
98#define FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS 0
99#endif
100#endif
101
102// Platforms that register real hardware channel drivers (clockless and/or SPI).
103// User-overridable: define before including FastLED.h to force on/off.
104#if !defined(FASTLED_HAS_CHANNELS)
105#if defined(FL_IS_ESP32) || defined(FL_IS_TEENSY_4X) || \
106 defined(FL_IS_RP) || defined(FL_IS_STM32) || \
107 defined(FL_IS_SAMD) || defined(FL_IS_NRF52)
108#define FASTLED_HAS_CHANNELS 1
109#else
110#define FASTLED_HAS_CHANNELS 0
111#endif
112#endif
113
114// Route SPI chipsets (APA102, SK9822, etc.) through the Channel API instead of
115// legacy APA102Controller/SPIOutput. Only enabled on platforms where
116// DATA_RATE_MHZ() returns Hz (not clock dividers) so that the SPI_DATA_RATE
117// template parameter can be passed directly to the channel encoder.
118#if !defined(FASTLED_SPI_USES_CHANNEL_API)
119#if FASTLED_HAS_CHANNELS && (defined(FL_IS_ESP32) || defined(FL_IS_TEENSY_4X) || \
120 defined(FL_IS_RP2040) || defined(FL_IS_RP2350))
121#define FASTLED_SPI_USES_CHANNEL_API 1
122#else
123#define FASTLED_SPI_USES_CHANNEL_API 0
124#endif
125#endif
126
127#ifndef __PROG_TYPES_COMPAT__
131#define __PROG_TYPES_COMPAT__
132#endif
133
134#ifdef FL_IS_WASM
135#include "platforms/wasm/js.h" // ok platform headers
136#include "platforms/wasm/led_sysdefs_wasm.h" // ok platform headers
137#include "platforms/wasm/compiler/Arduino.h" // ok platform headers
138#include "platforms/wasm/js_fetch.h" // ok platform headers
139#endif
140
141#ifdef SmartMatrix_h
142// IWYU pragma: begin_keep
143#include <SmartMatrix.h>
144// IWYU pragma: end_keep
145#endif
146
147#ifdef DmxSimple_h
148// IWYU pragma: begin_keep
149#include <DmxSimple.h>
150// IWYU pragma: end_keep
151#endif
152
153#ifdef DmxSerial_h
154// IWYU pragma: begin_keep
155#include <DMXSerial.h>
156// IWYU pragma: end_keep
157#endif
158
159#ifdef USE_OCTOWS2811
160// IWYU pragma: begin_keep
161#include <OctoWS2811.h>
162// IWYU pragma: end_keep
163#endif
164
165// Convenience includes for sketch inclusion
166#include "fl/task/executor.h"
168#include "fl/channels/rx.h"
169#include "fl/stl/array.h"
170#include "fl/stl/vector.h"
171#include "fl/stl/cstring.h"
172#include "fl/system/pin.h"
173
174
176#include "fl/stl/static_assert.h"
177#include "cpp_compat.h"
178
179#include "fastled_config.h"
180#include "led_sysdefs.h"
181
182// Include the internal FastLED header (provides core types without cycles)
183#include "fl/system/fastled.h"
184
185#include "fl/channels/channel.h"
187#include "fl/wdt/watchdog.h" // for fl::Watchdog (FastLED.watchdog() accessor)
188#include "fl/channels/manager.h"
189#include "fl/channels/config.h" // for ChannelConfig, MultiChannelConfig
190#include "fl/channels/bus.h" // for fl::Bus, fl::DefaultBus (Phase 3b, #2428)
191#include "fl/channels/bus_info.h" // for fl::deviceInfo (portable bus introspection)
192#include "fl/channels/bus_traits.h" // for fl::BusTraits, fl::BusSupports (Phase 3b, #2428)
193#include "fl/channels/channel_typed.h" // for fl::TypedChannel<B, Chipset> (Phase 3b, #2428)
194#include "fl/channels/slim_spi_bridge_controller.h" // for fl::SlimSpiBridgeController (#4585)
196#include "fl/stl/type_traits.h" // for fl::true_type/false_type (SPI addLeds<> dispatch, #4585)
197
198#include "fl/audio/input.h"
200
201// CFastLED::add(UIAudio&) only needs the name, which audio_manager.h forward
202// declares; the full UI headers (and the JSON UI they pull in on host/wasm)
203// are provided to sketches by the convenience block at the bottom of this
204// file, not to every library TU.
206
207// ============================================================================
208// C STRING FUNCTION USING DECLARATIONS
209// ============================================================================
210
216
217// Utility functions
218#include "fastled_delay.h"
219#include "bitswap.h"
220
221#include "lib8tion.h"
222
223// ============================================================================
224// MATH FUNCTION USING DECLARATIONS
225// ============================================================================
226
227// fl/math/math.h normalizes macros introduced by application/platform headers.
228// fl/stl/undef.h is intentionally re-includable for later normalization.
229
230#include "controller.h"
231#include "fastpin.h"
232#include "fastspi_types.h"
233#include "dmx.h"
234
235#include "platforms.h"
236
237// Default example pins; must follow platforms.h so board pin tables win.
238#include "platforms/default_pins.h"
239
240// Library Dependency Finder (LDF) hint headers
241// These headers use #if 0 blocks to hint library dependencies to the LDF scanner
242// without actually compiling the code. This works around LDF's limitation of scanning
243// headers without evaluating preprocessor paths.
244#include "platforms/ldf_headers.h"
245
246// Pass 2 macro cleanup: fl/math/math.h includes fl/stl/undef.h which undefs any
247// min/max/abs/round/radians/degrees/map macros re-introduced by platform headers above.
248// Then provides type-safe fl:: replacements brought into global scope via using below.
249#include "fl/math/math.h"
250
251// Bring fl:: math functions into global namespace for Arduino compatibility
252// Teensy platforms define their own template min/max in wiring.h (global namespace),
253// so we skip bringing fl::min/fl::max into global scope to avoid ambiguity.
254#if !defined(FL_IS_TEENSY)
255using fl::min;
256using fl::max;
257#endif
258using fl::abs;
259using fl::radians;
260using fl::degrees;
261
262// Note: Arduino map() function is defined in global namespace (platforms/stub/Arduino.h)
263// fl::map refers to the map container (red-black tree) and our map() function delegate.
264#include "fastled_progmem.h"
265#include "pixeltypes.h"
266#include "hsv2rgb.h"
267#include "colorutils.h"
268#include "pixelset.h"
269#include "colorpalettes.h"
270
271#include "noise.h"
272#include "power_mgt.h"
274
275#include "fastspi.h"
276#include "chipsets.h"
277#include "fl/chipsets/analog.h"
279
280#include "fl/gfx/leds.h"
281#include "fl/gfx/rgbw.h" // RGBW mode config (wrapped on CFastLED below)
282#include "fl/color/rgbw.h" // colorimetric profile facade
283
284// clockless.h removed - BulkClockless API has been superseded by Channel API
285
286// SPI chipset enumeration (modern type-safe enum class)
288
292 LPD6803 = static_cast<int>(fl::SpiChipset::LPD6803),
293 LPD8806 = static_cast<int>(fl::SpiChipset::LPD8806),
294 WS2801 = static_cast<int>(fl::SpiChipset::WS2801),
295 WS2803 = static_cast<int>(fl::SpiChipset::WS2803),
296 SM16716 = static_cast<int>(fl::SpiChipset::SM16716),
297 MY9221 = static_cast<int>(fl::SpiChipset::MY9221),
298 P9813 = static_cast<int>(fl::SpiChipset::P9813),
299 APA102 = static_cast<int>(fl::SpiChipset::APA102),
300 SK9822 = static_cast<int>(fl::SpiChipset::SK9822),
301 SK9822HD = static_cast<int>(fl::SpiChipset::SK9822HD),
302 DOTSTAR = static_cast<int>(fl::SpiChipset::DOTSTAR),
304 APA102HD = static_cast<int>(fl::SpiChipset::APA102HD),
305 HD107 = static_cast<int>(fl::SpiChipset::HD107),
306 HD107S = static_cast<int>(fl::SpiChipset::HD107S),
307 HD107HD = static_cast<int>(fl::SpiChipset::HD107HD),
308 HD108 = static_cast<int>(fl::SpiChipset::HD108),
309};
310
314
319
324
325#ifdef HAS_PIXIE
326template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
327#endif
328
329#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
334
337template<fl::u8 DATA_PIN> class NEOPIXEL : public WS2812Controller800Khz<DATA_PIN, GRB> {};
338
341template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
342class SM16703 : public SM16703Controller<DATA_PIN, RGB_ORDER> {};
343
346template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
347class SM16824E : public SM16824EController<DATA_PIN, RGB_ORDER> {};
348
351template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
352class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
353
359template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
360class TX1813N1 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
361
367template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
368class TM1812 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
369
372template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
373class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
374
379template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
380class TM1908 : public TM1908Controller<DATA_PIN, RGB_ORDER> {};
381
384template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
385class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
386
389template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
390class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {};
391
394template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
395class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {};
396
399template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
400class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {};
401
404template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
405class UCS1904 : public UCS1904Controller800Khz<DATA_PIN, RGB_ORDER> {};
406
409template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
410class UCS2903 : public UCS2903Controller<DATA_PIN, RGB_ORDER> {};
411
414template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
415class UCS7604 : public UCS7604Controller8bit<DATA_PIN, RGB_ORDER> {};
416
419template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
420class UCS7604HD : public UCS7604Controller16bit<DATA_PIN, RGB_ORDER> {};
421
425template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
426class UCS7604HD_1600 : public UCS7604Controller16bit1600<DATA_PIN, RGB_ORDER> {};
427
430template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
431class WS2812 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
432
434template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
435class WS2815 : public WS2815Controller<DATA_PIN, RGB_ORDER> {};
436
438template <fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
439class WS2816 : public WS2816Controller<DATA_PIN, RGB_ORDER> {};
440
443template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
444class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
445
448template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
449class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
450
456template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
457class OSTW2020C1E : public OSTW2020C1EController<DATA_PIN, RGB_ORDER> {};
458
461template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
462class WS2812BMiniV3 : public WS2812BMiniV3Controller<DATA_PIN, RGB_ORDER> {};
463
466template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
467class WS2812BV5 : public WS2812BV5Controller<DATA_PIN, RGB_ORDER> {};
468
475template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
476class GS1903 : public GS1903Controller<DATA_PIN, RGB_ORDER> {};
477
480template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
481class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
482
487template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
488class LC8816E : public LC8816EController<DATA_PIN, RGB_ORDER> {};
489
499template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
500class SK6812WWA : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
501
504template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
505class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
506
509template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
510class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
511
514template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
515class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
516
519template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
520class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
521
524template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
525class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
526
532template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
533class WS2814 : public WS2814Controller<DATA_PIN, RGB_ORDER> {};
534
540template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
541class WS2818 : public WS2818Controller<DATA_PIN, RGB_ORDER> {};
542
545template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
546class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
547
550template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
551class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
552
555template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
556class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
557
560template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
561class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
562
565template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
566class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
567
570template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
571class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
572
575template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
576class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
577
579template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
580class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
581
582#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
584template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
585#endif
586#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
588template<fl::EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
589#endif
590#endif
593
594
597#ifdef PORTA_FIRST_PIN
598 WS2811_PORTA,
599 WS2813_PORTA,
600 WS2811_400_PORTA,
601 TM1803_PORTA,
602 UCS1903_PORTA,
603#endif
604#ifdef PORTB_FIRST_PIN
605 WS2811_PORTB,
606 WS2813_PORTB,
607 WS2811_400_PORTB,
608 TM1803_PORTB,
609 UCS1903_PORTB,
610#endif
611#ifdef PORTC_FIRST_PIN
612 WS2811_PORTC,
613 WS2813_PORTC,
614 WS2811_400_PORTC,
615 TM1803_PORTC,
616 UCS1903_PORTC,
617#endif
618#ifdef PORTD_FIRST_PIN
619 WS2811_PORTD,
620 WS2813_PORTD,
621 WS2811_400_PORTD,
622 TM1803_PORTD,
623 UCS1903_PORTD,
624#endif
625#ifdef HAS_PORTDC
626 WS2811_PORTDC,
627 WS2813_PORTDC,
628 WS2811_400_PORTDC,
629 TM1803_PORTDC,
630 UCS1903_PORTDC,
631#endif
632};
633
634
641typedef fl::u8 (*power_func)(fl::u8 scale, fl::u32 data);
642
661enum class ClearFlags : fl::u32 {
662 NONE = 0,
663 CHANNELS = 1 << 0,
664 POWER_SETTINGS = 1 << 1,
665 BRIGHTNESS = 1 << 2,
666 REFRESH_RATE = 1 << 3,
667 FPS_COUNTER = 1 << 4,
669};
670
673 return static_cast<ClearFlags>(static_cast<fl::u32>(a) | static_cast<fl::u32>(b));
674}
675
678 return static_cast<ClearFlags>(static_cast<fl::u32>(a) & static_cast<fl::u32>(b));
679}
680
683 a = a | b;
684 return a;
685}
686
712#define FL_DITHER_ENABLE_MIN_REFRESH_HZ 100
713
718class CFastLED {
721 // int m_nControllers;
723 fl::u16 mNFPS;
725 fl::u32 mNPowerData;
730
731public:
733
745 void init() FL_NO_EXCEPT;
746
747 // Useful when you want to know when an event like onFrameBegin or onFrameEnd is happening.
748 // This is disabled on AVR to save space.
749 void addListener(fl::EngineEvents::Listener *listener) FL_NO_EXCEPT { fl::EngineEvents::addListener(listener); }
751
759
774 static fl::Watchdog& watchdog() FL_NO_EXCEPT;
775
780
784
788
790
802 static ::CLEDController &addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT;
803
806
821 static void add(fl::ChannelPtr channel) FL_NO_EXCEPT;
822
842 static fl::ChannelPtr add(const fl::ChannelConfig& config) FL_NO_EXCEPT;
843
844 template<fl::ProfileId Profile>
845 static fl::ChannelPtr add(const fl::ChannelConfig& config) FL_NO_EXCEPT {
846 fl::ChannelPtr channel = fl::Channel::create<Profile>(config);
847 if (channel != nullptr) add(channel);
848 return channel;
849 }
850
871
889 static fl::vector<fl::ChannelPtr> add(fl::initializer_list<fl::ChannelConfig> configs) FL_NO_EXCEPT;
890
911
920 static fl::RxChannelPtr addRx(const fl::RxChannelConfig& config) FL_NO_EXCEPT;
921
943
960
975
1000 static void enableAllDrivers() FL_NO_EXCEPT;
1001
1018 static void remove(fl::ChannelPtr channel) FL_NO_EXCEPT;
1019
1028 static void remove(fl::shared_ptr<fl::audio::Processor> processor) FL_NO_EXCEPT;
1029
1031
1044 template<template<fl::u8, fl::u8, fl::u8> class CHIPSET,
1045 fl::u8 RED_PIN, fl::u8 GREEN_PIN, fl::u8 BLUE_PIN>
1046 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset,
1047 int nLedsIfOffset = 0) FL_NO_EXCEPT {
1049 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
1050 }
1051
1052
1072
1073
1074 // Base template: Causes a compile-time error if an unsupported CHIPSET is used
1075 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN>
1077 // Default implementation, will be specialized for supported chipsets
1078 static const bool IS_VALID = false;
1079 };
1080
1081 // Macro to define a mapping from the ESPIChipeset enum to the controller class
1082 // in it's various template configurations.
1083 #define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS) \
1084 template<fl::u8 DATA_PIN, fl::u8 CLOCK_PIN> \
1085 struct ClockedChipsetHelper<CHIPSET_ENUM, DATA_PIN, CLOCK_PIN> { \
1086 static const bool IS_VALID = true; \
1087 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN> ControllerType; \
1088 /* Controller type with RGB_ORDER specified */ \
1089 template<fl::EOrder RGB_ORDER> \
1090 struct CONTROLLER_CLASS_WITH_ORDER { \
1091 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER> ControllerType; \
1092 }; \
1093 /* Controller type with RGB_ORDER and spi frequency specified */ \
1094 template<fl::EOrder RGB_ORDER, fl::u32 FREQ> \
1095 struct CONTROLLER_CLASS_WITH_ORDER_AND_FREQ { \
1096 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER, FREQ> ControllerType; \
1097 }; \
1098 };
1099
1100 // Define specializations for each supported CHIPSET
1101 // Note: Using unscoped enum values for backwards compatibility
1109
1110 // Both DOTSTAR and APA102 use the same controller class
1113
1114 // Both DOTSTARHD and APA102HD use the same controller class
1117
1120
1122
1125
1126
1127 #if FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS
1131 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) {
1132 // Instantiate the controller using ClockedChipsetHelper
1133 // Always USE WS2812 clockless controller since it's the common path.
1134 return addLeds<WS2812, DATA_PIN, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1135 }
1136
1138 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) {
1139 // Always USE WS2812 clockless controller since it's the common path.
1140 return addLeds<WS2812, DATA_PIN, B>(data, nLedsOrOffset, nLedsIfOffset);
1141 }
1142
1143
1144 // The addLeds function using ChipsetHelper
1145 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1146 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1147 // Always USE WS2812 clockless controller since it's the common path.
1148 return addLeds<WS2812, DATA_PIN, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1149 }
1150
1151 #endif // FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS (fake-SPI overloads)
1152
1153 // Channel-API SPI entry points (#4585). Always declared (templates are only
1154 // instantiated on use) so host tests can pin the exact code path that
1155 // `addLeds<ESPIChipsets ...>()` takes when FASTLED_SPI_USES_CHANNEL_API=1,
1156 // even though the shared test PCH parses FastLED.h with the host default
1157 // (0). Under FASTLED_SPI_USES_CHANNEL_API the public addLeds<> overloads
1158 // below forward here verbatim.
1159 //
1160 // Compile-time dispatch (#4585, #4636): every SPI chipset routes through
1161 // the slim `fl::SlimSpiBridgeController`. MY9221 uses the bit-bang
1162 // `MY9221Controller` instead, because it is dual-edge (DDR) clocked and
1163 // cannot be carried as SPI bytes. No runtime `fl::Channel` is ever built
1164 // for legacy `addLeds<>`. C++11 has no `if constexpr`, so the two bodies
1165 // are separate overloads selected via a `fl::true_type`/`fl::false_type`
1166 // tag -- only the overload actually called gets instantiated, so the
1167 // never-taken branch never names `SlimSpiBridgeController<..., MY9221, ...>`.
1168 //
1169 // DATA_PIN / CLOCK_PIN / RATE / VARIANT exist only to key the
1170 // function-local statics exactly like the old per-`addLeds<>`-instantiation
1171 // `static ChannelPtr sChannel` was keyed: two strips of the same chipset on
1172 // different pins (or via different overloads) must get distinct controllers.
1173 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT,
1175 static ::CLEDController &addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset,
1176 const fl::SpiChipsetConfig &spiCfg, fl::true_type /*useSlim*/) FL_NO_EXCEPT {
1178 return addLeds(&sCtrl, data, nLedsOrOffset, nLedsIfOffset);
1179 }
1180
1181 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT,
1182 fl::EOrder RGB_ORDER, fl::Bus B, fl::u8 B_WHICH>
1183 static ::CLEDController &addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset,
1184 const fl::SpiChipsetConfig &spiCfg, fl::false_type /*isMY9221 -> bit-bang*/) FL_NO_EXCEPT {
1185 (void)spiCfg;
1186 static MY9221Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, (RATE ? RATE : DATA_RATE_MHZ(1))> sCtrl;
1187 // Register (and bind the LED buffer) only once per specialization; a
1188 // repeated call must not rebind the shared controller's buffer.
1189 static bool sRegistered = false;
1190 if (sRegistered) {
1191 return sCtrl;
1192 }
1193 sRegistered = true;
1194 return addLeds(&sCtrl, data, nLedsOrOffset, nLedsIfOffset);
1195 }
1196
1197 // Only explicit-host slim controllers reference the native SPI driver, so
1198 // AUTO-host and MY9221 sketches never link the ESP-IDF SPI master stack.
1200#if defined(FL_IS_ESP32)
1201 if (spiCfg.spiBus != fl::Esp32SpiBus::AUTO) {
1202 fl::platforms::registerNativeSpiDriver();
1203 }
1204#else
1205 (void)spiCfg;
1206#endif
1207 }
1208
1210 (void)spiCfg;
1211 }
1212
1214 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>
1215 ::CLEDController &addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1217 static_cast<fl::SpiChipset>(CHIPSET), SPI_DATA_RATE);
1218 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1220 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, SPI_DATA_RATE, 0, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1221 }
1222
1224 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>
1227 static_cast<fl::SpiChipset>(CHIPSET), SPI_DATA_RATE);
1228 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder, spiBus);
1230 registerExplicitSpiHost(spiCfg, UseSlim());
1232 }
1233
1235 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1236 static ::CLEDController &addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1238 static_cast<fl::SpiChipset>(CHIPSET));
1239 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1240 // HD108 defaults to GRB; all other SPI chipsets default to RGB.
1241 constexpr fl::EOrder order =
1243 ? GRB : RGB;
1245 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, 0, 2, order, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1246 }
1247
1249 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>
1250 ::CLEDController& addLedsSpiChannel(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1252 static_cast<fl::SpiChipset>(CHIPSET));
1253 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1255 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, 0, 3, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1256 }
1257
1258 #if FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS
1259 // Fake-SPI overloads declared above.
1260 #elif FASTLED_SPI_USES_CHANNEL_API
1261
1263 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>
1264 ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1266 }
1267
1269 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>
1270 ::CLEDController &addLeds(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) {
1272 }
1273
1275 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1276 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1277 return addLedsSpiChannel<CHIPSET, DATA_PIN, CLOCK_PIN, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset);
1278 }
1279
1281 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>
1282 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1283 return addLedsSpiChannel<CHIPSET, DATA_PIN, CLOCK_PIN, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset);
1284 }
1285
1286 #else
1287
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> ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1291 // Instantiate the controller using ClockedChipsetHelper
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 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1297 }
1298
1301 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>
1305 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1306 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
1307 static ControllerTypeWithFreq c;
1308 c.setSpiBus(spiBus);
1309 return addLeds(&c, data, nLeds, 0);
1310 }
1311
1313 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) FL_NO_EXCEPT {
1316 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1317 typedef typename CHIP::ControllerType ControllerType;
1318 static ControllerType c;
1319 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1320 }
1321
1323 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1324 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1327 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1328 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
1329 static ControllerTypeWithOrder c;
1330 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1331 }
1332 #endif
1333
1334
1335#ifdef SPI_DATA
1336 template<ESPIChipsets CHIPSET, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1337 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB, B>(data, nLedsOrOffset, nLedsIfOffset);
1338 }
1339
1340 template<ESPIChipsets CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1341 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1342 }
1343
1344 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) {
1345 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE, B>(data, nLedsOrOffset, nLedsIfOffset);
1346 }
1347
1348#endif
1350
1351#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
1355 template<typename ControllerType>
1356 static inline ::CLEDController& addLedsImpl(ControllerType* controller, CRGB *data, int nLedsOrOffset, int nLedsIfOffset) FL_NO_EXCEPT {
1357 ::CLEDController* pLed = static_cast<::CLEDController*>(controller);
1358 return addLeds(pLed, data, nLedsOrOffset, nLedsIfOffset);
1359 }
1380
1382 template<template<fl::u8, fl::EOrder> class CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1383 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1386 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1387 }
1388
1390 template<template<fl::u8, fl::EOrder> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1391 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1393 static CHIPSET<DATA_PIN, RGB> c;
1394 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1395 }
1396
1398 template<template<fl::u8> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1399 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1401 static CHIPSET<DATA_PIN> c;
1402 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1403 }
1404
1405 template<template<fl::u8> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1406 static ::CLEDController &addLeds(fl::Leds& leds, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1407 CRGB* rgb = leds;
1408 return addLeds<CHIPSET, DATA_PIN, B>(rgb, nLedsOrOffset, nLedsIfOffset);
1409 }
1410
1411#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
1412 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>
1413 static ::CLEDController &addLeds(CRGB *data, int nLeds) {
1415 static fl::__FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
1416 return addLeds(&c, data, nLeds);
1417 }
1418#endif
1419
1420 #ifdef FASTSPI_USE_DMX_SIMPLE
1421 template<EClocklessChipsets CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER=RGB, fl::Bus B = fl::Bus::AUTO>
1422 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1423 {
1425 switch(CHIPSET) {
1426 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1427 }
1428 }
1429 #endif
1431#endif
1432
1453
1455 template<template<fl::EOrder RGB_ORDER> class CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1456 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1458 static CHIPSET<RGB_ORDER> c;
1459 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1460 }
1461
1463 template<template<fl::EOrder RGB_ORDER> class CHIPSET, fl::Bus B = fl::Bus::AUTO>
1464 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1466 static CHIPSET<RGB> c;
1467 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1468 }
1469
1470#ifdef USE_OCTOWS2811
1474 template<OWS2811 CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1475 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1476 {
1478 switch(CHIPSET) {
1479 case OCTOWS2811: { static fl::COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1480 case OCTOWS2811_400: { static fl::COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1481#ifdef WS2813_800kHz
1482 case OCTOWS2813: { static fl::COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1483#endif
1484 }
1485 }
1486
1490 template<OWS2811 CHIPSET, fl::Bus B = fl::Bus::AUTO>
1491 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1492 {
1493 return addLeds<CHIPSET,GRB,B>(data,nLedsOrOffset,nLedsIfOffset);
1494 }
1495
1496#endif
1497
1498#ifdef USE_WS2812SERIAL
1502 template<SWS2812 CHIPSET, int DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1503 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1504 {
1506 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
1507 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
1508 }
1509#endif
1510
1511#ifdef SmartMatrix_h
1514 template<ESM CHIPSET, fl::Bus B = fl::Bus::AUTO>
1515 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1516 {
1518 switch(CHIPSET) {
1519 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1520 }
1521 }
1522#endif
1524
1525
1526#ifdef FASTLED_HAS_BLOCKLESS
1527
1548
1550 template<EBlockChipsets CHIPSET, int NUM_LANES, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1551 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1553 switch(CHIPSET) {
1554 #ifdef PORTA_FIRST_PIN
1555 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
1556 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
1557 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
1558 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
1559 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
1560 #endif
1561 #ifdef PORTB_FIRST_PIN
1562 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
1563 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
1564 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
1565 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
1566 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
1567 #endif
1568 #ifdef PORTC_FIRST_PIN
1569 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
1570 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
1571 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
1572 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
1573 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
1574 #endif
1575 #ifdef PORTD_FIRST_PIN
1576 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
1577 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
1578 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
1579 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
1580 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
1581 #endif
1582 #ifdef HAS_PORTDC
1583 case WS2811_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1584 case WS2811_400_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1585 case WS2813_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1586 case TM1803_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1587 case UCS1903_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1588 #endif
1589 }
1590 }
1591
1593 template<EBlockChipsets CHIPSET, int NUM_LANES, fl::Bus B = fl::Bus::AUTO>
1594 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1595 return addLeds<CHIPSET,NUM_LANES,GRB,B>(data,nLedsOrOffset,nLedsIfOffset);
1596 }
1597
1598#endif
1599
1603
1607
1611
1618 void setDriverEnabled(const char* name, bool enabled) FL_NO_EXCEPT;
1619
1644 template<fl::Bus B, fl::u8 Which = 0>
1648
1660 bool setExclusiveDriver(fl::Bus bus, fl::u8 which = 0) FL_NO_EXCEPT;
1661
1665 bool isDriverEnabled(const char* name) const FL_NO_EXCEPT;
1666
1670
1674 fl::span<const fl::DriverInfo> getDriverInfos() const FL_NO_EXCEPT;
1675
1677
1684 void wait() FL_NO_EXCEPT;
1685
1689 bool wait(fl::u32 timeout_ms) FL_NO_EXCEPT;
1690
1694 inline void setMaxPowerInVoltsAndMilliamps(fl::u8 volts, fl::u32 milliamps) FL_NO_EXCEPT { setMaxPowerInMilliWatts(volts * milliamps); }
1695
1698 inline void setMaxPowerInMilliWatts(fl::u32 milliwatts) FL_NO_EXCEPT {
1699 mNPowerData = milliwatts;
1700#if FL_COLOR_PIPELINE_SHARED
1701 fl::activeFramePowerDispatch() = fl::framePowerDispatch();
1702 mPPowerFunc = fl::activeFramePowerDispatch()->showBrightness;
1703#else
1705#endif
1706 }
1707
1716 void setHdFieldFloor(fl::u8 min_field) FL_NO_EXCEPT;
1719
1725
1729 bool isPowerLimited() const FL_NO_EXCEPT;
1730
1734
1743 inline void setPowerModel(const PowerModelRGB& model) FL_NO_EXCEPT {
1744 set_power_model(model);
1745 }
1746
1756 inline void setPowerScalingExponent(float exponent) FL_NO_EXCEPT {
1758 }
1759
1765 }
1766
1767private:
1768 // Forward shims for the tiered-wait spin budget (#2818). Full impl
1769 // lives in src/fl/channels/detail/wait_spin_budget.{h,cpp.hpp}.
1770 // Declared here so we don't drag the channel-detail include graph
1771 // into FastLED.h.
1772 static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT;
1773 static fl::u32 _getWaitSpinBudgetUs() FL_NO_EXCEPT;
1774public:
1775
1789 inline void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT {
1790 _setWaitSpinBudgetUs(budget_us);
1791 }
1792
1794 inline fl::u32 getWaitSpinBudgetUs() const FL_NO_EXCEPT {
1795 return _getWaitSpinBudgetUs();
1796 }
1797
1802 inline void setPowerModel(const PowerModelRGBW& model) FL_NO_EXCEPT {
1803 set_power_model(model);
1804 }
1805
1810 inline void setPowerModel(const PowerModelRGBWW& model) FL_NO_EXCEPT {
1811 set_power_model(model);
1812 }
1813
1817 return get_power_model();
1818 }
1819
1858 fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter = true) const FL_NO_EXCEPT;
1859
1861
1870
1885 inline void setRgbwColorimetricProfile(const fl::DiodeProfile* profile) FL_NO_EXCEPT {
1887 }
1888
1893
1895
1903
1907
1908 // Called automatically at the end of show().
1909 void onEndFrame() FL_NO_EXCEPT;
1910
1914 void clear(bool writeData = false) FL_NO_EXCEPT;
1915
1937 static void clear(ClearFlags flags) FL_NO_EXCEPT;
1938
1940 void clearData() FL_NO_EXCEPT;
1941
1945 void showColor(const CRGB & color, fl::u8 scale) FL_NO_EXCEPT;
1946
1949 void showColor(const CRGB & color) FL_NO_EXCEPT { showColor(color, mScale); }
1950
1955 void delay(unsigned long ms) FL_NO_EXCEPT;
1956
1960 void setTemperature(const CRGB & temp) FL_NO_EXCEPT;
1961
1965 void setCorrection(const CRGB & correction) FL_NO_EXCEPT;
1966
1970 void setDither(fl::u8 ditherMode = BINARY_DITHER) FL_NO_EXCEPT;
1971
1986
1994 void setMaxRefreshRate(fl::u16 refresh, bool constrain=false) FL_NO_EXCEPT;
1995
2000 void countFPS(int nFrames=25) FL_NO_EXCEPT;
2001
2004 fl::u16 getFPS() FL_NO_EXCEPT { return mNFPS; }
2005
2008 int count() FL_NO_EXCEPT;
2009
2012 CLEDController & operator[](int x) FL_NO_EXCEPT;
2013
2016 int size() FL_NO_EXCEPT;
2017
2021};
2022
2024#define FastSPI_LED FastLED
2026#define FastSPI_LED2 FastLED
2027#ifndef LEDS
2029#define LEDS FastLED
2030#endif
2031
2033extern CFastLED FastLED;
2034
2038#ifndef HAS_HARDWARE_PIN_SUPPORT
2039#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
2040#define NO_HARDWARE_PIN_SUPPORT
2041#endif
2042
2043
2044#endif
2045
2046
2048
2049#if !defined(FASTLED_INTERNAL) && !defined(FASTLED_LEAN_AND_MEAN)
2050
2051#include "fl/stl/string.h" // Awesome Str class that has stack allocation and heap overflow, copy on write.
2052#include "fl/math/xymap.h" // XYMap class for mapping 2D coordinates on seperintine matrices.
2053
2054#include "fl/math/math.h" // fl::clamp, fl::map_range, fl::min, fl::max, etc.
2055
2056#include "fl/log/log.h" // FL_WARN("time now: " << millis()), FL_WARN_IF(...), FL_PRINT(...), FL_LOG_*() category-specific logging
2057#include "fl/system/serial.h" // Arduino-compatible Serial API: fl::Serial.print(), fl::Serial.read(), etc.
2058#include "fl/stl/assert.h" // FASTLED_ASSERT(condition, "message");
2059#include "fl/stl/sstream.h" // fl::sstream for string stream operations
2060
2061// The remote RPC system (fl/remote/remote.h) is opt-in: it pulls the JSON
2062// parser, the RPC server and the scheduler (57 headers) into every sketch
2063// that includes FastLED.h. Sketches that use it include it directly, or
2064// define FL_INCLUDE_REMOTE before including FastLED.h.
2065#if defined(FL_INCLUDE_REMOTE)
2066#include "fl/remote/remote.h" // Remote RPC system for JSON-based function calls
2067#endif
2068
2069// provides:
2070// fl::vector<T> - Standard heap vector
2071// fl::vector_inlined<T,N> - Allocate on stack N elements, then overflow to heap vector.
2072// fl::vector_fixed<T,N> - Stack allocated fixed size vector, elements will fail to add when full.
2073#include "fl/stl/vector.h"
2074
2075// Flexible callbacks in the style of std::function.
2076#include "fl/stl/function.h"
2077
2078// Clears the led data and other objects.
2079// CRGB leds[NUM_LEDS];
2080// fl::clear(leds)
2081#include "fl/gfx/clear.h"
2082
2083// Leds has a CRGB block and an XYMap
2084#include "fl/gfx/leds.h"
2085
2086#include "fl/channels/spi.h" // SPI device and multi-lane SPI support (1-16 lanes)
2087
2088#include "fl/ui/ui.h" // Provides UIButton, UISlider, UICheckbox, UINumberField and UITitle, UIDescription, UIHelp, UIGroup.
2089#include "fl/stl/noexcept.h"
2090using fl::UITitle;
2091using fl::UIDescription;
2092using fl::UIHelp;
2093using fl::UIButton; // These names are unique enough that we don't need to namespace them
2094using fl::UICheckbox;
2095using fl::UINumberField;
2096using fl::UISlider;
2097using fl::UIDropdown;
2098using fl::UIGroup;
2099using fl::XYMap;
2100using fl::round; // Template version avoids conflicts with ::round
2101// Only expose fl::delay as global delay() on non-hardware platforms (stub/WASM).
2102// On real Arduino platforms, Arduino's native delay(uint32_t) is already in scope;
2103// importing fl::delay there causes an ambiguous-overload error for any third-party
2104// library (e.g. IRremote) that calls the unqualified delay().
2105// Users who need fl::delay's async-task-pumping behaviour can call fl::delay() or
2106// fl::delayMs() explicitly.
2107#if defined(FASTLED_STUB_IMPL)
2108using fl::delay;
2109#endif
2110
2111// Common fl:: type aliases for global namespace convenience
2112template<typename T> using fl_vector = fl::vector<T>;
2113template<typename Key, typename Value, typename Compare = fl::less<Key>> using fl_map = fl::flat_map<Key, Value, Compare>;
2114using fl_string = fl::string;
2115
2116// Note: delayMicroseconds and delayMillis are provided by Arduino core
2117// The fl:: namespace versions are available for explicit use when needed
2118
2119#define FASTLED_TITLE(text) fl::UITitle g_title(text)
2120#define FASTLED_DESCRIPTION(text) fl::UIDescription g_description(text)
2121#define FASTLED_HELP(text) fl::UIHelp g_help(text)
2122
2123
2124#endif // FASTLED_INTERNAL && !FASTLED_LEAN_AND_MEAN
2125
2126
2127
2128// Experimental: loop() hijacking.
2129//
2130// EngineEvents requires that FastLED.show() be invoked.
2131// If the user skips that then certain updates will be skipped.
2132//
2133// Right now this isn't a big deal, but in the future it could be.
2134//
2135// Therefore this experiment is done so that this loop() hijack trick
2136// can be used to insert code at the start of every loop(), such as a
2137// scoped object that forces a begin and end frame event.
2138//
2139// It's possible to hijack the loop() via a macro so that
2140// extra code can be injected at the start of every frame.
2141// When FASTLED_LOOP_RUNS_ASYNC == 1
2142// then use loop() to also run the async.
2143//
2144// EXAMPLE:
2145// #define FASTLED_LOOP_RUNS_ASYNC 1
2146// #include "FastLED.h"
2147// void loop() {
2148// FL_WARN("async will run in the loop");
2149// delay(500);
2150// }
2151
2152#ifndef FASTLED_LOOP_RUNS_ASYNC
2153#define FASTLED_LOOP_RUNS_ASYNC 0
2154#endif
2155
2156#if FASTLED_LOOP_RUNS_ASYNC == 1
2157// The loop is set as a macro that re-defines the user loop function
2158// to sketch_loop()
2159#define loop() \
2160 sketch_loop(); \
2161 void loop() { sketch_loop(); fl::task::run(); } \
2162 void sketch_loop()
2163#endif
2164
2165// Backdoor to get the size of the CLedController object. The one place
2166// that includes this just uses extern to declare the function.
2167// Declaration moved to src/fl/system/fastled.h
CRGB leds[1]
fl::UIAudio audio("Audio Input")
#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.
ClearFlags operator&(ClearFlags a, ClearFlags b) FL_NO_EXCEPT
Enable bitwise AND for ClearFlags.
Definition FastLED.h:677
#define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS)
Definition FastLED.h:1083
ClearFlags
Flags for FastLED.clear() to control what state gets cleared/reset.
Definition FastLED.h:661
@ CHANNELS
Remove all channels from controller list.
Definition FastLED.h:663
@ CHANNEL_ENGINES
Clear all channel drivers from ChannelManager.
Definition FastLED.h:668
@ POWER_SETTINGS
Reset power management (setMaxPowerInMilliWatts)
Definition FastLED.h:664
@ FPS_COUNTER
Reset FPS tracking counter to 0.
Definition FastLED.h:667
@ NONE
Clear nothing (no-op)
Definition FastLED.h:662
@ REFRESH_RATE
Reset refresh rate limiting to unlimited.
Definition FastLED.h:666
ClearFlags & operator|=(ClearFlags &a, ClearFlags b) FL_NO_EXCEPT
Enable bitwise OR assignment for ClearFlags.
Definition FastLED.h:682
ClearFlags operator|(ClearFlags a, ClearFlags b) FL_NO_EXCEPT
Enable bitwise OR for ClearFlags.
Definition FastLED.h:672
SWS2812
WS2812Serial Library controller type.
Definition FastLED.h:323
@ WS2812SERIAL
Definition FastLED.h:323
OWS2811
Octo WS2811 LED Library controller types.
Definition FastLED.h:318
@ OCTOWS2811
Definition FastLED.h:318
@ OCTOWS2813
Definition FastLED.h:318
@ OCTOWS2811_400
Definition FastLED.h:318
ESPIChipsets
Backwards compatibility enum - allows old code to use unscoped names (e.g., APA102 instead of fl::Spi...
Definition FastLED.h:291
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:304
@ P9813
P9813 LED chipset.
Definition FastLED.h:298
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
Definition FastLED.h:301
@ SK9822
SK9822 LED chipset.
Definition FastLED.h:300
@ MY9221
MY9221 12-channel LED driver (dual-edge clocked; 4 RGB LEDs per chip)
Definition FastLED.h:297
@ WS2803
WS2803 LED chipset.
Definition FastLED.h:295
@ HD107
Same as APA102, but in turbo 40-mhz mode.
Definition FastLED.h:305
@ HD107S
Marketed HD107S part name; alias of HD107.
Definition FastLED.h:306
@ WS2801
WS2801 LED chipset.
Definition FastLED.h:294
@ DOTSTAR
APA102 LED chipset alias.
Definition FastLED.h:302
@ APA102
APA102 LED chipset.
Definition FastLED.h:299
@ LPD8806
LPD8806 LED chipset.
Definition FastLED.h:293
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
Definition FastLED.h:307
@ LPD6803
LPD6803 LED chipset.
Definition FastLED.h:292
@ DOTSTARHD
APA102HD LED chipset alias.
Definition FastLED.h:303
@ SM16716
SM16716 LED chipset.
Definition FastLED.h:296
@ HD108
16-bit variant of HD107, always gamma corrected. No SD (standard definition) option available - all H...
Definition FastLED.h:308
ESM
Smart Matrix Library controller type.
Definition FastLED.h:313
@ SMART_MATRIX
Definition FastLED.h:313
EBlockChipsets
Blockless output port enum.
Definition FastLED.h:596
fl::u8(* power_func)(fl::u8 scale, fl::u32 data)
Typedef for a power consumption calculation function.
Definition FastLED.h:641
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
void clear(bool writeData=false) FL_NO_EXCEPT
Clear the leds, wiping the local array of data.
power_func mPPowerFunc
function for overriding brightness when using FastLED.show();
Definition FastLED.h:726
_FL_MAP_CLOCKED_CHIPSET(LPD6803, LPD6803Controller) _FL_MAP_CLOCKED_CHIPSET(LPD8806
fl::u8 getBrightness() FL_NO_EXCEPT
Get the current global brightness setting.
Definition FastLED.h:1606
fl::u8 getHdFieldFloor() const FL_NO_EXCEPT
void setExclusiveDriver() FL_NO_EXCEPT
Register a single driver at a priority above the platform default (compile-time TU-linking variant).
Definition FastLED.h:1645
void setCorrection(const CRGB &correction) FL_NO_EXCEPT
Set a global color correction.
float getPowerScalingExponent() const FL_NO_EXCEPT
Get the configured brightness-to-power response exponent.
Definition FastLED.h:1763
void setPowerModel(const PowerModelRGBW &model) FL_NO_EXCEPT
Definition FastLED.h:1802
static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
static void add(fl::ChannelPtr channel) FL_NO_EXCEPT
Add a Channel-based LED controller (from ChannelPtr)
void show() FL_NO_EXCEPT
Update all our controllers with the current led colors.
Definition FastLED.h:1906
void setDriverEnabled(const char *name, bool enabled) FL_NO_EXCEPT
Enable or disable a channel driver by name at runtime.
CFastLED() FL_NO_EXCEPT
static void registerExplicitSpiHost(const fl::SpiChipsetConfig &spiCfg, fl::true_type) FL_NO_EXCEPT
Definition FastLED.h:1199
static void registerExplicitSpiHost(const fl::SpiChipsetConfig &spiCfg, fl::false_type) FL_NO_EXCEPT
Definition FastLED.h:1209
static fl::ChannelEvents & channelEvents() FL_NO_EXCEPT
Access the channel event system.
void countFPS(int nFrames=25) FL_NO_EXCEPT
For debugging, this will keep track of time between calls to countFPS().
bool colorManagementStrict() const FL_NO_EXCEPT
Definition FastLED.h:1977
void onEndShowLeds() FL_NO_EXCEPT
Manually trigger the end show LEDs event.
fl::u32 getWaitSpinBudgetUs() const FL_NO_EXCEPT
Get the current tiered-wait spin budget (microseconds).
Definition FastLED.h:1794
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add a 3rd party library based CLEDController instance to the world.
Definition FastLED.h:1464
void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
Override the channel-manager tiered-wait spin budget (microseconds).
Definition FastLED.h:1789
static fl::u32 _getWaitSpinBudgetUs() FL_NO_EXCEPT
static fl::Watchdog & watchdog() FL_NO_EXCEPT
Access the unified cross-platform watchdog timer.
static void remove(fl::ChannelPtr channel) FL_NO_EXCEPT
Remove a channel from the LED controller list.
int size() FL_NO_EXCEPT
Get the number of leds in the first controller.
void setMaxPowerInMilliWatts(fl::u32 milliwatts) FL_NO_EXCEPT
Set the maximum power to be used, given in milliwatts.
Definition FastLED.h:1698
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController instance to the world (legacy path).
Definition FastLED.h:1324
void setBrightness(fl::u8 scale) FL_NO_EXCEPT
Set the global brightness scaling.
Definition FastLED.h:1602
void setMaxPowerInVoltsAndMilliamps(fl::u8 volts, fl::u32 milliamps) FL_NO_EXCEPT
Set the maximum power to be used, given in volts and milliamps.
Definition FastLED.h:1694
::CLEDController & addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::false_type) FL_NO_EXCEPT
Definition FastLED.h:1183
void clearData() FL_NO_EXCEPT
Clear out the local data array.
void setDither(fl::u8 ditherMode=BINARY_DITHER) FL_NO_EXCEPT
Set the dithering mode.
::CLEDController & addLeds(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) FL_NO_EXCEPT
Add an SPI controller on a selected ESP-IDF host.
Definition FastLED.h:1302
const fl::DiodeProfile * getRgbwColorimetricProfile() const FL_NO_EXCEPT
Currently active RGBW colorimetric profile (defaults to &fl::kRgbwDefaultProfile).
Definition FastLED.h:1890
fl::u16 getFPS() FL_NO_EXCEPT
Get the number of frames/second being written out.
Definition FastLED.h:2004
fl::u8 getLastShowBrightness() const FL_NO_EXCEPT
Brightness the most recent show() / showColor() actually applied, after the power limiter set by setM...
static fl::vector< fl::ChannelPtr > & channels() FL_NO_EXCEPT
stored ChannelPtrs to keep them alive
LPD8806Controller WS2803Controller MY9221Controller APA102Controller APA102ControllerHD APA102Controller HD108Controller SK9822ControllerHD ::CLEDController & addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::true_type) FL_NO_EXCEPT
Definition FastLED.h:1175
void onBeginFrame() FL_NO_EXCEPT
Manually trigger the begin frame event.
void showColor(const CRGB &color, fl::u8 scale) FL_NO_EXCEPT
Set all leds on all controllers to the given color/scale.
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:1974
void wait() FL_NO_EXCEPT
Wait for all channel bus transmissions to complete.
fl::u8 mScale
the current global brightness scale setting
Definition FastLED.h:722
void onEndFrame() FL_NO_EXCEPT
bool isPowerLimited() const FL_NO_EXCEPT
True if the power limiter lowered the brightness of the most recent show() / showColor() below what i...
CRGB * leds() FL_NO_EXCEPT
Get a pointer to led data for the first controller.
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController via Channel API (default RGB order and speed).
Definition FastLED.h:1236
void showColor(const CRGB &color) FL_NO_EXCEPT
Set all leds on all controllers to the given color.
Definition FastLED.h:1949
static ::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController instance to the world (legacy path).
Definition FastLED.h:1313
void setPowerModel(const PowerModelRGB &model) FL_NO_EXCEPT
Definition FastLED.h:1743
void delay(unsigned long ms) FL_NO_EXCEPT
Delay for the given number of milliseconds.
static fl::RxChannelPtr addRx(const fl::RxChannelConfig &config) FL_NO_EXCEPT
Add an RX channel with runtime configuration.
void setRgbwColorimetricProfile(const fl::DiodeProfile *profile) FL_NO_EXCEPT
Install a legacy fallback RGBW diode chromaticity profile for scalar colorimetric calls.
Definition FastLED.h:1885
void setDefaultSourceProfile(const fl::SourceProfile &profile) FL_NO_EXCEPT
Definition FastLED.h:1980
fl::u32 mNPowerData
max power use parameter
Definition FastLED.h:725
fl::u16 mNFPS
tracking for current frames per second (FPS) value
Definition FastLED.h:723
void setMaxRefreshRate(fl::u16 refresh, bool constrain=false) FL_NO_EXCEPT
Set the maximum refresh rate.
void init() FL_NO_EXCEPT
Initialize platform-specific subsystems.
fl::u8 mLastShownScale
brightness the last show()/showColor() applied, after the power limiter
Definition FastLED.h:728
::CLEDController & addLedsSpiChannel(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) FL_NO_EXCEPT
Add an SPI controller with an explicit ESP-IDF SPI host.
Definition FastLED.h:1225
void addListener(fl::EngineEvents::Listener *listener) FL_NO_EXCEPT
Definition FastLED.h:749
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a OCTOWS2811 based CLEDController instance to the world.
Definition FastLED.h:1475
void setTemperature(const CRGB &temp) FL_NO_EXCEPT
Set a global color temperature.
int count() FL_NO_EXCEPT
Get how many controllers have been registered.
fl::u8 mLastRequestedScale
brightness the last show()/showColor() was asked for
Definition FastLED.h:727
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController via Channel API (default speed).
Definition FastLED.h:1250
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController via Channel API.
Definition FastLED.h:1215
const fl::SourceProfile & defaultSourceProfile() const FL_NO_EXCEPT
Definition FastLED.h:1983
::CLEDController & addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add a CLEDController instance to the world.
void setPowerModel(const PowerModelRGBWW &model) FL_NO_EXCEPT
Definition FastLED.h:1810
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController instance to the world (legacy path).
Definition FastLED.h:1289
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a WS2812Serial library based CLEDController instance to the world.
Definition FastLED.h:1503
fl::span< const fl::DriverInfo > getDriverInfos() const FL_NO_EXCEPT
Get full state of all registered channel drivers.
void setPowerScalingExponent(float exponent) FL_NO_EXCEPT
Set a non-linear brightness-to-power response exponent.
Definition FastLED.h:1756
bool isDriverEnabled(const char *name) const FL_NO_EXCEPT
Check if a driver is enabled by name.
fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter=true) const FL_NO_EXCEPT
Get estimated power consumption in milliwatts.
void setHdFieldFloor(fl::u8 min_field) FL_NO_EXCEPT
Lowest 5-bit current field the colour-managed APA102-HD path may use (B1's flicker floor,...
fl::size getDriverCount() const FL_NO_EXCEPT
Get count of registered channel drivers.
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add a 3rd party library based CLEDController instance to the world.
Definition FastLED.h:1456
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a OCTOWS2811 library based CLEDController instance to the world.
Definition FastLED.h:1491
PowerModelRGB getPowerModel() const FL_NO_EXCEPT
Get current RGB power model.
Definition FastLED.h:1816
void removeListener(fl::EngineEvents::Listener *listener) FL_NO_EXCEPT
Definition FastLED.h:750
static void enableAllDrivers() FL_NO_EXCEPT
Enroll every channel driver available on this platform with ChannelManager.
fl::u16 mMaxRefreshHz
frame-rate cap in Hz, 0 = unlimited (u16 saves 2 B over micros, #4788)
Definition FastLED.h:724
and refresh rates, and provides access functions for driving led data to controllers via the show() /...
Definition FastLED.h:718
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:362
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,...
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.
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) FL_NO_EXCEPT
Determines the highest brightness level you can use and still stay under the specified power budget f...
void set_power_scaling_exponent(float exponent) FL_NO_EXCEPT
Set a non-linear brightness-to-power response exponent.
PowerModelRGB get_power_model() FL_NO_EXCEPT
Get current RGB power model.
void set_power_model(const PowerModelRGB &model) FL_NO_EXCEPT
Set custom RGB LED power consumption model.
float get_power_scaling_exponent() FL_NO_EXCEPT
Get the current brightness-to-power response exponent.
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
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() FL_NO_EXCEPT
Get the global ChannelManager singleton instance.
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:29
enable_if<!is_integral< T >::value, T >::type round(T value) FL_NO_EXCEPT
Definition math.h:327
void busKeepAlive() FL_NO_EXCEPT
Definition bus_traits.h:154
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:210
void set_rgbw_colorimetric_profile(const DiodeProfile *profile) FL_NO_EXCEPT
Definition rgbw.cpp.hpp:203
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
Definition eorder.h:15
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:535
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:28
constexpr T radians(T deg) FL_NO_EXCEPT
Definition math.h:530
Base definition for an LED controller.
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_STATIC_ASSERT(...)
#define FL_NO_EXCEPT
Shared "slim bridge" legacy addLeds<ESPIChipsets ...>() controller for the SPI channel API – driver-a...
SPI LED chipset enumeration.
Portable compile-time assertion wrapper.
static const bool IS_VALID
Definition FastLED.h:1078
RGB LED power consumption model Used for standard 3-channel LEDs (WS2812, WS2812B,...
Definition power_mgt.h:30
RGBW LED power consumption model Used for 4-channel LEDs (SK6812 RGBW and similar).
Definition power_mgt.h:58
RGBWW LED power consumption model (RGB + warm white + cool white).
Definition power_mgt.h:99
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.