FastLED 3.10.10
Loading...
Searching...
No Matches
chipsets.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef __INC_CHIPSETS_H
4#define __INC_CHIPSETS_H
5
6// allow-include-after-namespace
7
8#include "pixeltypes.h"
12#include "fl/stl/bit_cast.h"
13#include "fl/stl/unique_ptr.h"
16#include "pixel_iterator.h"
17#include "crgb.h"
18#include "eorder.h"
19#include "fl/math/math.h"
20#include "platforms/is_platform.h"
21
22// Include centralized LED chipset timing definitions
23// These provide unified nanosecond-based T1, T2, T3 timing for all supported chipsets
25
26// Include legacy AVR-specific timing definitions (FMUL-based)
27// Used for backward compatibility with existing AVR clockless drivers
28#ifdef FL_IS_AVR
29#include "platforms/avr/led_timing_legacy_avr.h" // ok platform headers
30#endif
31
32// Platform-specific clockless controller dispatch
33// Includes the appropriate clockless controller implementation for the target platform
34#include "platforms/clockless.h"
35
36// Include UCS7604 controller (works on all platforms with clockless controller support)
37#include "fl/chipsets/ucs7604.h"
39
40// Include platform-independent SPI utilities
41#include "platforms/shared/spi_pixel_writer.h" // ok platform headers
42
43// Platform-specific SPI output template dispatch
44// Includes the appropriate SPIOutput template implementation for the target platform
45// This must be included before any SPI chipset controllers (e.g., APA102, P9813)
46#include "platforms/spi_output_template.h"
47
48// Include SPI chipset controllers
49#include "fl/chipsets/apa102.h"
50#include "fl/chipsets/hd108.h"
51#include "fl/chipsets/lpd880x.h"
52#include "fl/chipsets/ws2801.h"
53#include "fl/chipsets/p9813.h"
54#include "fl/chipsets/sm16716.h"
55#include "fl/chipsets/my9221.h"
56
57// Platform-specific clockless timing configuration
58//
59// IMPORTANT: All platforms use nanosecond-based timing at the API level.
60// Chipset timing values (T1, T2, T3) are specified in nanoseconds (e.g., T1=250ns, T2=625ns, T3=375ns)
61//
62// Platforms that need cycle-based timing internally (e.g., AVR, ARM, ESP8266) perform
63// nanosecond-to-cycle conversion within their clockless driver implementation using F_CPU or equivalent.
64//
65// Platform-specific clockless drivers are defined in:
66// - ESP32/ESP8266: platforms/esp/clockless.h
67// - All ARM platforms: led_sysdefs_arm_*.h + platform-specific clockless headers
68// - AVR platforms: led_sysdefs_avr.h + platforms/avr/clockless_*.h
69// - Other platforms: respective led_sysdefs_*.h files
70
71// ============================================================================
72// PLATFORM-SPECIFIC SPECIALIZED CONTROLLERS (Bottom Includes)
73// ============================================================================
74// The includes below MUST be at this point in the file because:
75//
76// 1. C++ templates require full definition in headers (no .cpp separation)
77// 2. Base templates and type definitions (above) must be defined BEFORE
78// platform-specific specializations (below) can see and use them
79// 3. Platform specializations need to instantiate/specialize the base templates
80//
81// This is intentional C++ template architecture, not a code smell or circular
82// dependency. Template-heavy libraries like FastLED naturally have includes at
83// the bottom to support platform-specific specializations.
84//
85// Example: WS2812 is heavily optimized per-platform because it's the most
86// popular chipset. Each platform provides specialized implementations that
87// fully replace the default template instantiation.
88// ============================================================================
89
90#include "platforms/chipsets_specialized_ws2812.h"
91
92#if defined(ARDUINO) && (defined(SoftwareSerial_h) || defined(__SoftwareSerial_h))
93// IWYU pragma: begin_keep
94#include <SoftwareSerial.h>
95// IWYU pragma: end_keep
96#endif
97
100
101
102
107
108#if defined(ARDUINO) && (defined(SoftwareSerial_h) || defined(__SoftwareSerial_h))
109
110#define HAS_PIXIE
111
112
116template<fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
117class PixieController : public CPixelLEDController<RGB_ORDER> {
118 SoftwareSerial Serial;
119 CMinWait<2000> mWait;
120
121public:
122 PixieController() : Serial(-1, DATA_PIN) {}
123
124protected:
126 virtual void init() {
127 Serial.begin(115200);
128 mWait.mark();
129 }
130
132 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
133 mWait.wait();
134 while(pixels.has(1)) {
135 fl::u8 r = pixels.loadAndScale0();
136 Serial.write(r);
137 fl::u8 g = pixels.loadAndScale1();
138 Serial.write(g);
139 fl::u8 b = pixels.loadAndScale2();
140 Serial.write(b);
141 pixels.advanceData();
142 pixels.stepDithering();
143 }
144 mWait.mark();
145 }
146
147};
148
149// template<SoftwareSerial & STREAM, EOrder RGB_ORDER = RGB>
150// class PixieController : public PixieBaseController<STREAM, RGB_ORDER> {
151// public:
152// virtual void init() {
153// STREAM.begin(115200);
154// }
155// };
156
157#endif
158#endif
159
191
192
193template <
194 typename CONTROLLER,
195 EOrder RGB_ORDER = GRB> // Default on WS2812>
197 : public CPixelLEDController<RGB_ORDER, CONTROLLER::LANES_VALUE,
198 CONTROLLER::MASK_VALUE> {
199 public:
200 // ControllerT is a helper class. It subclasses the device controller class
201 // and has three methods to call the three protected methods we use.
202 // This is janky, but redeclaring public methods protected in a derived class
203 // is janky, too.
204
205 // N.B., byte order must be RGB.
206 typedef CONTROLLER ControllerBaseT;
207 class ControllerT : public CONTROLLER {
208 friend class RGBWEmulatedController<CONTROLLER, RGB_ORDER>;
209 void *callBeginShowLeds(int size) FL_NO_EXCEPT { return ControllerBaseT::beginShowLeds(size); }
210 void callShow(CRGB *data, int nLeds, fl::u8 brightness) FL_NO_EXCEPT {
211 ControllerBaseT::show(data, nLeds, brightness);
212 }
213 void callEndShowLeds(void *data) FL_NO_EXCEPT { ControllerBaseT::endShowLeds(data); }
214 };
215
216
217 static const int LANES = CONTROLLER::LANES_VALUE;
218 static const fl::u32 MASK = CONTROLLER::MASK_VALUE;
219
220 // The delegated controller must do no reordering.
221 FL_STATIC_ASSERT(RGB == CONTROLLER::RGB_ORDER_VALUE, "The delegated controller MUST NOT do reordering");
222
228
231
235
237 return mController.callEndShowLeds(data);
238 }
239
248 // Ensure buffer is large enough
249 ensureBuffer(pixels.size());
250 Rgbw rgbw = this->getRgbw();
252 while (pixels.has(1)) {
253 pixels.stepDithering();
254 pixels.loadAndScaleRGBW(rgbw, data, data + 1, data + 2, data + 3);
255 data += 4;
256 pixels.advanceData();
257 }
258
259 // Force the device controller to a state where it passes data through
260 // unmodified: color correction, color temperature, dither, and brightness
261 // (passed as an argument to show()). Temporarily enable the controller,
262 // show the LEDs, and disable it again.
263 //
264 // The device controller is in the global controller list, so if we
265 // don't keep it disabled, it will refresh again with unknown brightness,
266 // temperature, etc.
267
268 mController.setCorrection(CRGB(255, 255, 255));
269 mController.setTemperature(CRGB(255, 255, 255));
270 mController.setDither(DISABLE_DITHER);
271
272 mController.setEnabled(true);
273 mController.callShow(mRGBWPixels.get(), Rgbw::size_as_rgb(pixels.size()), 255);
274 mController.setEnabled(false);
275 }
276
277 private:
281 void init() FL_NO_EXCEPT override {
282 mController.init();
283 mController.setEnabled(false);
284 }
285
290 void ensureBuffer(fl::i32 num_leds) FL_NO_EXCEPT {
291 if (num_leds != mNumRGBLeds) {
292 mNumRGBLeds = num_leds;
293 // The delegate controller expects the raw pixel byte data in multiples of 3.
294 // In the case of src data not a multiple of 3, then we need to
295 // add pad bytes so that the delegate controller doesn't walk off the end
296 // of the array and invoke a buffer overflow panic.
297 fl::u32 new_size = Rgbw::size_as_rgb(num_leds);
298 mRGBWPixels.reset(new CRGB[new_size]); // ok bare allocation (array new)
299 // showPixels may never clear the last two pixels.
300 for (fl::u32 i = 0; i < new_size; i++) {
301 mRGBWPixels[i] = CRGB(0, 0, 0);
302 }
303
304 mController.setLeds(mRGBWPixels.get(), new_size);
305 }
306 }
307
309 fl::i32 mNumRGBLeds = 0;
310 fl::i32 mNumRGBWLeds = 0;
312};
313
317
326
327
328
330//
331// Clockless template instantiations - see clockless.h for how the timing values are used
332//
333
334#ifdef FL_CLOCKLESS_CONTROLLER_DEFINED
359
360// Allow clock that clockless controller is based on to have different
361// frequency than the CPU.
362#if !defined(CLOCKLESS_FREQUENCY)
363 #define CLOCKLESS_FREQUENCY F_CPU
364#endif
365
366// We want to force all avr's to use the Trinket controller when running at 8Mhz, because even the 328's at 8Mhz
367// need the more tightly defined timeframes.
368// Suppress -Wsubobject-linkage warning for controller template instantiations.
369// In C++11/14, constexpr variables have internal linkage, which causes the compiler
370// to warn when they are used in base classes of externally-linked templates. The macro
371// FL_INLINE_CONSTEXPR adds explicit 'inline' in C++17+ to resolve this, but for C++11
372// compatibility we suppress the warning here.
375
376
377
378
379// Legacy macro for nanoseconds to clock cycles conversion
380// This is no longer used by the core API but kept for backward compatibility
381#define FL_NANOSECONDS_TO_CLOCK_CYCLES(_NS) (((_NS * ((CLOCKLESS_FREQUENCY / 1000000L)) + 999)) / 1000)
382
383
384//
385// Given datasheet timing values T0H, T0L, T1H, T1L (in nanoseconds):
386//
387// duration = max(T0H + T0L, T1H + T1L) # Maximum cycle time
388// T1 = T0H # High time for '0' bit
389// T2 = T1H - T0H # Additional time for '1' bit
390// T3 = duration - T1H # Tail time after '1' bit
391//
392// Example (WS2812B with T0H=400, T0L=850, T1H=850, T1L=400):
393// duration = 1250, T1 = 400, T2 = 450, T3 = 400
394//
395// For interactive conversion or validation, use: uv run ci/tools/led_timing_conversions.py
396// For automated testing of all chipsets: uv run ci/test_led_timing_conversion.py
397// For C++ check out
398// * converter: src/fl/clockless/timing_conversion.h
399// * tests: tests/fl/clockless/timing_conversion.cpp
400
401
404template <int DATA_PIN, EOrder RGB_ORDER = RGB>
405class GE8822Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_GE8822_800KHZ, RGB_ORDER, 4, false> {};
406
409template <int DATA_PIN, EOrder RGB_ORDER = RGB>
410class GW6205Controller400Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_GW6205_400KHZ, RGB_ORDER, 4, false> {};
411
414template <int DATA_PIN, EOrder RGB_ORDER = RGB>
415class GW6205Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_GW6205_800KHZ, RGB_ORDER> {};
416
419template <int DATA_PIN, EOrder RGB_ORDER = RGB>
420class UCS1903Controller400Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_UCS1903_400KHZ, RGB_ORDER> {};
421
424template <int DATA_PIN, EOrder RGB_ORDER = RGB>
425class UCS1903BController800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_UCS1903B_800KHZ, RGB_ORDER> {};
426
429template <int DATA_PIN, EOrder RGB_ORDER = RGB>
430class UCS1904Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_UCS1904_800KHZ, RGB_ORDER> {};
431
434template <int DATA_PIN, EOrder RGB_ORDER = RGB>
435class UCS2903Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_UCS2903, RGB_ORDER> {};
436
437// Template wrapper to adapt ClocklessControllerImpl (6-param template alias)
438// to the 3-param template template parameter expected by UCS7604ControllerT
439namespace {
440 template<int DATA_PIN, typename TIMING, EOrder RGB_ORDER>
441 class ClocklessControllerWrapper : public fl::ClocklessControllerImpl<DATA_PIN, TIMING, RGB_ORDER> {};
442}
443
446template <int DATA_PIN, EOrder RGB_ORDER = RGB>
448
451template <int DATA_PIN, EOrder RGB_ORDER = RGB>
453
456template <int DATA_PIN, EOrder RGB_ORDER = RGB>
458
461template <int DATA_PIN, EOrder RGB_ORDER = RGB>
462class TM1809Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_TM1809_800KHZ, RGB_ORDER> {};
463
466template <int DATA_PIN, EOrder RGB_ORDER = RGB>
467class TM1908Controller
468 : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_TM1908,
469 RGB_ORDER, 0, false,
470 fl::TIMING_TM1908::RESET> {};
471
475template <int DATA_PIN, EOrder RGB_ORDER = GRB>
476class WS2811Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2811_800KHZ_LEGACY, RGB_ORDER> {};
477
480template <int DATA_PIN, EOrder RGB_ORDER = GRB>
481class WS2813Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2813, RGB_ORDER> {};
482
486template <int DATA_PIN, EOrder RGB_ORDER = RGB>
487class WS2814Controller : public fl::detail::FixedRgbwController<
488 fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2814,
489 RGB_ORDER, 0, false,
490 fl::TIMING_WS2814::RESET>> {};
491
494template <int DATA_PIN, EOrder RGB_ORDER = GRB>
495class WS2818Controller
496 : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2818,
497 RGB_ORDER, 0, false,
498 fl::TIMING_WS2818::RESET> {};
499
504#if !FASTLED_WS2812_HAS_SPECIAL_DRIVER
505template <int DATA_PIN, EOrder RGB_ORDER = GRB>
506class WS2812Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2812_800KHZ, RGB_ORDER> {};
507#endif
508
514template <int DATA_PIN, EOrder RGB_ORDER = GRB>
515class OSTW2020C1EController
516 : public fl::ClocklessControllerImpl<DATA_PIN,
517 fl::TIMING_WS2812_800KHZ,
518 RGB_ORDER, 0, false, 300> {};
519
523template <int DATA_PIN, EOrder RGB_ORDER = GRB>
524class WS2812BMiniV3Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2812B_MINI_V3, RGB_ORDER> {};
525
529template <int DATA_PIN, EOrder RGB_ORDER = GRB>
530class WS2812BV5Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2812B_V5, RGB_ORDER> {};
531
535template <int DATA_PIN, EOrder RGB_ORDER = GRB>
536class WS2811Controller400Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2811_400KHZ, RGB_ORDER> {};
537
540template <int DATA_PIN, EOrder RGB_ORDER = GRB>
541class WS2815Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_WS2815, RGB_ORDER> {};
542
545template <int DATA_PIN, EOrder RGB_ORDER = RGB>
546class DP1903Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_DP1903_800KHZ, RGB_ORDER> {};
547
550template <int DATA_PIN, EOrder RGB_ORDER = RGB>
551class DP1903Controller400Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_DP1903_400KHZ, RGB_ORDER> {};
552
555template <int DATA_PIN, EOrder RGB_ORDER = RGB>
556class TM1803Controller400Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_TM1803_400KHZ, RGB_ORDER> {};
557
564template <int DATA_PIN, EOrder RGB_ORDER = RGB>
565class TM1829Controller800Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_TM1829_800KHZ, RGB_ORDER, 0, true, 500> {};
566
570template <int DATA_PIN, EOrder RGB_ORDER = RGB>
571class TM1829Controller1600Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_TM1829_1600KHZ, RGB_ORDER, 0, true, 500> {};
572
575template <int DATA_PIN, EOrder RGB_ORDER = RGB>
576class LPD1886Controller1250Khz : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_LPD1886_1250KHZ, RGB_ORDER> {};
577
580template <int DATA_PIN, EOrder RGB_ORDER = RGB>
581class LPD1886Controller1250Khz_8bit : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_LPD1886_1250KHZ, RGB_ORDER> {};
582
583
586template <int DATA_PIN, EOrder RGB_ORDER = RGB>
587class SK6822Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_SK6822, RGB_ORDER> {};
588
591template <int DATA_PIN, EOrder RGB_ORDER = RGB>
592class SK6812Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_SK6812, RGB_ORDER> {};
593
597template <int DATA_PIN, EOrder RGB_ORDER = GRB>
598class LC8816EController : public fl::detail::FixedRgbwController<
599 fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_LC8816E,
600 RGB_ORDER, 0, false,
601 fl::TIMING_LC8816E::RESET>> {};
602
605template <int DATA_PIN, EOrder RGB_ORDER = RGB>
606class SM16703Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_SM16703, RGB_ORDER> {};
607
610template <int DATA_PIN, EOrder RGB_ORDER = RGB>
611class GS1903Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_GS1903, RGB_ORDER> {};
612
615template <int DATA_PIN, EOrder RGB_ORDER = RGB>
616class PL9823Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_PL9823, RGB_ORDER> {};
617
621template <int DATA_PIN, EOrder RGB_ORDER = RGB>
622class UCS1912Controller : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_UCS1912, RGB_ORDER> {};
623
628template <int DATA_PIN, EOrder RGB_ORDER = RGB>
629class SM16824EController : public fl::ClocklessControllerImpl<DATA_PIN, fl::TIMING_SM16824E, RGB_ORDER> {};
630
633
634
635// WS2816 - is an emulated controller that emits 48 bit pixels by forwarding
636// them to a platform specific WS2812 controller. The WS2812 controller
637// has to output twice as many 24 bit pixels.
638template <EOrder RGB_ORDER, typename DELEGATE>
639class WS2816ControllerImpl
640 : public CPixelLEDController<RGB_ORDER,
641 DELEGATE::LANES_VALUE,
642 DELEGATE::MASK_VALUE> {
643
644public:
645 using ControllerBaseT = DELEGATE;
646 template<fl::Bus B>
647 using WithBus = WS2816ControllerImpl<RGB_ORDER,
648 typename fl::detail::ClocklessBusController<ControllerBaseT, B>::type>;
649
650 // ControllerT is a helper class. It subclasses the device controller class
651 // and has three methods to call the three protected methods we use.
652 // This is janky, but redeclaring public methods protected in a derived class
653 // is janky, too.
654
655 // N.B., byte order must be RGB.
656 class ControllerT : public ControllerBaseT {
657 friend class WS2816ControllerImpl<RGB_ORDER, ControllerBaseT>;
658 void *callBeginShowLeds(int size) FL_NO_EXCEPT { return ControllerBaseT::beginShowLeds(size); }
659 void callShow(CRGB *data, int nLeds, fl::u8 brightness) FL_NO_EXCEPT {
660 ControllerBaseT::show(data, nLeds, brightness);
661 }
662 void callEndShowLeds(void *data) FL_NO_EXCEPT { ControllerBaseT::endShowLeds(data); }
663 };
664
665 static const int LANES = ControllerT::LANES_VALUE;
666 static const fl::u32 MASK = ControllerT::MASK_VALUE;
667
668#if defined(FASTLED_TESTING)
669 const ControllerT& getDelegateForTesting() const FL_NO_EXCEPT {
670 return mController;
671 }
672#endif
673
674 WS2816ControllerImpl() FL_NO_EXCEPT {}
675 ~WS2816ControllerImpl() {
676 mController.setLeds(nullptr, 0);
677 }
678
679 VIRTUAL_IF_NOT_AVR void *beginShowLeds(int size) FL_NO_EXCEPT OVERRIDE_IF_NOT_AVR {
680 mController.setEnabled(true);
681 void *result = mController.callBeginShowLeds(2 * size);
682 mController.setEnabled(false);
683 return result;
684 }
685
686 VIRTUAL_IF_NOT_AVR void endShowLeds(void *data) FL_NO_EXCEPT OVERRIDE_IF_NOT_AVR {
687 mController.setEnabled(true);
688 mController.callEndShowLeds(data);
689 mController.setEnabled(false);
690 }
691
692 virtual void showPixels(PixelController<RGB_ORDER, LANES, MASK> &pixels) FL_NO_EXCEPT override {
693 // Ensure buffer is large enough
694 ensureBuffer(pixels.size());
695
696 // Create PixelIterator from PixelController (WS2816 is RGB-only, no W channel)
697 fl::PixelIterator pixel_iter = pixels.as_iterator(fl::RgbwInvalid::value());
698
699 // Create 16-bit RGB iterator range (handles RGB reordering, scaling, brightness)
700 auto rgb16_range = fl::makeScaledPixelRangeRGB16(&pixel_iter);
701
702 // Encode 16-bit RGB pixels to dual 8-bit CRGB format
703 fl::encodeWS2816(rgb16_range.first, rgb16_range.second, mData.get());
704
705 // Ensure device controller won't modify color values
706 mController.setCorrection(CRGB(255, 255, 255));
707 mController.setTemperature(CRGB(255, 255, 255));
708 mController.setDither(DISABLE_DITHER);
709
710 // Output the data stream
711 mController.setEnabled(true);
712 mController.callShow(mData.get(), 2 * pixels.size(), 255);
713 mController.setEnabled(false);
714 }
715
716private:
717 void init() FL_NO_EXCEPT override {
718 mController.init();
719 mController.setEnabled(false);
720 }
721
722 void ensureBuffer(int size_8bit) FL_NO_EXCEPT {
723 int size_16bit = 2 * size_8bit;
724 if (mController.size() != size_16bit) {
725
726 auto new_leds = fl::make_unique<CRGB[]>(size_16bit);
727 mData = fl::move(new_leds);
728 mController.setLeds(mData.get(), size_16bit);
729 }
730 }
731
732 fl::unique_ptr<CRGB[]> mData;
733 ControllerT mController;
734};
735
736template <int DATA_PIN, EOrder RGB_ORDER = GRB>
737class WS2816Controller : public WS2816ControllerImpl<
738 RGB_ORDER, WS2812Controller800Khz<DATA_PIN, RGB>> {};
739
740
741#endif
742
753
754#if defined(FL_IS_SILABS)
755
756#include "platforms/arm/mgm240/clockless_ezws2812_gpio.h" // ok platform headers
757
769template<fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
770using EZWS2812_GPIO = fl::ClocklessController_ezWS2812_GPIO_Auto<DATA_PIN, RGB_ORDER>;
771
772#ifdef FASTLED_USES_EZWS2812_SPI
773
774#include "platforms/arm/mgm240/clockless_ezws2812_spi.h" // ok platform headers
775#include "fl/stl/noexcept.h"
776
794template<EOrder RGB_ORDER = GRB>
795using EZWS2812_SPI = fl::ClocklessController_ezWS2812_SPI<RGB_ORDER>;
796
797#endif // FASTLED_USES_EZWS2812_SPI
798
799#endif // ARDUINO_ARCH_SILABS
800
802
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define DATA_PIN
Definition ClientReal.h:82
#define RGB_ORDER
WS2812< DATA_PIN, RGB > ControllerT
Rgbw rgbw
void mark() FL_NO_EXCEPT
Reset the timestamp that marks the start of the wait period.
void wait() FL_NO_EXCEPT
Blocking delay until WAIT time since mark() has passed.
Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not e...
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels) FL_NO_EXCEPT=0
Send the LED data to the strip.
Template extension of the CLEDController class.
CLEDController & setRgbw(const Rgbw &arg=RgbwDefault::value()) FL_NO_EXCEPT
VIRTUAL_IF_NOT_AVR int size() const FL_NO_EXCEPT
How many LEDs does this controller manage?
CLEDController & setLeds(CRGB *data, int nLeds) FL_NO_EXCEPT
Set the default array of LEDs to be used by this controller.
Rgbw getRgbw() const FL_NO_EXCEPT
virtual void init() FL_NO_EXCEPT=0
Initialize the LED controller.
Keep fixed RGBW behavior around both the original and rebound transport.
Legacy header.
#define DISABLE_DITHER
Disable dithering.
Definition dither_mode.h:14
fl::EOrder EOrder
Definition eorder.h:12
constexpr EOrder GRB
Definition eorder.h:19
constexpr EOrder RGB
Definition eorder.h:17
Defines color channel ordering enumerations.
Declares functions for five-bit gamma correction.
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels) FL_NO_EXCEPT override
Main rendering function that converts RGB to RGBW and shows pixels.
Definition chipsets.h:247
fl::i32 mNumRGBLeds
Number of RGB LEDs in the original array.
Definition chipsets.h:309
~RGBWEmulatedController()=default
Destructor - cleans up the internal RGBW buffer.
FL_STATIC_ASSERT(RGB==CONTROLLER::RGB_ORDER_VALUE, "The delegated controller MUST NOT do reordering")
void * callBeginShowLeds(int size) FL_NO_EXCEPT
Definition chipsets.h:209
VIRTUAL_IF_NOT_AVR void endShowLeds(void *data) FL_NO_EXCEPT OVERRIDE_IF_NOT_AVR
Definition chipsets.h:236
VIRTUAL_IF_NOT_AVR void * beginShowLeds(int size) FL_NO_EXCEPT OVERRIDE_IF_NOT_AVR
Definition chipsets.h:232
ControllerT mController
The underlying RGB controller instance.
Definition chipsets.h:311
fl::unique_ptr< CRGB[]> mRGBWPixels
Internal buffer for packed RGBW data.
Definition chipsets.h:308
static const int LANES
Definition chipsets.h:217
void ensureBuffer(fl::i32 num_leds) FL_NO_EXCEPT
Ensures the internal RGBW buffer is large enough for the LED count.
Definition chipsets.h:290
RGBWEmulatedController(const Rgbw &rgbw=RgbwDefault()) FL_NO_EXCEPT
Constructor with optional RGBW configuration.
Definition chipsets.h:225
fl::i32 mNumRGBWLeds
Number of RGBW pixels the buffer can hold.
Definition chipsets.h:310
void init() FL_NO_EXCEPT override
Initialize the controller and disable the base controller.
Definition chipsets.h:281
static const fl::u32 MASK
Definition chipsets.h:218
void callShow(CRGB *data, int nLeds, fl::u8 brightness) FL_NO_EXCEPT
Definition chipsets.h:210
void callEndShowLeds(void *data) FL_NO_EXCEPT
Definition chipsets.h:213
CONTROLLER ControllerBaseT
Definition chipsets.h:206
fl::CRGB CRGB
Definition crgb.h:25
Centralized LED chipset timing definitions with nanosecond precision.
MY9221 12-channel LED driver controller.
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition move.h:30
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args) FL_NO_EXCEPT
Definition unique_ptr.h:263
unsigned char u8
Definition stdint.h:132
void encodeWS2816(InputIterator first, InputIterator last, OutputIterator out) FL_NO_EXCEPT
Encode 16-bit RGB pixel data into dual 8-bit RGB format for WS2816.
Definition ws2816.h:62
UCS7604ControllerT< DATA_PIN, RGB_ORDER, fl::UCS7604Mode::UCS7604_MODE_16BIT_800KHZ, fl::TIMING_UCS7604_800KHZ, CLOCKLESS_CONTROLLER > UCS7604Controller16bitT
Definition ucs7604.h:202
void init(Context &ctx, int w, int h) FL_NO_EXCEPT
Definition engine.h:133
pair< detail::ScaledPixelIteratorRGB16, detail::ScaledPixelIteratorRGB16 > makeScaledPixelRangeRGB16(PixelIterator *pixels) FL_NO_EXCEPT
Create 16-bit RGB input iterator range from PixelIterator.
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
UCS7604ControllerT< DATA_PIN, RGB_ORDER, fl::UCS7604Mode::UCS7604_MODE_8BIT_800KHZ, fl::TIMING_UCS7604_800KHZ, CLOCKLESS_CONTROLLER > UCS7604Controller8bitT
Definition ucs7604.h:199
To * bit_cast_ptr(void *storage) FL_NO_EXCEPT
Definition bit_cast.h:60
UCS7604ControllerT< DATA_PIN, RGB_ORDER, fl::UCS7604Mode::UCS7604_MODE_16BIT_1600KHZ, fl::TIMING_UCS7604_1600KHZ, CLOCKLESS_CONTROLLER > UCS7604Controller16bit1600T
Definition ucs7604.h:205
Legacy header.
Includes defintions for RGB and HSV pixels.
#define VIRTUAL_IF_NOT_AVR
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
#define OVERRIDE_IF_NOT_AVR
#define FL_NO_EXCEPT
#define FL_DISABLE_WARNING_SUBOBJECT_LINKAGE
Portable compile-time assertion wrapper.
FASTLED_FORCE_INLINE bool has(int n) FL_NO_EXCEPT
Do we have n pixels left to process?
FASTLED_FORCE_INLINE void stepDithering() FL_NO_EXCEPT
Step the dithering forward - creates triangular wave that toggles between pixels.
FASTLED_FORCE_INLINE fl::u8 loadAndScale1(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE void advanceData() FL_NO_EXCEPT
Advance the data pointer forward, adjust position counter.
FASTLED_FORCE_INLINE fl::u8 loadAndScale0(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE fl::u8 loadAndScale2(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of loadAndScale<2>()
Pixel controller class.
static u32 size_as_rgb(u32 num_of_rgbw_pixels) FL_NO_EXCEPT
Definition rgbw.h:262
static Rgbw value() FL_NO_EXCEPT
Definition rgbw.h:279
#define Serial
Definition serial.h:314
UCS7604 LED chipset controller implementation for FastLED.
WS2816 encoder - converts 16-bit RGB pixels to dual 8-bit RGB format.