Variant type that holds either a clockless or SPI chipset configuration.
Variant type that holds either a clockless or SPI chipset configuration This allows ChannelConfig to support both chipset types with compile-time type safety and runtime polymorphism via the visitor pattern.
#pragma once
#include "crgb.h"
#include "color.h"
struct ClocklessChipset {
return pin == other.pin &&
}
return !(*this == other);
}
};
template <typename TIMING>
}
struct SpiChipsetConfig {
}
return !(*this == other);
}
};
using ChipsetVariant = fl::variant<ClocklessChipset, SpiChipsetConfig>;
struct ChannelConfig {
template<typename TIMING>
const ChannelOptions&
options = ChannelOptions())
};
template<typename Chipset>
struct ChannelConfigOf {
}
return cfg;
}
};
struct MultiChannelConfig {
};
}
Runtime chipset timing configuration for clockless LED drivers.
SPI encoder configuration for clocked LED chipsets.
u32 getLength() const FL_NOEXCEPT
iterator begin() FL_NOEXCEPT
iterator end() FL_NOEXCEPT
Encoding pipeline selector for clockless LED chipsets.
Declares dithering options and types.
Functions for red, green, blue, white (RGBW) output.
ClocklessEncoder
Identifies which encoder to use for clockless chipsets in the Channel API.
@ CLOCKLESS_ENCODER_WS2812
Default, no preamble (WS2812 and compatible)
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > map
constexpr ClocklessChipset makeClockless(int pin) FL_NOEXCEPT
Build a ClocklessChipset from a compile-time TIMING trait.
constexpr ChipsetTimingConfig makeTimingConfig() FL_NOEXCEPT
Convert compile-time CHIPSET type to runtime timing config.
fl::variant< ClocklessChipset, SpiChipsetConfig > ChipsetVariant
constexpr ClocklessEncoder encoder_for() FL_NOEXCEPT
Extract the encoder selector from a compile-time TIMING type.
@ APA102
APA102 LED chipset.
Base definition for an LED controller.
#define FASTLED_SHARED_PTR_STRUCT(type)
const fl::ScreenMap & getScreenMap() const FL_NOEXCEPT
Get screen map for JS canvas visualization.
fl::optional< fl::string > mName
Optional user-specified name (if not set, Channel generates one automatically)
ChannelConfig & operator=(const ChannelConfig &) FL_NOEXCEPT=delete
bool isSpi() const FL_NOEXCEPT
Check if this is an SPI chipset.
const ChipsetVariant & getChipset() const FL_NOEXCEPT
Get the chipset configuration variant.
const ClocklessChipset * getClocklessChipset() const FL_NOEXCEPT
Get clockless chipset (returns nullptr if not clockless)
bool hasScreenMap() const FL_NOEXCEPT
Check if screen map is configured.
const SpiChipsetConfig * getSpiChipset() const FL_NOEXCEPT
Get SPI chipset (returns nullptr if not SPI)
int getDataPin() const FL_NOEXCEPT
Get data pin (works for both clockless and SPI)
void setScreenMap(const fl::ScreenMap &map) FL_NOEXCEPT
Set screen map for JS canvas visualization.
fl::ScreenMap mScreenMap
Screen mapping.
ChannelOptions options
Optional channel settings (correction, temperature, dither, rgbw, affinity)
fl::span< CRGB > mLeds
LED data array.
bool isClockless() const FL_NOEXCEPT
Check if this is a clockless chipset.
ChannelConfig(const fl::string &name, const ChipsetVariant &chipset, fl::span< CRGB > leds, EOrder rgbOrder=RGB, const ChannelOptions &options=ChannelOptions()) FL_NOEXCEPT
Named constructor with chipset variant.
ChipsetVariant chipset
Chipset configuration (clockless or SPI)
int getClockPin() const FL_NOEXCEPT
Get clock pin (returns -1 for clockless chipsets)
EOrder rgb_order
RGB channel ordering.
ChannelConfig toErased() const FL_NOEXCEPT
Convenience: build the erased form by value (handy in templates where the implicit conversion is supp...
ChannelConfigOf(const Chipset &chipset, fl::span< CRGB > leds, EOrder rgbOrder=RGB, const ChannelOptions &options=ChannelOptions()) FL_NOEXCEPT
Construct from a typed chipset, LEDs span, and optional metadata.
fl::ScreenMap mScreenMap
Screen mapping (for JS canvas visualization).
fl::span< CRGB > mLeds
LED data span.
ChannelOptions options
Optional channel settings (correction, temperature, dither, rgbw, affinity).
fl::optional< fl::string > mName
Optional user-specified name. If unset, Channel auto-generates one.
EOrder rgb_order
RGB channel ordering.
Chipset chipset
Typed chipset configuration.
bool operator!=(const ClocklessChipset &other) const FL_NOEXCEPT
Inequality operator.
ChipsetTimingConfig timing
T1/T2/T3 timing parameters.
ClocklessChipset & operator=(const ClocklessChipset &) FL_NOEXCEPT=default
Copy assignment.
ClocklessEncoder encoder
Byte-level encoding pipeline (default: WS2812)
bool operator==(const ClocklessChipset &other) const FL_NOEXCEPT
Equality operator.
constexpr ClocklessChipset() FL_NOEXCEPT
Default constructor.
MultiChannelConfig & operator=(const MultiChannelConfig &) FL_NOEXCEPT=default
fl::vector< ChannelConfigPtr > mChannels
Vector of shared pointers to channel configurations.
MultiChannelConfig() FL_NOEXCEPT=default
~MultiChannelConfig() FL_NOEXCEPT=default
MultiChannelConfig & add(ChannelConfigPtr channel) FL_NOEXCEPT
Add a channel configuration to the multi-channel config.
SpiEncoder timing
SPI encoder configuration.
bool operator!=(const SpiChipsetConfig &other) const FL_NOEXCEPT
Inequality operator.
SpiChipsetConfig() FL_NOEXCEPT
Default constructor (requires explicit protocol specification)
int clockPin
GPIO clock pin (SCK)
int dataPin
GPIO data pin (MOSI)
bool operator==(const SpiChipsetConfig &other) const FL_NOEXCEPT
Equality operator.
SpiChipsetConfig & operator=(const SpiChipsetConfig &) FL_NOEXCEPT=default
Copy assignment.