FastLED 3.10.10
Loading...
Searching...
No Matches
channel_typed.h
Go to the documentation of this file.
1#pragma once
2
28
29#include "fl/channels/bus.h"
31#include "fl/channels/channel.h"
32#include "fl/channels/config.h"
33#include "fl/log/log.h"
34#include "fl/stl/noexcept.h"
36#include "fl/stl/type_traits.h"
37
38namespace fl {
39
40namespace detail {
41
44template<Bus B, typename Chipset>
46 static constexpr Bus value = B;
47};
48
49template<typename Chipset>
50struct resolve_bus<Bus::AUTO, Chipset> {
52};
53
54} // namespace detail
55
68template<Bus B, typename Chipset, fl::u8 Which = 0>
70public:
73
74 // Compile-time contract: the named bus must accept this chipset family.
75 //
76 // The diagnostic message (suppressed on pre-C++17 toolchains by
77 // FL_STATIC_ASSERT) describes the contract: route ClocklessChipset to a
78 // clockless bus (RMT/PARLIO/I2S/...) and SpiChipsetConfig to an SPI bus.
81 "TypedChannel: Bus does not support this Chipset family");
82
88 static ChannelPtr create(const ChannelConfigOf<Chipset>& cfg) FL_NO_EXCEPT {
89 // Register only the compile-time-selected bus specialization and its
90 // associated driver(s). This retains the required translation unit(s)
91 // without pulling in enableAllDrivers().
94 ChannelConfig erased = cfg.toErased();
95 erased.options.mBus = kBus;
96 erased.options.mBusWhich = Which;
97 return Channel::create(erased);
98 }
99
106 static ChannelPtr create(const ChannelConfig& cfg) FL_NO_EXCEPT {
107 if (!cfg.getChipset().is<Chipset>()) {
108 FL_ERROR("TypedChannel: configuration does not match the selected chipset family");
109 return nullptr;
110 }
113 ChannelConfig erased = cfg;
114 erased.options.mBus = kBus;
115 erased.options.mBusWhich = Which;
116 return Channel::create(erased);
117 }
118
119private:
121};
122
123} // namespace fl
Portable compile-time identifiers for LED channel buses.
Per-driver traits keyed on fl::Bus.
ESP32-P4 Parallel IO (PARLIO) LED channel.
static ChannelPtr create(const ChannelConfigOf< Chipset > &cfg) FL_NO_EXCEPT
Construct a runtime Channel from a typed configuration.
TypedChannel() FL_NO_EXCEPT=delete
static ChannelPtr create(const ChannelConfig &cfg) FL_NO_EXCEPT
Overload accepting the (type-erased) non-template config.
static constexpr Bus kBus
The bus actually used after resolving Bus::AUTO.
FL_STATIC_ASSERT(BusSupports< kBus, Chipset, Which >::value, "TypedChannel: Bus does not support this Chipset family")
#define FL_ERROR(...)
Definition log.h:373
Centralized logging categories for FastLED hardware interfaces and subsystems.
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
Bus
Portable public bus selector.
Definition bus.h:31
@ AUTO
Definition bus.h:32
Base definition for an LED controller.
Primary template — intentionally undefined.
Definition bus_traits.h:31
Portable compile-time assertion wrapper.
ChannelOptions options
Optional channel settings (correction, temperature, dither, rgbw, affinity)
Definition config.h:277
Configuration for a single LED channel.
Definition config.h:167
Strongly-typed channel configuration with compile-time chipset family.
Definition config.h:307
enable_clockless<Traits>() only for the clockless chipset family.
Definition bus_traits.h:76
static constexpr Bus value
Resolve a possibly-Bus::AUTO template argument to the concrete platform default for the given Chipset...