HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
Ws2812Handler Class Reference

Unified handler for WS2812 addressable LED strips. More...

#include <Ws2812Handler.h>

Collaboration diagram for Ws2812Handler:
[legend]

Classes

struct  Config
 Configuration structure for the WS2812 handler. More...
 

Public Member Functions

 Ws2812Handler (const Config &config) noexcept
 Construct WS2812 handler with configuration.
 
 ~Ws2812Handler () noexcept
 
 Ws2812Handler (const Ws2812Handler &)=delete
 
Ws2812Handleroperator= (const Ws2812Handler &)=delete
 
 Ws2812Handler (Ws2812Handler &&)=delete
 
Ws2812Handleroperator= (Ws2812Handler &&)=delete
 
esp_err_t Initialize () noexcept
 Initialize the RMT channel and LED strip.
 
bool EnsureInitialized () noexcept
 Ensure strip resources are initialized (lazy init entrypoint).
 
bool Deinitialize () noexcept
 Deinitialize and release RMT resources.
 
bool IsInitialized () const noexcept
 Check if initialized.
 
uint32_t GetNumLeds () const noexcept
 Get the number of LEDs in the strip.
 
WS2812Strip * GetStrip () noexcept
 Get the underlying LED strip object.
 
const WS2812Strip * GetStrip () const noexcept
 
WS2812Strip * GetDriver () noexcept
 Naming-consistent alias of GetStrip().
 
const WS2812Strip * GetDriver () const noexcept
 
WS2812Animator * GetAnimator () noexcept
 Get the animator object.
 
const WS2812Animator * GetAnimator () const noexcept
 
template<typename Fn >
auto visitDriver (Fn &&fn) noexcept -> decltype(fn(std::declval< WS2812Strip & >()))
 Visit strip driver with a callable.
 
template<typename Fn >
auto visitAnimator (Fn &&fn) noexcept -> decltype(fn(std::declval< WS2812Animator & >()))
 Visit animator object with a callable.
 
void DumpDiagnostics () noexcept
 Dump diagnostics to logger.
 
const char * GetDescription () const noexcept
 Get a human-readable description of the handler.
 

Static Public Member Functions

static Config GetDefaultConfig () noexcept
 Get a sensible default Config.
 

Private Member Functions

bool EnsureInitializedLocked () noexcept
 

Private Attributes

Config config_
 
bool initialized_ {false}
 
RtosMutex mutex_
 
std::unique_ptr< WS2812Strip > strip_
 
std::unique_ptr< WS2812Animator > animator_
 
char description_ [64] {}
 Human-readable handler description.
 

Detailed Description

Unified handler for WS2812 addressable LED strips.

Provides thread-safe access to LED strip control and animation effects.

Constructor & Destructor Documentation

◆ Ws2812Handler() [1/3]

Ws2812Handler::Ws2812Handler ( const Config & config)
explicitnoexcept

Construct WS2812 handler with configuration.

Parameters
configLED strip configuration.
Here is the call graph for this function:

◆ ~Ws2812Handler()

Ws2812Handler::~Ws2812Handler ( )
noexcept
Here is the call graph for this function:

◆ Ws2812Handler() [2/3]

Ws2812Handler::Ws2812Handler ( const Ws2812Handler & )
delete

◆ Ws2812Handler() [3/3]

Ws2812Handler::Ws2812Handler ( Ws2812Handler && )
delete

Member Function Documentation

◆ Deinitialize()

bool Ws2812Handler::Deinitialize ( )
noexcept

Deinitialize and release RMT resources.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpDiagnostics()

void Ws2812Handler::DumpDiagnostics ( )
noexcept

Dump diagnostics to logger.

Here is the call graph for this function:

◆ EnsureInitialized()

bool Ws2812Handler::EnsureInitialized ( )
noexcept

Ensure strip resources are initialized (lazy init entrypoint).

Returns
true if initialized and ready.
Here is the call graph for this function:

◆ EnsureInitializedLocked()

bool Ws2812Handler::EnsureInitializedLocked ( )
privatenoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAnimator() [1/2]

const WS2812Animator * Ws2812Handler::GetAnimator ( ) const
noexcept
Here is the call graph for this function:

◆ GetAnimator() [2/2]

WS2812Animator * Ws2812Handler::GetAnimator ( )
noexcept

Get the animator object.

Returns
Pointer to WS2812Animator, or nullptr if not initialized.
Warning
Raw pointer — NOT mutex-protected. Prefer visitAnimator().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDefaultConfig()

static Config Ws2812Handler::GetDefaultConfig ( )
inlinestaticnoexcept

Get a sensible default Config.

Returns
Default Config structure.

◆ GetDescription()

const char * Ws2812Handler::GetDescription ( ) const
noexcept

Get a human-readable description of the handler.

Returns
String e.g. "WS2812 LED Strip (GPIO48, 30 LEDs)"

◆ GetDriver() [1/2]

const WS2812Strip * Ws2812Handler::GetDriver ( ) const
noexcept
Here is the call graph for this function:

◆ GetDriver() [2/2]

WS2812Strip * Ws2812Handler::GetDriver ( )
noexcept

Naming-consistent alias of GetStrip().

Warning
Raw pointer — NOT mutex-protected. Prefer visitDriver().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNumLeds()

uint32_t Ws2812Handler::GetNumLeds ( ) const
inlinenoexcept

Get the number of LEDs in the strip.

◆ GetStrip() [1/2]

const WS2812Strip * Ws2812Handler::GetStrip ( ) const
noexcept
Here is the call graph for this function:

◆ GetStrip() [2/2]

WS2812Strip * Ws2812Handler::GetStrip ( )
noexcept

Get the underlying LED strip object.

Returns
Pointer to WS2812Strip, or nullptr if not initialized.
Warning
Raw pointer — NOT mutex-protected. Caller is responsible for external synchronization in multi-task environments. Prefer visitDriver() for thread-safe access.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialize()

esp_err_t Ws2812Handler::Initialize ( )
noexcept

Initialize the RMT channel and LED strip.

Returns
ESP_OK on success, or esp_err_t error code from the RMT driver.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsInitialized()

bool Ws2812Handler::IsInitialized ( ) const
inlinenoexcept

Check if initialized.

◆ operator=() [1/2]

Ws2812Handler & Ws2812Handler::operator= ( const Ws2812Handler & )
delete

◆ operator=() [2/2]

Ws2812Handler & Ws2812Handler::operator= ( Ws2812Handler && )
delete

◆ visitAnimator()

template<typename Fn >
auto Ws2812Handler::visitAnimator ( Fn && fn) -> decltype(fn(std::declval<WS2812Animator&>()))
inlinenoexcept

Visit animator object with a callable.

Returns
Callable result or default-constructed value if unavailable.
Here is the call graph for this function:

◆ visitDriver()

template<typename Fn >
auto Ws2812Handler::visitDriver ( Fn && fn) -> decltype(fn(std::declval<WS2812Strip&>()))
inlinenoexcept

Visit strip driver with a callable.

Returns
Callable result or default-constructed value if unavailable.
Here is the call graph for this function:

Member Data Documentation

◆ animator_

std::unique_ptr<WS2812Animator> Ws2812Handler::animator_
private

◆ config_

Config Ws2812Handler::config_
private

◆ description_

char Ws2812Handler::description_[64] {}
private

Human-readable handler description.

◆ initialized_

bool Ws2812Handler::initialized_ {false}
private

◆ mutex_

RtosMutex Ws2812Handler::mutex_
mutableprivate

◆ strip_

std::unique_ptr<WS2812Strip> Ws2812Handler::strip_
private

The documentation for this class was generated from the following files: