FastLED 3.9.15
Loading...
Searching...
No Matches
LegacyClocklessProxy.h
Go to the documentation of this file.
1// LegacyClocklessProxy.h - Runtime-to-template pin dispatch for legacy addLeds API
2//
3// Maps a runtime pin number (0-8) to compile-time WS2812B<PIN, RGB> template
4// instantiations via a switch statement. This allows autoresearch testing of the
5// legacy template API path: WS2812B<PIN> -> WS2812Controller800Khz ->
6// ClocklessControllerImpl -> ClocklessIdf5 -> Channel
7
8#pragma once
9
10#include <FastLED.h>
11#include "fl/stl/unique_ptr.h"
12
26
27 template<int PIN>
30 FastLED.addLeds(c.get(), leds, numLeds);
31 return c;
32 }
33
34public:
35 LegacyClocklessProxy(int pin, CRGB* leds, int numLeds) {
36 switch (pin) {
37 case 0: mController = create<0>(leds, numLeds); break;
38 case 1: mController = create<1>(leds, numLeds); break;
39 case 2: mController = create<2>(leds, numLeds); break;
40 case 3: mController = create<3>(leds, numLeds); break;
41 case 4: mController = create<4>(leds, numLeds); break;
42 case 5: mController = create<5>(leds, numLeds); break;
43 case 6: mController = create<6>(leds, numLeds); break;
44 case 7: mController = create<7>(leds, numLeds); break;
45 case 8: mController = create<8>(leds, numLeds); break;
46 default: break; // mController stays nullptr
47 }
48 }
49
51
52 // Non-copyable (unique_ptr already enforces this, but be explicit)
55
57 bool valid() const { return mController != nullptr; }
58};
fl::CRGB leds[NUM_LEDS]
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::unique_ptr< CLEDController > mController
fl::unique_ptr< CLEDController > create(CRGB *leds, int numLeds)
LegacyClocklessProxy(int pin, CRGB *leds, int numLeds)
LegacyClocklessProxy(const LegacyClocklessProxy &)=delete
bool valid() const
Check if the proxy was successfully created.
LegacyClocklessProxy & operator=(const LegacyClocklessProxy &)=delete
~LegacyClocklessProxy()=default
fl::CRGB CRGB
Definition crgb.h:25
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args) FL_NOEXCEPT
Definition unique_ptr.h:261