FastLED 3.10.10
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 3010010
34#ifndef FASTLED_INTERNAL
35# ifdef FASTLED_SHOW_VERSION
36# ifdef FASTLED_HAS_PRAGMA_MESSAGE
37# pragma message "FastLED version 3.010.010"
38# else
39# warning FastLED version 3.010.010 (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/driver_bindings.h" // for fl::bindDriver (FastLED.enable<>)
193#include "fl/channels/bus_traits.h" // for fl::BusTraits, fl::BusSupports (Phase 3b, #2428)
195#include "fl/channels/channel_typed.h" // for fl::TypedChannel<B, Chipset> (Phase 3b, #2428)
196#include "fl/channels/slim_spi_bridge_controller.h" // for fl::SlimSpiBridgeController (#4585)
198#include "fl/stl/type_traits.h" // for fl::true_type/false_type (SPI addLeds<> dispatch, #4585)
199
200#include "fl/audio/input.h"
202
203// CFastLED::add(UIAudio&) only needs the name, which audio_manager.h forward
204// declares; the full UI headers (and the JSON UI they pull in on host/wasm)
205// are provided to sketches by the convenience block at the bottom of this
206// file, not to every library TU.
208
209// ============================================================================
210// C STRING FUNCTION USING DECLARATIONS
211// ============================================================================
212
218
219// Utility functions
220#include "fastled_delay.h"
221#include "bitswap.h"
222
223#include "lib8tion.h"
224
225// ============================================================================
226// MATH FUNCTION USING DECLARATIONS
227// ============================================================================
228
229// fl/math/math.h normalizes macros introduced by application/platform headers.
230// fl/stl/undef.h is intentionally re-includable for later normalization.
231
232#include "controller.h"
233#include "fastpin.h"
234#include "fastspi_types.h"
235#include "dmx.h"
236
237#include "platforms.h"
238
239// Default example pins; must follow platforms.h so board pin tables win.
240#include "platforms/default_pins.h"
241
242// Library Dependency Finder (LDF) hint headers
243// These headers use #if 0 blocks to hint library dependencies to the LDF scanner
244// without actually compiling the code. This works around LDF's limitation of scanning
245// headers without evaluating preprocessor paths.
246#include "platforms/ldf_headers.h"
247
248// Pass 2 macro cleanup: fl/math/math.h includes fl/stl/undef.h which undefs any
249// min/max/abs/round/radians/degrees/map macros re-introduced by platform headers above.
250// Then provides type-safe fl:: replacements brought into global scope via using below.
251#include "fl/math/math.h"
252
253// Bring fl:: math functions into global namespace for Arduino compatibility
254// Teensy platforms define their own template min/max in wiring.h (global namespace),
255// so we skip bringing fl::min/fl::max into global scope to avoid ambiguity.
256#if !defined(FL_IS_TEENSY)
257using fl::min;
258using fl::max;
259#endif
260using fl::abs;
261using fl::radians;
262using fl::degrees;
263
264// Note: Arduino map() function is defined in global namespace (platforms/stub/Arduino.h)
265// fl::map refers to the map container (red-black tree) and our map() function delegate.
266#include "fastled_progmem.h"
267#include "pixeltypes.h"
268#include "hsv2rgb.h"
269#include "colorutils.h"
270#include "pixelset.h"
271#include "colorpalettes.h"
272
273#include "noise.h"
274#include "power_mgt.h"
276
277#include "fastspi.h"
278#include "chipsets.h"
279#include "fl/chipsets/analog.h"
281
282#include "fl/gfx/leds.h"
283#include "fl/gfx/rgbw.h" // RGBW mode config (wrapped on CFastLED below)
284#include "fl/color/rgbw.h" // colorimetric profile facade
285
286// clockless.h removed - BulkClockless API has been superseded by Channel API
287
288// SPI chipset enumeration (modern type-safe enum class)
290
294 LPD6803 = static_cast<int>(fl::SpiChipset::LPD6803),
295 LPD8806 = static_cast<int>(fl::SpiChipset::LPD8806),
296 WS2801 = static_cast<int>(fl::SpiChipset::WS2801),
297 WS2803 = static_cast<int>(fl::SpiChipset::WS2803),
298 SM16716 = static_cast<int>(fl::SpiChipset::SM16716),
299 MY9221 = static_cast<int>(fl::SpiChipset::MY9221),
300 P9813 = static_cast<int>(fl::SpiChipset::P9813),
301 APA102 = static_cast<int>(fl::SpiChipset::APA102),
302 SK9822 = static_cast<int>(fl::SpiChipset::SK9822),
303 SK9822HD = static_cast<int>(fl::SpiChipset::SK9822HD),
304 DOTSTAR = static_cast<int>(fl::SpiChipset::DOTSTAR),
306 APA102HD = static_cast<int>(fl::SpiChipset::APA102HD),
307 HD107 = static_cast<int>(fl::SpiChipset::HD107),
308 HD107S = static_cast<int>(fl::SpiChipset::HD107S),
309 HD107HD = static_cast<int>(fl::SpiChipset::HD107HD),
310 HD108 = static_cast<int>(fl::SpiChipset::HD108),
311};
312
316
321
326
327#ifdef HAS_PIXIE
328template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
329#endif
330
331#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
336
339template<fl::u8 DATA_PIN> class NEOPIXEL : public WS2812Controller800Khz<DATA_PIN, GRB> {};
340
343template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
344class SM16703 : public SM16703Controller<DATA_PIN, RGB_ORDER> {};
345
348template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
349class SM16824E : public SM16824EController<DATA_PIN, RGB_ORDER> {};
350
353template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
354class TM1829 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
355
361template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
362class TX1813N1 : public TM1829Controller800Khz<DATA_PIN, RGB_ORDER> {};
363
369template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
370class TM1812 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
371
374template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
375class TM1809 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
376
381template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
382class TM1908 : public TM1908Controller<DATA_PIN, RGB_ORDER> {};
383
386template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
387class TM1804 : public TM1809Controller800Khz<DATA_PIN, RGB_ORDER> {};
388
391template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
392class TM1803 : public TM1803Controller400Khz<DATA_PIN, RGB_ORDER> {};
393
396template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
397class UCS1903 : public UCS1903Controller400Khz<DATA_PIN, RGB_ORDER> {};
398
401template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
402class UCS1903B : public UCS1903BController800Khz<DATA_PIN, RGB_ORDER> {};
403
406template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
407class UCS1904 : public UCS1904Controller800Khz<DATA_PIN, RGB_ORDER> {};
408
411template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
412class UCS2903 : public UCS2903Controller<DATA_PIN, RGB_ORDER> {};
413
416template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
417class UCS7604 : public UCS7604Controller8bit<DATA_PIN, RGB_ORDER> {};
418
421template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
422class UCS7604HD : public UCS7604Controller16bit<DATA_PIN, RGB_ORDER> {};
423
427template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
428class UCS7604HD_1600 : public UCS7604Controller16bit1600<DATA_PIN, RGB_ORDER> {};
429
432template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
433class WS2812 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
434
436template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
437class WS2815 : public WS2815Controller<DATA_PIN, RGB_ORDER> {};
438
440template <fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
441class WS2816 : public WS2816Controller<DATA_PIN, RGB_ORDER> {};
442
445template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
446class WS2852 : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
447
450template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
451class WS2812B : public WS2812Controller800Khz<DATA_PIN, RGB_ORDER> {};
452
458template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
459class OSTW2020C1E : public OSTW2020C1EController<DATA_PIN, RGB_ORDER> {};
460
463template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
464class WS2812BMiniV3 : public WS2812BMiniV3Controller<DATA_PIN, RGB_ORDER> {};
465
468template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
469class WS2812BV5 : public WS2812BV5Controller<DATA_PIN, RGB_ORDER> {};
470
477template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
478class GS1903 : public GS1903Controller<DATA_PIN, RGB_ORDER> {};
479
482template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
483class SK6812 : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
484
489template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
490class LC8816E : public LC8816EController<DATA_PIN, RGB_ORDER> {};
491
501template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
502class SK6812WWA : public SK6812Controller<DATA_PIN, RGB_ORDER> {};
503
506template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
507class SK6822 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
508
511template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
512class APA106 : public SK6822Controller<DATA_PIN, RGB_ORDER> {};
513
516template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
517class PL9823 : public PL9823Controller<DATA_PIN, RGB_ORDER> {};
518
521template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
522class WS2811 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
523
526template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
527class WS2813 : public WS2813Controller<DATA_PIN, RGB_ORDER> {};
528
534template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
535class WS2814 : public WS2814Controller<DATA_PIN, RGB_ORDER> {};
536
542template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
543class WS2818 : public WS2818Controller<DATA_PIN, RGB_ORDER> {};
544
547template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
548class APA104 : public WS2811Controller800Khz<DATA_PIN, RGB_ORDER> {};
549
552template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
553class WS2811_400 : public WS2811Controller400Khz<DATA_PIN, RGB_ORDER> {};
554
557template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
558class GE8822 : public GE8822Controller800Khz<DATA_PIN, RGB_ORDER> {};
559
562template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
563class GW6205 : public GW6205Controller800Khz<DATA_PIN, RGB_ORDER> {};
564
567template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
568class GW6205_400 : public GW6205Controller400Khz<DATA_PIN, RGB_ORDER> {};
569
572template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
573class LPD1886 : public LPD1886Controller1250Khz<DATA_PIN, RGB_ORDER> {};
574
577template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
578class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit<DATA_PIN, RGB_ORDER> {};
579
581template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER>
582class UCS1912 : public UCS1912Controller<DATA_PIN, RGB_ORDER> {};
583
584#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
586template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class DMXSIMPLE : public DMXSimpleController<DATA_PIN, RGB_ORDER> {};
587#endif
588#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
590template<fl::EOrder RGB_ORDER> class DMXSERIAL : public DMXSerialController<RGB_ORDER> {};
591#endif
592#endif
595
596
599#ifdef PORTA_FIRST_PIN
600 WS2811_PORTA,
601 WS2813_PORTA,
602 WS2811_400_PORTA,
603 TM1803_PORTA,
604 UCS1903_PORTA,
605#endif
606#ifdef PORTB_FIRST_PIN
607 WS2811_PORTB,
608 WS2813_PORTB,
609 WS2811_400_PORTB,
610 TM1803_PORTB,
611 UCS1903_PORTB,
612#endif
613#ifdef PORTC_FIRST_PIN
614 WS2811_PORTC,
615 WS2813_PORTC,
616 WS2811_400_PORTC,
617 TM1803_PORTC,
618 UCS1903_PORTC,
619#endif
620#ifdef PORTD_FIRST_PIN
621 WS2811_PORTD,
622 WS2813_PORTD,
623 WS2811_400_PORTD,
624 TM1803_PORTD,
625 UCS1903_PORTD,
626#endif
627#ifdef HAS_PORTDC
628 WS2811_PORTDC,
629 WS2813_PORTDC,
630 WS2811_400_PORTDC,
631 TM1803_PORTDC,
632 UCS1903_PORTDC,
633#endif
634};
635
636
643typedef fl::u8 (*power_func)(fl::u8 scale, fl::u32 data);
644
663enum class ClearFlags : fl::u32 {
664 NONE = 0,
665 CHANNELS = 1 << 0,
666 POWER_SETTINGS = 1 << 1,
667 BRIGHTNESS = 1 << 2,
668 REFRESH_RATE = 1 << 3,
669 FPS_COUNTER = 1 << 4,
671};
672
675 return static_cast<ClearFlags>(static_cast<fl::u32>(a) | static_cast<fl::u32>(b));
676}
677
680 return static_cast<ClearFlags>(static_cast<fl::u32>(a) & static_cast<fl::u32>(b));
681}
682
685 a = a | b;
686 return a;
687}
688
714#define FL_DITHER_ENABLE_MIN_REFRESH_HZ 100
715
720class CFastLED {
723 // int m_nControllers;
725 fl::u16 mNFPS;
727 fl::u32 mNPowerData;
732
733public:
735
747 void init() FL_NO_EXCEPT;
748
749 // Useful when you want to know when an event like onFrameBegin or onFrameEnd is happening.
750 // This is disabled on AVR to save space.
751 void addListener(fl::EngineEvents::Listener *listener) FL_NO_EXCEPT { fl::EngineEvents::addListener(listener); }
753
761
776 static fl::Watchdog& watchdog() FL_NO_EXCEPT;
777
782
786
790
792
804 static ::CLEDController &addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT;
805
808
823 static void add(fl::ChannelPtr channel) FL_NO_EXCEPT;
824
844 static fl::ChannelPtr add(const fl::ChannelConfig& config) FL_NO_EXCEPT;
845
852 template<fl::Bus B, typename Chipset = fl::ClocklessChipset, fl::u8 Which = 0>
853 static fl::ChannelPtr add(const fl::ChannelConfig& config) FL_NO_EXCEPT {
854 fl::ChannelPtr channel = fl::TypedChannel<B, Chipset, Which>::create(config);
855 if (channel != nullptr) add(channel);
856 return channel;
857 }
858
861 template<fl::Bus B, typename Chipset, fl::u8 Which = 0>
862 static fl::ChannelPtr add(const fl::ChannelConfigOf<Chipset>& config) FL_NO_EXCEPT {
863 fl::ChannelPtr channel = fl::TypedChannel<B, Chipset, Which>::create(config);
864 if (channel != nullptr) add(channel);
865 return channel;
866 }
867
868 template<fl::ProfileId Profile>
869 static fl::ChannelPtr add(const fl::ChannelConfig& config) FL_NO_EXCEPT {
870 fl::ChannelPtr channel = fl::Channel::create<Profile>(config);
871 if (channel != nullptr) add(channel);
872 return channel;
873 }
874
895
913 static fl::vector<fl::ChannelPtr> add(fl::initializer_list<fl::ChannelConfig> configs) FL_NO_EXCEPT;
914
935
944 static fl::RxChannelPtr addRx(const fl::RxChannelConfig& config) FL_NO_EXCEPT;
945
967
984
999
1024 static void enableAllDrivers() FL_NO_EXCEPT;
1025
1041 template<fl::Bus B, typename Chipset = fl::ClocklessChipset, fl::u8 Which = 0>
1044 return *this;
1045 }
1046
1063 static void remove(fl::ChannelPtr channel) FL_NO_EXCEPT;
1064
1074
1076
1089 template<template<fl::u8, fl::u8, fl::u8> class CHIPSET,
1090 fl::u8 RED_PIN, fl::u8 GREEN_PIN, fl::u8 BLUE_PIN>
1091 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset,
1092 int nLedsIfOffset = 0) FL_NO_EXCEPT {
1094 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
1095 }
1096
1097
1117
1118
1119 // Base template: Causes a compile-time error if an unsupported CHIPSET is used
1120 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN>
1122 // Default implementation, will be specialized for supported chipsets
1123 static const bool IS_VALID = false;
1124 };
1125
1126 // Macro to define a mapping from the ESPIChipeset enum to the controller class
1127 // in it's various template configurations.
1128 #define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS) \
1129 template<fl::u8 DATA_PIN, fl::u8 CLOCK_PIN> \
1130 struct ClockedChipsetHelper<CHIPSET_ENUM, DATA_PIN, CLOCK_PIN> { \
1131 static const bool IS_VALID = true; \
1132 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN> ControllerType; \
1133 /* Controller type with RGB_ORDER specified */ \
1134 template<fl::EOrder RGB_ORDER> \
1135 struct CONTROLLER_CLASS_WITH_ORDER { \
1136 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER> ControllerType; \
1137 }; \
1138 /* Controller type with RGB_ORDER and spi frequency specified */ \
1139 template<fl::EOrder RGB_ORDER, fl::u32 FREQ> \
1140 struct CONTROLLER_CLASS_WITH_ORDER_AND_FREQ { \
1141 typedef CONTROLLER_CLASS<DATA_PIN, CLOCK_PIN, RGB_ORDER, FREQ> ControllerType; \
1142 }; \
1143 };
1144
1145 // Define specializations for each supported CHIPSET
1146 // Note: Using unscoped enum values for backwards compatibility
1154
1155 // Both DOTSTAR and APA102 use the same controller class
1158
1159 // Both DOTSTARHD and APA102HD use the same controller class
1162
1165
1167
1170
1171
1172 #if FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS
1176 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) {
1177 // Instantiate the controller using ClockedChipsetHelper
1178 // Always USE WS2812 clockless controller since it's the common path.
1179 return addLeds<WS2812, DATA_PIN, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1180 }
1181
1183 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) {
1184 // Always USE WS2812 clockless controller since it's the common path.
1185 return addLeds<WS2812, DATA_PIN, B>(data, nLedsOrOffset, nLedsIfOffset);
1186 }
1187
1188
1189 // The addLeds function using ChipsetHelper
1190 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1191 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1192 // Always USE WS2812 clockless controller since it's the common path.
1193 return addLeds<WS2812, DATA_PIN, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1194 }
1195
1196 #endif // FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS (fake-SPI overloads)
1197
1198 // Channel-API SPI entry points (#4585). Always declared (templates are only
1199 // instantiated on use) so host tests can pin the exact code path that
1200 // `addLeds<ESPIChipsets ...>()` takes when FASTLED_SPI_USES_CHANNEL_API=1,
1201 // even though the shared test PCH parses FastLED.h with the host default
1202 // (0). Under FASTLED_SPI_USES_CHANNEL_API the public addLeds<> overloads
1203 // below forward here verbatim.
1204 //
1205 // Compile-time dispatch (#4585, #4636): every SPI chipset routes through
1206 // the slim `fl::SlimSpiBridgeController`. MY9221 uses the bit-bang
1207 // `MY9221Controller` instead, because it is dual-edge (DDR) clocked and
1208 // cannot be carried as SPI bytes. No runtime `fl::Channel` is ever built
1209 // for legacy `addLeds<>`. C++11 has no `if constexpr`, so the two bodies
1210 // are separate overloads selected via a `fl::true_type`/`fl::false_type`
1211 // tag -- only the overload actually called gets instantiated, so the
1212 // never-taken branch never names `SlimSpiBridgeController<..., MY9221, ...>`.
1213 //
1214 // DATA_PIN / CLOCK_PIN / RATE / VARIANT exist only to key the
1215 // function-local statics exactly like the old per-`addLeds<>`-instantiation
1216 // `static ChannelPtr sChannel` was keyed: two strips of the same chipset on
1217 // different pins (or via different overloads) must get distinct controllers.
1218 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT,
1220 static ::CLEDController &addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset,
1221 const fl::SpiChipsetConfig &spiCfg, fl::true_type /*useSlim*/) FL_NO_EXCEPT {
1223 return addLeds(&sCtrl, data, nLedsOrOffset, nLedsIfOffset);
1224 }
1225
1226 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT,
1227 fl::EOrder RGB_ORDER, fl::Bus B, fl::u8 B_WHICH>
1228 static ::CLEDController &addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset,
1229 const fl::SpiChipsetConfig &spiCfg, fl::false_type /*isMY9221 -> bit-bang*/) FL_NO_EXCEPT {
1230 (void)spiCfg;
1231 static MY9221Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, (RATE ? RATE : DATA_RATE_MHZ(1))> sCtrl;
1232 // Register (and bind the LED buffer) only once per specialization; a
1233 // repeated call must not rebind the shared controller's buffer.
1234 static bool sRegistered = false;
1235 if (sRegistered) {
1236 return sCtrl;
1237 }
1238 sRegistered = true;
1239 return addLeds(&sCtrl, data, nLedsOrOffset, nLedsIfOffset);
1240 }
1241
1242 // Only explicit-host slim controllers reference the native SPI driver, so
1243 // AUTO-host and MY9221 sketches never link the ESP-IDF SPI master stack.
1245#if defined(FL_IS_ESP32)
1246 if (spiCfg.spiBus != fl::Esp32SpiBus::AUTO) {
1247 fl::platforms::registerNativeSpiDriver();
1248 }
1249#else
1250 (void)spiCfg;
1251#endif
1252 }
1253
1255 (void)spiCfg;
1256 }
1257
1259 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>
1260 ::CLEDController &addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1262 static_cast<fl::SpiChipset>(CHIPSET), SPI_DATA_RATE);
1263 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1265 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, SPI_DATA_RATE, 0, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
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>
1272 static_cast<fl::SpiChipset>(CHIPSET), SPI_DATA_RATE);
1273 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder, spiBus);
1275 registerExplicitSpiHost(spiCfg, UseSlim());
1277 }
1278
1280 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1281 static ::CLEDController &addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1283 static_cast<fl::SpiChipset>(CHIPSET));
1284 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1285 // HD108 defaults to GRB; all other SPI chipsets default to RGB.
1286 constexpr fl::EOrder order =
1288 ? GRB : RGB;
1290 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, 0, 2, order, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1291 }
1292
1294 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>
1295 ::CLEDController& addLedsSpiChannel(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1297 static_cast<fl::SpiChipset>(CHIPSET));
1298 fl::SpiChipsetConfig spiCfg(DATA_PIN, CLOCK_PIN, encoder);
1300 return addLedsSpiDispatch<CHIPSET, DATA_PIN, CLOCK_PIN, 0, 3, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset, spiCfg, UseSlim());
1301 }
1302
1303 #if FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS
1304 // Fake-SPI overloads declared above.
1305 #elif FASTLED_SPI_USES_CHANNEL_API
1306
1308 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>
1309 ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1311 }
1312
1314 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>
1315 ::CLEDController &addLeds(CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) {
1317 }
1318
1320 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
1321 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1322 return addLedsSpiChannel<CHIPSET, DATA_PIN, CLOCK_PIN, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset);
1323 }
1324
1326 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>
1327 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1328 return addLedsSpiChannel<CHIPSET, DATA_PIN, CLOCK_PIN, RGB_ORDER, B, B_WHICH>(data, nLedsOrOffset, nLedsIfOffset);
1329 }
1330
1331 #else
1332
1334 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 {
1336 // Instantiate the controller using ClockedChipsetHelper
1338 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1339 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
1340 static ControllerTypeWithFreq c;
1341 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1342 }
1343
1346 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>
1350 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1351 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER_AND_FREQ<RGB_ORDER, SPI_DATA_RATE>::ControllerType ControllerTypeWithFreq;
1352 static ControllerTypeWithFreq c;
1353 c.setSpiBus(spiBus);
1354 return addLeds(&c, data, nLeds, 0);
1355 }
1356
1358 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 {
1361 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1362 typedef typename CHIP::ControllerType ControllerType;
1363 static ControllerType c;
1364 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1365 }
1366
1368 template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1369 ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1372 FL_STATIC_ASSERT(CHIP::IS_VALID, "Unsupported chipset");
1373 typedef typename CHIP::template CONTROLLER_CLASS_WITH_ORDER<RGB_ORDER>::ControllerType ControllerTypeWithOrder;
1374 static ControllerTypeWithOrder c;
1375 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1376 }
1377 #endif
1378
1379
1380#ifdef SPI_DATA
1381 template<ESPIChipsets CHIPSET, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1382 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB, B>(data, nLedsOrOffset, nLedsIfOffset);
1383 }
1384
1385 template<ESPIChipsets CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO> static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1386 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, B>(data, nLedsOrOffset, nLedsIfOffset);
1387 }
1388
1389 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) {
1390 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE, B>(data, nLedsOrOffset, nLedsIfOffset);
1391 }
1392
1393#endif
1395
1396#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
1400 template<typename ControllerType>
1401 static inline ::CLEDController& addLedsImpl(ControllerType* controller, CRGB *data, int nLedsOrOffset, int nLedsIfOffset) FL_NO_EXCEPT {
1402 ::CLEDController* pLed = static_cast<::CLEDController*>(controller);
1403 return addLeds(pLed, data, nLedsOrOffset, nLedsIfOffset);
1404 }
1425
1427 template<template<fl::u8, fl::EOrder> class CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1428 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1430 using Controller = typename fl::detail::ClocklessBusController<CHIPSET<DATA_PIN, RGB_ORDER>, B>::type;
1431 static Controller c;
1432 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1433 }
1434
1436 template<template<fl::u8, fl::EOrder> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1437 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1439 using Controller = typename fl::detail::ClocklessBusController<CHIPSET<DATA_PIN, RGB>, B>::type;
1440 static Controller c;
1441 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1442 }
1443
1445 template<template<fl::u8> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1446 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1448 using Controller = typename fl::detail::ClocklessBusController<CHIPSET<DATA_PIN>, B>::type;
1449 static Controller c;
1450 return addLedsImpl(&c, data, nLedsOrOffset, nLedsIfOffset);
1451 }
1452
1453 template<template<fl::u8> class CHIPSET, fl::u8 DATA_PIN, fl::Bus B = fl::Bus::AUTO>
1454 static ::CLEDController &addLeds(fl::Leds& leds, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1455 CRGB* rgb = leds;
1456 return addLeds<CHIPSET, DATA_PIN, B>(rgb, nLedsOrOffset, nLedsIfOffset);
1457 }
1458
1459#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
1460 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>
1461 static ::CLEDController &addLeds(CRGB *data, int nLeds) {
1463 static fl::__FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
1464 return addLeds(&c, data, nLeds);
1465 }
1466#endif
1467
1468 #ifdef FASTSPI_USE_DMX_SIMPLE
1469 template<EClocklessChipsets CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER=RGB, fl::Bus B = fl::Bus::AUTO>
1470 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1471 {
1473 switch(CHIPSET) {
1474 case DMX: { static DMXController<DATA_PIN> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1475 }
1476 }
1477 #endif
1479#endif
1480
1501
1503 template<template<fl::EOrder RGB_ORDER> class CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1504 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1506 static CHIPSET<RGB_ORDER> c;
1507 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1508 }
1509
1511 template<template<fl::EOrder RGB_ORDER> class CHIPSET, fl::Bus B = fl::Bus::AUTO>
1512 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) FL_NO_EXCEPT {
1514 static CHIPSET<RGB> c;
1515 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
1516 }
1517
1518#ifdef USE_OCTOWS2811
1522 template<OWS2811 CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1523 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1524 {
1526 switch(CHIPSET) {
1527 case OCTOWS2811: { static fl::COctoWS2811Controller<RGB_ORDER,WS2811_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1528 case OCTOWS2811_400: { static fl::COctoWS2811Controller<RGB_ORDER,WS2811_400kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1529#ifdef WS2813_800kHz
1530 case OCTOWS2813: { static fl::COctoWS2811Controller<RGB_ORDER,WS2813_800kHz> controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1531#endif
1532 }
1533 }
1534
1538 template<OWS2811 CHIPSET, fl::Bus B = fl::Bus::AUTO>
1539 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1540 {
1541 return addLeds<CHIPSET,GRB,B>(data,nLedsOrOffset,nLedsIfOffset);
1542 }
1543
1544#endif
1545
1546#ifdef USE_WS2812SERIAL
1550 template<SWS2812 CHIPSET, int DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1551 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1552 {
1554 static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
1555 return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
1556 }
1557#endif
1558
1559#ifdef SmartMatrix_h
1562 template<ESM CHIPSET, fl::Bus B = fl::Bus::AUTO>
1563 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
1564 {
1566 switch(CHIPSET) {
1567 case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
1568 }
1569 }
1570#endif
1572
1573
1574#ifdef FASTLED_HAS_BLOCKLESS
1575
1596
1598 template<EBlockChipsets CHIPSET, int NUM_LANES, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
1599 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1601 switch(CHIPSET) {
1602 #ifdef PORTA_FIRST_PIN
1603 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
1604 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
1605 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
1606 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
1607 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
1608 #endif
1609 #ifdef PORTB_FIRST_PIN
1610 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
1611 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
1612 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
1613 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
1614 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
1615 #endif
1616 #ifdef PORTC_FIRST_PIN
1617 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
1618 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
1619 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
1620 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
1621 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
1622 #endif
1623 #ifdef PORTD_FIRST_PIN
1624 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
1625 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
1626 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
1627 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
1628 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
1629 #endif
1630 #ifdef HAS_PORTDC
1631 case WS2811_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1632 case WS2811_400_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2811_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1633 case WS2813_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_WS2813, RGB_ORDER, 0, false>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1634 case TM1803_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_TM1803_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1635 case UCS1903_PORTDC: return addLeds(new fl::SixteenWayInlineBlockClocklessController<NUM_LANES, fl::TIMING_UCS1903_400KHZ, RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset); // ok bare allocation
1636 #endif
1637 }
1638 }
1639
1641 template<EBlockChipsets CHIPSET, int NUM_LANES, fl::Bus B = fl::Bus::AUTO>
1642 static ::CLEDController &addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
1643 return addLeds<CHIPSET,NUM_LANES,GRB,B>(data,nLedsOrOffset,nLedsIfOffset);
1644 }
1645
1646#endif
1647
1651
1655
1659
1666 void setDriverEnabled(const char* name, bool enabled) FL_NO_EXCEPT;
1667
1692 template<fl::Bus B, fl::u8 Which = 0>
1696
1708 bool setExclusiveDriver(fl::Bus bus, fl::u8 which = 0) FL_NO_EXCEPT;
1709
1713 bool isDriverEnabled(const char* name) const FL_NO_EXCEPT;
1714
1718
1722 fl::span<const fl::DriverInfo> getDriverInfos() const FL_NO_EXCEPT;
1723
1725
1732 void wait() FL_NO_EXCEPT;
1733
1737 bool wait(fl::u32 timeout_ms) FL_NO_EXCEPT;
1738
1742 inline void setMaxPowerInVoltsAndMilliamps(fl::u8 volts, fl::u32 milliamps) FL_NO_EXCEPT { setMaxPowerInMilliWatts(volts * milliamps); }
1743
1746 inline void setMaxPowerInMilliWatts(fl::u32 milliwatts) FL_NO_EXCEPT {
1747 mNPowerData = milliwatts;
1748#if FL_COLOR_PIPELINE_SHARED
1749 fl::activeFramePowerDispatch() = fl::framePowerDispatch();
1750 mPPowerFunc = fl::activeFramePowerDispatch()->showBrightness;
1751#else
1753#endif
1754 }
1755
1764 void setHdFieldFloor(fl::u8 min_field) FL_NO_EXCEPT;
1767
1773
1777 bool isPowerLimited() const FL_NO_EXCEPT;
1778
1782
1791 inline void setPowerModel(const PowerModelRGB& model) FL_NO_EXCEPT {
1792 set_power_model(model);
1793 }
1794
1798 inline void setMcuPowerMilliWatts(fl::u16 mcu_mW) FL_NO_EXCEPT {
1799 set_mcu_power_mW(mcu_mW);
1800 }
1801
1802 inline fl::u16 getMcuPowerMilliWatts() const FL_NO_EXCEPT {
1803 return get_mcu_power_mW();
1804 }
1805
1815 inline void setPowerScalingExponent(float exponent) FL_NO_EXCEPT {
1817 }
1818
1824 }
1825
1826private:
1827 // Forward shims for the tiered-wait spin budget (#2818). Full impl
1828 // lives in src/fl/channels/detail/wait_spin_budget.{h,cpp.hpp}.
1829 // Declared here so we don't drag the channel-detail include graph
1830 // into FastLED.h.
1831 static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT;
1832 static fl::u32 _getWaitSpinBudgetUs() FL_NO_EXCEPT;
1833public:
1834
1848 inline void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT {
1849 _setWaitSpinBudgetUs(budget_us);
1850 }
1851
1853 inline fl::u32 getWaitSpinBudgetUs() const FL_NO_EXCEPT {
1854 return _getWaitSpinBudgetUs();
1855 }
1856
1861 inline void setPowerModel(const PowerModelRGBW& model) FL_NO_EXCEPT {
1862 set_power_model(model);
1863 }
1864
1869 inline void setPowerModel(const PowerModelRGBWW& model) FL_NO_EXCEPT {
1870 set_power_model(model);
1871 }
1872
1876 return get_power_model();
1877 }
1878
1917 fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter = true) const FL_NO_EXCEPT;
1918
1920
1929
1944 inline void setRgbwColorimetricProfile(const fl::DiodeProfile* profile) FL_NO_EXCEPT {
1946 }
1947
1952
1954
1962
1966
1967 // Called automatically at the end of show().
1968 void onEndFrame() FL_NO_EXCEPT;
1969
1973 void clear(bool writeData = false) FL_NO_EXCEPT;
1974
1996 static void clear(ClearFlags flags) FL_NO_EXCEPT;
1997
1999 void clearData() FL_NO_EXCEPT;
2000
2004 void showColor(const CRGB & color, fl::u8 scale) FL_NO_EXCEPT;
2005
2008 void showColor(const CRGB & color) FL_NO_EXCEPT { showColor(color, mScale); }
2009
2014 void delay(unsigned long ms) FL_NO_EXCEPT;
2015
2019 void setTemperature(const CRGB & temp) FL_NO_EXCEPT;
2020
2024 void setCorrection(const CRGB & correction) FL_NO_EXCEPT;
2025
2029 void setDither(fl::u8 ditherMode = BINARY_DITHER) FL_NO_EXCEPT;
2030
2045
2053 void setMaxRefreshRate(fl::u16 refresh, bool constrain=false) FL_NO_EXCEPT;
2054
2059 void countFPS(int nFrames=25) FL_NO_EXCEPT;
2060
2063 fl::u16 getFPS() FL_NO_EXCEPT { return mNFPS; }
2064
2067 int count() FL_NO_EXCEPT;
2068
2071 CLEDController & operator[](int x) FL_NO_EXCEPT;
2072
2075 int size() FL_NO_EXCEPT;
2076
2080};
2081
2083#define FastSPI_LED FastLED
2085#define FastSPI_LED2 FastLED
2086#ifndef LEDS
2088#define LEDS FastLED
2089#endif
2090
2092extern CFastLED FastLED;
2093
2097#ifndef HAS_HARDWARE_PIN_SUPPORT
2098#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
2099#define NO_HARDWARE_PIN_SUPPORT
2100#endif
2101
2102
2103#endif
2104
2105
2107
2108#if !defined(FASTLED_INTERNAL) && !defined(FASTLED_LEAN_AND_MEAN)
2109
2110#include "fl/stl/string.h" // Awesome Str class that has stack allocation and heap overflow, copy on write.
2111#include "fl/math/xymap.h" // XYMap class for mapping 2D coordinates on seperintine matrices.
2112
2113#include "fl/math/math.h" // fl::clamp, fl::map_range, fl::min, fl::max, etc.
2114
2115#include "fl/log/log.h" // FL_WARN("time now: " << millis()), FL_WARN_IF(...), FL_PRINT(...), FL_LOG_*() category-specific logging
2116#include "fl/system/serial.h" // Arduino-compatible Serial API: fl::Serial.print(), fl::Serial.read(), etc.
2117#include "fl/stl/assert.h" // FASTLED_ASSERT(condition, "message");
2118#include "fl/stl/sstream.h" // fl::sstream for string stream operations
2119
2120// The remote RPC system (fl/remote/remote.h) is opt-in: it pulls the JSON
2121// parser, the RPC server and the scheduler (57 headers) into every sketch
2122// that includes FastLED.h. Sketches that use it include it directly, or
2123// define FL_INCLUDE_REMOTE before including FastLED.h.
2124#if defined(FL_INCLUDE_REMOTE)
2125#include "fl/remote/remote.h" // Remote RPC system for JSON-based function calls
2126#endif
2127
2128// provides:
2129// fl::vector<T> - Standard heap vector
2130// fl::vector_inlined<T,N> - Allocate on stack N elements, then overflow to heap vector.
2131// fl::vector_fixed<T,N> - Stack allocated fixed size vector, elements will fail to add when full.
2132#include "fl/stl/vector.h"
2133
2134// Flexible callbacks in the style of std::function.
2135#include "fl/stl/function.h"
2136
2137// Clears the led data and other objects.
2138// CRGB leds[NUM_LEDS];
2139// fl::clear(leds)
2140#include "fl/gfx/clear.h"
2141
2142// Leds has a CRGB block and an XYMap
2143#include "fl/gfx/leds.h"
2144
2145#include "fl/channels/spi.h" // SPI device and multi-lane SPI support (1-16 lanes)
2146
2147#include "fl/ui/ui.h" // Provides UIButton, UISlider, UICheckbox, UINumberField and UITitle, UIDescription, UIHelp, UIGroup.
2148#include "fl/stl/noexcept.h"
2149using fl::UITitle;
2150using fl::UIDescription;
2151using fl::UIHelp;
2152using fl::UIButton; // These names are unique enough that we don't need to namespace them
2153using fl::UICheckbox;
2154using fl::UINumberField;
2155using fl::UISlider;
2156using fl::UIDropdown;
2157using fl::UIGroup;
2158using fl::XYMap;
2159using fl::round; // Template version avoids conflicts with ::round
2160// Only expose fl::delay as global delay() on non-hardware platforms (stub/WASM).
2161// On real Arduino platforms, Arduino's native delay(uint32_t) is already in scope;
2162// importing fl::delay there causes an ambiguous-overload error for any third-party
2163// library (e.g. IRremote) that calls the unqualified delay().
2164// Users who need fl::delay's async-task-pumping behaviour can call fl::delay() or
2165// fl::delayMs() explicitly.
2166#if defined(FASTLED_STUB_IMPL)
2167using fl::delay;
2168#endif
2169
2170// Common fl:: type aliases for global namespace convenience
2171template<typename T> using fl_vector = fl::vector<T>;
2172template<typename Key, typename Value, typename Compare = fl::less<Key>> using fl_map = fl::flat_map<Key, Value, Compare>;
2173using fl_string = fl::string;
2174
2175// Note: delayMicroseconds and delayMillis are provided by Arduino core
2176// The fl:: namespace versions are available for explicit use when needed
2177
2178#define FASTLED_TITLE(text) fl::UITitle g_title(text)
2179#define FASTLED_DESCRIPTION(text) fl::UIDescription g_description(text)
2180#define FASTLED_HELP(text) fl::UIHelp g_help(text)
2181
2182
2183#endif // FASTLED_INTERNAL && !FASTLED_LEAN_AND_MEAN
2184
2185
2186
2187// Experimental: loop() hijacking.
2188//
2189// EngineEvents requires that FastLED.show() be invoked.
2190// If the user skips that then certain updates will be skipped.
2191//
2192// Right now this isn't a big deal, but in the future it could be.
2193//
2194// Therefore this experiment is done so that this loop() hijack trick
2195// can be used to insert code at the start of every loop(), such as a
2196// scoped object that forces a begin and end frame event.
2197//
2198// It's possible to hijack the loop() via a macro so that
2199// extra code can be injected at the start of every frame.
2200// When FASTLED_LOOP_RUNS_ASYNC == 1
2201// then use loop() to also run the async.
2202//
2203// EXAMPLE:
2204// #define FASTLED_LOOP_RUNS_ASYNC 1
2205// #include "FastLED.h"
2206// void loop() {
2207// FL_WARN("async will run in the loop");
2208// delay(500);
2209// }
2210
2211#ifndef FASTLED_LOOP_RUNS_ASYNC
2212#define FASTLED_LOOP_RUNS_ASYNC 0
2213#endif
2214
2215#if FASTLED_LOOP_RUNS_ASYNC == 1
2216// The loop is set as a macro that re-defines the user loop function
2217// to sketch_loop()
2218#define loop() \
2219 sketch_loop(); \
2220 void loop() { sketch_loop(); fl::task::run(); } \
2221 void sketch_loop()
2222#endif
2223
2224// Backdoor to get the size of the CLedController object. The one place
2225// that includes this just uses extern to declare the function.
2226// Declaration moved to src/fl/system/fastled.h
CRGB leds[1]
#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:679
#define _FL_MAP_CLOCKED_CHIPSET(CHIPSET_ENUM, CONTROLLER_CLASS)
Definition FastLED.h:1128
ClearFlags
Flags for FastLED.clear() to control what state gets cleared/reset.
Definition FastLED.h:663
@ CHANNELS
Remove all channels from controller list.
Definition FastLED.h:665
@ CHANNEL_ENGINES
Clear all channel drivers from ChannelManager.
Definition FastLED.h:670
@ POWER_SETTINGS
Reset power management (setMaxPowerInMilliWatts)
Definition FastLED.h:666
@ FPS_COUNTER
Reset FPS tracking counter to 0.
Definition FastLED.h:669
@ NONE
Clear nothing (no-op)
Definition FastLED.h:664
@ REFRESH_RATE
Reset refresh rate limiting to unlimited.
Definition FastLED.h:668
ClearFlags & operator|=(ClearFlags &a, ClearFlags b) FL_NO_EXCEPT
Enable bitwise OR assignment for ClearFlags.
Definition FastLED.h:684
ClearFlags operator|(ClearFlags a, ClearFlags b) FL_NO_EXCEPT
Enable bitwise OR for ClearFlags.
Definition FastLED.h:674
SWS2812
WS2812Serial Library controller type.
Definition FastLED.h:325
@ WS2812SERIAL
Definition FastLED.h:325
OWS2811
Octo WS2811 LED Library controller types.
Definition FastLED.h:320
@ OCTOWS2811
Definition FastLED.h:320
@ OCTOWS2813
Definition FastLED.h:320
@ OCTOWS2811_400
Definition FastLED.h:320
ESPIChipsets
Backwards compatibility enum - allows old code to use unscoped names (e.g., APA102 instead of fl::Spi...
Definition FastLED.h:293
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:306
@ P9813
P9813 LED chipset.
Definition FastLED.h:300
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
Definition FastLED.h:303
@ SK9822
SK9822 LED chipset.
Definition FastLED.h:302
@ MY9221
MY9221 12-channel LED driver (dual-edge clocked; 4 RGB LEDs per chip)
Definition FastLED.h:299
@ WS2803
WS2803 LED chipset.
Definition FastLED.h:297
@ HD107
Same as APA102, but in turbo 40-mhz mode.
Definition FastLED.h:307
@ HD107S
Marketed HD107S part name; alias of HD107.
Definition FastLED.h:308
@ WS2801
WS2801 LED chipset.
Definition FastLED.h:296
@ DOTSTAR
APA102 LED chipset alias.
Definition FastLED.h:304
@ APA102
APA102 LED chipset.
Definition FastLED.h:301
@ LPD8806
LPD8806 LED chipset.
Definition FastLED.h:295
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
Definition FastLED.h:309
@ LPD6803
LPD6803 LED chipset.
Definition FastLED.h:294
@ DOTSTARHD
APA102HD LED chipset alias.
Definition FastLED.h:305
@ SM16716
SM16716 LED chipset.
Definition FastLED.h:298
@ HD108
16-bit variant of HD107, always gamma corrected. No SD (standard definition) option available - all H...
Definition FastLED.h:310
ESM
Smart Matrix Library controller type.
Definition FastLED.h:315
@ SMART_MATRIX
Definition FastLED.h:315
EBlockChipsets
Blockless output port enum.
Definition FastLED.h:598
fl::u8(* power_func)(fl::u8 scale, fl::u32 data)
Typedef for a power consumption calculation function.
Definition FastLED.h:643
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:728
_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:1654
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:1693
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:1822
void setPowerModel(const PowerModelRGBW &model) FL_NO_EXCEPT
Definition FastLED.h:1861
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:1965
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:1244
static void registerExplicitSpiHost(const fl::SpiChipsetConfig &spiCfg, fl::false_type) FL_NO_EXCEPT
Definition FastLED.h:1254
CFastLED & enable() FL_NO_EXCEPT
Enable one bus for the runtime FastLED.add(cfg) path.
Definition FastLED.h:1042
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:2036
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:1853
::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:1512
void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
Override the channel-manager tiered-wait spin budget (microseconds).
Definition FastLED.h:1848
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:1746
::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:1369
void setBrightness(fl::u8 scale) FL_NO_EXCEPT
Set the global brightness scaling.
Definition FastLED.h:1650
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:1742
::CLEDController & addLedsSpiDispatch(CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::false_type) FL_NO_EXCEPT
Definition FastLED.h:1228
void clearData() FL_NO_EXCEPT
Clear out the local data array.
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Definition FastLED.h:1091
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:1347
const fl::DiodeProfile * getRgbwColorimetricProfile() const FL_NO_EXCEPT
Currently active RGBW colorimetric profile (defaults to &fl::kRgbwDefaultProfile).
Definition FastLED.h:1949
fl::u16 getFPS() FL_NO_EXCEPT
Get the number of frames/second being written out.
Definition FastLED.h:2063
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:1220
void setMcuPowerMilliWatts(fl::u16 mcu_mW) FL_NO_EXCEPT
Definition FastLED.h:1798
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:2033
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:724
static fl::ChannelPtr add(const fl::ChannelConfigOf< Chipset > &config) FL_NO_EXCEPT
Add a typed configuration, deducing its chipset family.
Definition FastLED.h:862
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:1281
void showColor(const CRGB &color) FL_NO_EXCEPT
Set all leds on all controllers to the given color.
Definition FastLED.h:2008
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:1358
void setPowerModel(const PowerModelRGB &model) FL_NO_EXCEPT
Definition FastLED.h:1791
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:1944
void setDefaultSourceProfile(const fl::SourceProfile &profile) FL_NO_EXCEPT
Definition FastLED.h:2039
fl::u32 mNPowerData
max power use parameter
Definition FastLED.h:727
fl::u16 mNFPS
tracking for current frames per second (FPS) value
Definition FastLED.h:725
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:730
::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:1270
void addListener(fl::EngineEvents::Listener *listener) FL_NO_EXCEPT
Definition FastLED.h:751
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a OCTOWS2811 based CLEDController instance to the world.
Definition FastLED.h:1523
static fl::ChannelPtr add(const fl::ChannelConfig &config) FL_NO_EXCEPT
Definition FastLED.h:869
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:729
::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:1295
::CLEDController & addLedsSpiChannel(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add an SPI based CLEDController via Channel API.
Definition FastLED.h:1260
const fl::SourceProfile & defaultSourceProfile() const FL_NO_EXCEPT
Definition FastLED.h:2042
::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:1869
::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:1334
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a WS2812Serial library based CLEDController instance to the world.
Definition FastLED.h:1551
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:1815
fl::u16 getMcuPowerMilliWatts() const FL_NO_EXCEPT
Definition FastLED.h:1802
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:1504
::CLEDController & addLeds(CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a OCTOWS2811 library based CLEDController instance to the world.
Definition FastLED.h:1539
PowerModelRGB getPowerModel() const FL_NO_EXCEPT
Get current RGB power model.
Definition FastLED.h:1875
void removeListener(fl::EngineEvents::Listener *listener) FL_NO_EXCEPT
Definition FastLED.h:752
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:726
and refresh rates, and provides access functions for driving led data to controllers via the show() /...
Definition FastLED.h:720
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:365
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,...
static ChannelPtr create(const ChannelConfigOf< Chipset > &cfg) FL_NO_EXCEPT
Construct a runtime Channel from a typed configuration.
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.
Opt-in, link-on-use channel driver bindings for FastLED.add(cfg).
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.
fl::u16 get_mcu_power_mW() FL_NO_EXCEPT
The MCU baseline currently charged, in milliwatts.
float get_power_scaling_exponent() FL_NO_EXCEPT
Get the current brightness-to-power response exponent.
void set_mcu_power_mW(fl::u16 mcu_mW) FL_NO_EXCEPT
Override the MCU board's undimmable baseline draw, in milliwatts.
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:132
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:159
Bus
Portable public bus selector.
Definition bus.h:31
@ AUTO
Definition bus.h:32
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
void bindDriver() FL_NO_EXCEPT
Enable one bus for FastLED.add(cfg).
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:1123
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:65
RGBWW LED power consumption model (RGB + warm white + cool white).
Definition power_mgt.h:106
Configuration for a single LED channel.
Definition config.h:167
Strongly-typed channel configuration with compile-time chipset family.
Definition config.h:307
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.