Addressable LED strip handler for WS2812/NeoPixel LEDs using the ESP32 RMT peripheral.
Construction
1
Ws2812Handler(constConfig&config);
Config Structure
1
2
3
4
5
6
7
8
9
10
11
structConfig{gpio_num_tgpio_pin{};// GPIO pin connected to LED data lineuint32_tnum_leds{1};// Number of LEDs in the stripLedTypeled_type{LedType::RGB};uint8_tbrightness{255};// Global brightness (0–255)intrmt_channel{0};// RMT channel numberuint16_tt0h{400};// T0H timing (ns)uint16_tt1h{800};// T1H timing (ns)uint16_tt0l{850};// T0L timing (ns)uint16_tt1l{450};// T1L timing (ns)};
Key Methods
Lifecycle
Method
Description
Initialize()
Initialize RMT channel and LED strip. Returns esp_err_t.
EnsureInitialized()
Lazy init entrypoint
Deinitialize()
Release RMT resources
IsInitialized()
Check initialization state
Driver Access
Method
Description
GetNumLeds()
Get the number of LEDs
GetDriver() / GetStrip()
Get underlying WS2812Strip*
GetAnimator()
Get underlying WS2812Animator*
visitDriver(fn)
Execute callable with WS2812Strip& under mutex
visitAnimator(fn)
Execute callable with WS2812Animator& under mutex
Diagnostics
Method
Description
DumpDiagnostics()
Log LED count, config, init state
All pixel operations and animation effects are intentionally delegated to
the underlying driver objects (WS2812Strip, WS2812Animator) exposed by
the handler.
Thread Safety
All methods are protected by an internal RtosMutex.
Test Coverage
See examples/esp32/main/handler_tests/ws2812_handler_comprehensive_test.cpp.