FastLED 3.10.8
Loading...
Searching...
No Matches
bus_traits.h
Go to the documentation of this file.
1#pragma once
2
17
18#include "fl/channels/bus.h"
19#include "fl/stl/noexcept.h"
20#include "fl/stl/type_traits.h"
21
22namespace fl {
23
31template<fl::Bus B, fl::u8 Which = 0> struct BusTraits;
32
46template<fl::Bus B, typename Chipset, fl::u8 Which = 0>
48
49namespace detail {
50
56template<typename Traits>
58 -> decltype(Traits::enableClockless(), void()) {
59 Traits::enableClockless();
60}
61template<typename Traits>
63template<typename Traits>
67
70template<typename Chipset, typename Traits>
72 static void apply() FL_NO_EXCEPT {}
73};
74template<typename Traits>
78
82
83template<Bus B, fl::u8 Which = 0>
85 // Explicitly enabling a bus makes it eligible for clockless channels too.
88 return 0;
89}
90
91} // namespace detail
92
111template<Bus... Buses>
113 // C++11-compatible pack expansion via array initializer trick.
114 using expand = int[];
115 (void)expand{0, detail::bus_register_one<Buses>()...};
116}
117
118template<Bus B, fl::u8 Which = 0>
122
131namespace detail {
132
133template<fl::Bus B, fl::u8 Which = 0>
135 static inline void odr_use() FL_NO_EXCEPT {
136 // ODR-use the singleton accessor's address — sufficient to keep
137 // the driver TU alive. We do NOT call `instance()` here because
138 // some platforms construct the driver eagerly inside the Meyers
139 // singleton and we want `Bus::X`-tagged `addLeds<>` to behave as
140 // a pure compile-time annotation (no runtime side effect beyond
141 // the linker keep-alive itself).
143 }
144};
145
146template<fl::u8 Which>
148 static inline void odr_use() FL_NO_EXCEPT {} // AUTO: no pinning, no ODR-use.
149};
150
151} // namespace detail
152
153template<fl::Bus B, fl::u8 Which = 0>
157
158} // namespace fl
Portable compile-time identifiers for LED channel buses.
int bus_register_one() FL_NO_EXCEPT
Helper used by enableDrivers<Bus...>() to expand the parameter pack.
Definition bus_traits.h:84
auto enable_clockless_impl(int) FL_NO_EXCEPT -> decltype(Traits::enableClockless(), void())
Call Traits::enableClockless() when the bus provides one.
Definition bus_traits.h:57
void enable_clockless() FL_NO_EXCEPT
Definition bus_traits.h:64
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
integral_constant< bool, false > false_type
Definition type_traits.h:29
void busKeepAlive() FL_NO_EXCEPT
Definition bus_traits.h:154
Bus
Portable public bus selector.
Definition bus.h:27
@ AUTO
Definition bus.h:28
void enableDrivers() FL_NO_EXCEPT
Register the named drivers with ChannelManager for runtime selection.
Definition bus_traits.h:112
void enableDriver() FL_NO_EXCEPT
Definition bus_traits.h:119
Base definition for an LED controller.
Definition crgb.hpp:179
Primary template — intentionally undefined.
Definition bus_traits.h:31
Capability check: does bus B accept chipset family Chipset?
Definition bus_traits.h:47
Clockless chipset configuration (single data pin)
Definition config.h:33
static void odr_use() FL_NO_EXCEPT
Definition bus_traits.h:135
static void apply() FL_NO_EXCEPT
Definition bus_traits.h:72
enable_clockless<Traits>() only for the clockless chipset family.
Definition bus_traits.h:71