FastLED 3.9.15
Loading...
Searching...
No Matches
channel_typed.h
Go to the documentation of this file.
1#pragma once
2
24
25#include "fl/channels/bus.h"
27#include "fl/channels/channel.h"
28#include "fl/channels/config.h"
29#include "fl/stl/noexcept.h"
31#include "fl/stl/type_traits.h"
32
33namespace fl {
34
35namespace detail {
36
39template<Bus B, typename Chipset>
41 static constexpr Bus value = B;
42};
43
44template<typename Chipset>
45struct resolve_bus<Bus::AUTO, Chipset> {
47};
48
49} // namespace detail
50
63template<Bus B, typename Chipset>
65public:
68
69 // Compile-time contract: the named bus must accept this chipset family.
70 //
71 // The diagnostic message (suppressed on pre-C++17 toolchains by
72 // FL_STATIC_ASSERT) describes the contract: route ClocklessChipset to a
73 // clockless bus (RMT/PARLIO/I2S/...) and SpiChipsetConfig to an SPI bus.
76 "TypedChannel: Bus does not support this Chipset family");
77
83 static ChannelPtr create(const ChannelConfigOf<Chipset>& cfg) FL_NOEXCEPT {
84 // Naming `BusTraits<kBus>::instance` here is the ODR-use that links
85 // the driver translation unit even in the static-only `--gc-sections`
86 // mode (issue #2428 Phase 5 binary-size fix).
88 ChannelConfig erased = cfg.toErased();
89 return Channel::create(erased);
90 }
91
98 static ChannelPtr create(const ChannelConfig& cfg) FL_NOEXCEPT {
100 return Channel::create(cfg);
101 }
102
103private:
105};
106
107} // namespace fl
Compile-time identifier for an LED channel transmission bus.
Per-driver traits keyed on fl::Bus.
ESP32-P4 Parallel IO (PARLIO) LED channel.
static ChannelPtr create(const ChannelConfigOf< Chipset > &cfg) FL_NOEXCEPT
Construct a runtime Channel from a typed configuration.
TypedChannel() FL_NOEXCEPT=delete
static ChannelPtr create(const ChannelConfig &cfg) FL_NOEXCEPT
Overload accepting the (type-erased) non-template config.
FL_STATIC_ASSERT(BusSupports< kBus, Chipset >::value, "TypedChannel: Bus does not support this Chipset family")
static constexpr Bus kBus
The bus actually used after resolving Bus::AUTO.
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
FL_DISABLE_WARNING_PUSH unsigned char * B
Bus
Driver identifier for compile-time bus selection.
Definition bus.h:60
@ AUTO
Sentinel: defer to DefaultBus<Chipset>::value.
Definition bus.h:61
Base definition for an LED controller.
Definition crgb.hpp:179
Primary template — intentionally undefined.
Definition bus_traits.h:30
Per-platform default bus for a given chipset family.
Definition bus.h:88
#define FL_NOEXCEPT
Portable compile-time assertion wrapper.
Configuration for a single LED channel.
Definition config.h:163
Strongly-typed channel configuration with compile-time chipset family.
Definition config.h:303
static constexpr Bus value
Resolve a possibly-Bus::AUTO template argument to the concrete platform default for the given Chipset...