43#ifndef COMPONENT_HANDLER_WS2812_HANDLER_H_
44#define COMPONENT_HANDLER_WS2812_HANDLER_H_
50#include "core/hf-core-drivers/external/hf-ws2812-rmt-driver/inc/ws2812_cpp.hpp"
51#include "core/hf-core-drivers/external/hf-ws2812-rmt-driver/inc/ws2812_effects.hpp"
54#if defined(ESP_PLATFORM)
55#include "driver/gpio.h"
146 [[nodiscard]] WS2812Strip*
GetStrip() noexcept;
147 [[nodiscard]] const WS2812Strip*
GetStrip() const noexcept;
153 [[nodiscard]] WS2812Strip*
GetDriver() noexcept;
154 [[nodiscard]] const WS2812Strip*
GetDriver() const noexcept;
161 [[nodiscard]] WS2812Animator*
GetAnimator() noexcept;
162 [[nodiscard]] const WS2812Animator*
GetAnimator() const noexcept;
168 template <typename Fn>
169 auto
visitDriver(Fn&& fn) noexcept -> decltype(fn(std::declval<WS2812Strip&>())) {
170 using ReturnType =
decltype(fn(std::declval<WS2812Strip&>()));
171 MutexLockGuard lock(
mutex_);
173 if constexpr (std::is_void_v<ReturnType>) {
186 template <
typename Fn>
187 auto visitAnimator(Fn&& fn)
noexcept ->
decltype(fn(std::declval<WS2812Animator&>())) {
188 using ReturnType =
decltype(fn(std::declval<WS2812Animator&>()));
189 MutexLockGuard lock(
mutex_);
191 if constexpr (std::is_void_v<ReturnType>) {
int gpio_num_t
Definition Ws2812Handler.h:57
Unified handler for WS2812 addressable LED strips.
Definition Ws2812Handler.h:71
char description_[64]
Human-readable handler description.
Definition Ws2812Handler.h:223
WS2812Strip * GetDriver() noexcept
Naming-consistent alias of GetStrip().
Definition Ws2812Handler.cpp:119
auto visitDriver(Fn &&fn) noexcept -> decltype(fn(std::declval< WS2812Strip & >()))
Visit strip driver with a callable.
Definition Ws2812Handler.h:169
WS2812Animator * GetAnimator() noexcept
Get the animator object.
Definition Ws2812Handler.cpp:128
std::unique_ptr< WS2812Strip > strip_
Definition Ws2812Handler.h:221
bool initialized_
Definition Ws2812Handler.h:219
void DumpDiagnostics() noexcept
Dump diagnostics to logger.
Definition Ws2812Handler.cpp:141
bool Deinitialize() noexcept
Deinitialize and release RMT resources.
Definition Ws2812Handler.cpp:87
~Ws2812Handler() noexcept
Definition Ws2812Handler.cpp:26
WS2812Strip * GetStrip() noexcept
Get the underlying LED strip object.
Definition Ws2812Handler.cpp:106
bool EnsureInitialized() noexcept
Ensure strip resources are initialized (lazy init entrypoint).
Definition Ws2812Handler.cpp:75
const char * GetDescription() const noexcept
Get a human-readable description of the handler.
Definition Ws2812Handler.cpp:157
RtosMutex mutex_
Definition Ws2812Handler.h:220
std::unique_ptr< WS2812Animator > animator_
Definition Ws2812Handler.h:222
Config config_
Definition Ws2812Handler.h:218
esp_err_t Initialize() noexcept
Initialize the RMT channel and LED strip.
Definition Ws2812Handler.cpp:32
bool IsInitialized() const noexcept
Check if initialized.
Definition Ws2812Handler.h:128
Ws2812Handler(const Config &config) noexcept
Construct WS2812 handler with configuration.
Definition Ws2812Handler.cpp:16
uint32_t GetNumLeds() const noexcept
Get the number of LEDs in the strip.
Definition Ws2812Handler.h:137
auto visitAnimator(Fn &&fn) noexcept -> decltype(fn(std::declval< WS2812Animator & >()))
Visit animator object with a callable.
Definition Ws2812Handler.h:187
static Config GetDefaultConfig() noexcept
Get a sensible default Config.
Definition Ws2812Handler.h:213
bool EnsureInitializedLocked() noexcept
Definition Ws2812Handler.cpp:80
Configuration structure for the WS2812 handler.
Definition Ws2812Handler.h:76
uint16_t t1l
T1L timing in nanoseconds.
Definition Ws2812Handler.h:85
int rmt_channel
RMT channel number.
Definition Ws2812Handler.h:81
LedType led_type
Definition Ws2812Handler.h:79
uint8_t brightness
Global brightness (0-255)
Definition Ws2812Handler.h:80
uint32_t num_leds
Number of LEDs in the strip.
Definition Ws2812Handler.h:78
uint16_t t1h
T1H timing in nanoseconds.
Definition Ws2812Handler.h:83
uint16_t t0l
T0L timing in nanoseconds.
Definition Ws2812Handler.h:84
uint16_t t0h
T0H timing in nanoseconds.
Definition Ws2812Handler.h:82
gpio_num_t gpio_pin
GPIO pin connected to LED data line.
Definition Ws2812Handler.h:77