|
WS2812 RMT Driver
API reference
|
#include <rmt_wrapper.hpp>
Public Member Functions | |
| RmtTx (gpio_num_t gpio, uint32_t resolution_hz=10 '000 '000, size_t mem_symbols=kDefaultMemSymbols, bool with_dma=false, uint32_t queue_depth=4, rmt_clock_source_t clk_src=RMT_CLK_SRC_DEFAULT, int channel_id=-1) | |
| Create a Transmit channel. | |
| RmtTx (const RmtTx &)=delete | |
| RmtTx & | operator= (const RmtTx &)=delete |
| RmtTx (RmtTx &&other) noexcept | |
| RmtTx & | operator= (RmtTx &&other) noexcept |
| ~RmtTx () | |
| esp_err_t | Init () |
| Create and enable the channel if that has not succeeded yet. | |
| esp_err_t | InitStatus () const |
| Result of the last Init(): ESP_OK when the channel is ready. | |
| bool | IsReady () const |
| True when the channel was created and enabled. | |
| esp_err_t | Transmit (const rmt_symbol_word_t *symbols, size_t count, int32_t timeout_ms=kWaitForever) const |
| Transmit raw RMT symbols (blocking until done). | |
| template<typename Ticks , std::enable_if_t< std::is_same_v< Ticks, TickType_t >, int > = 0> | |
| esp_err_t | Transmit (const rmt_symbol_word_t *symbols, size_t count, Ticks timeout) const |
| esp_err_t | TransmitBytes (const uint8_t *data, size_t length, const rmt_symbol_word_t &bit0, const rmt_symbol_word_t &bit1, int32_t timeout_ms=kWaitForever) |
| Transmit an arbitrary byte stream with custom bit timing. | |
| template<typename Ticks , std::enable_if_t< std::is_same_v< Ticks, TickType_t >, int > = 0> | |
| esp_err_t | TransmitBytes (const uint8_t *data, size_t length, const rmt_symbol_word_t &bit0, const rmt_symbol_word_t &bit1, Ticks timeout) |
| esp_err_t | TransmitWs2812 (const uint8_t *grb, size_t length, int32_t timeout_ms=kWaitForever) |
| Helper dedicated to WS2812/NeoPixel @ 800 kHz. Uses 10 MHz or faster resolution to achieve accurate timings. | |
| template<typename Ticks , std::enable_if_t< std::is_same_v< Ticks, TickType_t >, int > = 0> | |
| esp_err_t | TransmitWs2812 (const uint8_t *grb, size_t length, Ticks timeout) |
| rmt_channel_handle_t | Handle () const |
Static Public Member Functions | |
| static constexpr int32_t | TicksToTimeoutMs (TickType_t ticks, uint32_t tick_rate_hz=configTICK_RATE_HZ) |
| Convert a FreeRTOS tick count to the millisecond timeout the transmit calls take. | |
Static Public Attributes | |
| static constexpr size_t | kDefaultMemSymbols = WS2812_RMT_MEM_BLOCK_SYMBOLS |
| static constexpr int32_t | kWaitForever = -1 |
|
inlineexplicit |
Create a Transmit channel.
| gpio | Output GPIO number. |
| resolution_hz | Clock resolution in Hz (max 40 MHz on ESP32‑C6). |
| mem_symbols | Symbol memory per channel (in 32-bit words); the default is one memory block of the target. |
| with_dma | Enable DMA mode for huge transfers. |
| queue_depth | Depth of internal Transmit queue. |
| clk_src | Clock source (default: RMT_CLK_SRC_DEFAULT). |
| channel_id | Unused: ESP-IDF v5 allocates the channel itself. |
|
delete |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
Create and enable the channel if that has not succeeded yet.
The constructor calls this once. A failure (no free channel, invalid GPIO, no memory) no longer aborts: it is returned here and by InitStatus(), the object stays unusable (every transmit returns ESP_ERR_INVALID_STATE), and a later Init() retries.
|
inline |
Result of the last Init(): ESP_OK when the channel is ready.
|
inline |
True when the channel was created and enabled.
|
inlinestaticconstexpr |
Convert a FreeRTOS tick count to the millisecond timeout the transmit calls take.
portMAX_DELAY becomes kWaitForever; other counts round down and saturate at INT32_MAX. Only the deprecated tick overloads use it.
|
inline |
Transmit raw RMT symbols (blocking until done).
| timeout_ms | How long to wait for the frame to go out, in milliseconds; kWaitForever (-1) waits until it is done. Passed to rmt_tx_wait_all_done() as it is. |
|
inline |
int32_t, or kWaitForever.
|
inline |
Transmit an arbitrary byte stream with custom bit timing.
| bit0 | Symbol encoding logic‑0 (LSB first by default). |
| bit1 | Symbol encoding logic‑1. |
| timeout_ms | Wait for the frame in milliseconds; kWaitForever (-1) waits until done. |
|
inline |
int32_t, or kWaitForever.
|
inline |
Helper dedicated to WS2812/NeoPixel @ 800 kHz. Uses 10 MHz or faster resolution to achieve accurate timings.
| timeout_ms | Wait for the frame in milliseconds; kWaitForever (-1) waits until done. |
|
inline |
int32_t, or kWaitForever.
|
staticconstexpr |
Channel memory requested by default, in symbols.
|
staticconstexpr |
Transmit timeout that waits until the frame is out, as rmt_tx_wait_all_done() takes it.