FastLED 3.10.10
Loading...
Searching...
No Matches
driver_bindings.h
Go to the documentation of this file.
1#pragma once
2
21
22#include "fl/channels/bus.h"
24#include "fl/stl/int.h"
25#include "fl/stl/noexcept.h"
26#include "fl/stl/type_traits.h"
27
28namespace fl {
29
38
41public:
43
46
49 bool bind(Bus bus, u8 which) FL_NO_EXCEPT;
50
51 bool empty() const FL_NO_EXCEPT { return mHead == nullptr; }
52
53private:
54 DriverBinding* mHead = nullptr;
55};
56
57namespace detail {
58
59template<Bus B, typename Chipset, u8 Which>
60struct BusBinding {
61 static constexpr Bus kBus =
63
68
70 static DriverBinding sNode = {kBus, Which, &BusBinding::bind,
71 nullptr, false}; // okay static in header
72 return sNode;
73 }
74};
75
78template<typename Chipset, typename = void>
80
81template<typename Chipset>
82struct HasDefaultBus<Chipset, decltype(void(DefaultBus<Chipset>::value))>
83 : fl::true_type {};
84
85template<typename Chipset>
90
91template<typename Chipset>
93 return false; // no platform default: nothing to bind
94}
95
98template<typename Chipset>
102
105template<Bus B, typename Chipset>
108 B != Bus::AUTO || HasDefaultBus<Chipset>::value> {};
109
110template<Bus B, typename Chipset, u8 Which>
114
115template<Bus B, typename Chipset, u8 Which>
116inline void bindDriverImpl(fl::false_type) FL_NO_EXCEPT {} // no default bus
117
118} // namespace detail
119
123template<Bus B, typename Chipset = ClocklessChipset, u8 Which = 0>
128
129} // namespace fl
Portable compile-time identifiers for LED channel buses.
Per-driver traits keyed on fl::Bus.
bool empty() const FL_NO_EXCEPT
DriverBinding * mHead
void push(DriverBinding &node) FL_NO_EXCEPT
Self-add a node. Idempotent: a node already listed is ignored.
bool bind(Bus bus, u8 which) FL_NO_EXCEPT
Bind (register) every node matching bus/which, or every node when bus is Bus::AUTO.
static DriverBindings & instance() FL_NO_EXCEPT
Process-wide list of enabled buses.
void bindDriverImpl(fl::true_type) FL_NO_EXCEPT
bool bindDefaultDriverImpl(fl::true_type) FL_NO_EXCEPT
bool bindDefaultDriver() FL_NO_EXCEPT
Bind the platform default driver for Chipset, if one exists.
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
integral_constant< bool, true > true_type
Definition s16x16x4.h:28
integral_constant< bool, false > false_type
Definition s16x16x4.h:29
unsigned char u8
Definition stdint.h:132
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Bus
Portable public bus selector.
Definition bus.h:31
@ AUTO
Definition bus.h:32
void bindDriver() FL_NO_EXCEPT
Enable one bus for FastLED.add(cfg).
Base definition for an LED controller.
DriverBinding * next
void(* bind)()
registers the driver with ChannelManager
One enabled bus. Static storage, linked intrusively; never heap.
Primary template — intentionally undefined.
Definition bus_traits.h:31
static DriverBinding & node() FL_NO_EXCEPT
static void bind() FL_NO_EXCEPT
static constexpr Bus kBus
False only for Bus::AUTO on a platform with no DefaultBus<Chipset>: there is no bus to name,...
True when the platform specializes DefaultBus<Chipset>.
enable_clockless<Traits>() only for the clockless chipset family.
Definition bus_traits.h:76