FastLED 3.10.6
Loading...
Searching...
No Matches
uart_wave_encoder.h File Reference

Detailed Description

Platform-neutral UART wave4/wave5 encoder API.

This encoder uses a "wave10" model that treats the full 10-bit UART frame (START + 8 data + STOP) as the fundamental encoding unit. With TX inversion, START=HIGH and STOP=LOW, giving 5 controllable pulses per LED bit (2 LED bits per frame).

The implementation originated with the ESP UART backend, but it models only an inverted UART frame and ChipsetTimingConfig; ESP UART, RP UART DMA, and future backends all consume this stable channel-layer API.

Wave10 Concept

Unlike wave8 (8 pulses per bit for PARLIO/SPI), wave10 accounts for UART's automatic start/stop bits as part of the waveform:

LED bit A: [START=H] [D0] [D1] [D2] [D3] <- 5 pulses, START fixed HIGH
LED bit B: [D4] [D5] [D6] [D7] [STOP=L] <- 5 pulses, STOP fixed LOW
fl::UICheckbox pulses("Beat Pulses", true)
static const int H
Definition PerfDisc.ino:21

Dynamic LUT Generation

The LUT is computed from chipset timing (T1/T2/T3) rather than hardcoded, enabling support for any clockless LED protocol (WS2812, SK6812, WS2811, etc.)

Encoding Ratio

  • 2 LED bits -> 1 UART byte (8 data bits)
  • 1 LED byte (8 bits) -> 4 UART bytes
  • 1 RGB LED (3 bytes) -> 12 UART bytes

Timing Feasibility

A chipset is compatible when:

  1. Required baud rate <= 5.0 Mbps (ESP32 UART limit)
  2. T0H and T1H map to different pulse counts in [1, 4]
  3. Quantized timing is within half a pulse width of nominal

Definition in file uart_wave_encoder.h.

+ Include dependency graph for uart_wave_encoder.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fl::Wave10Lut
 Wave lookup table for UART LED encoding (waveN family) More...
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 
namespace  fl::detail
 Compile-time linker keep-alive hook for a single fl::Bus.
 

Functions

Wave10Lut fl::buildWave10Lut (const ChipsetTimingConfig &timing) FL_NO_EXCEPT
 Build a Wave10 LUT from chipset timing parameters.
 
Wave10Lut fl::buildWave10LutForMaxBaud (const ChipsetTimingConfig &timing, u32 max_baud_rate) FL_NO_EXCEPT
 Build a UART waveform LUT with a backend-specific baud ceiling.
 
FASTLED_FORCE_INLINE constexpr size_t fl::calculateUartBufferSize (size_t input_size) FL_NO_EXCEPT
 Calculate required output buffer size for LED encoding.
 
FASTLED_FORCE_INLINE constexpr size_t fl::calculateUartBufferSizeForLeds (size_t num_leds) FL_NO_EXCEPT
 Calculate required output buffer size for RGB LED encoding.
 
bool fl::canRepresentTiming (const ChipsetTimingConfig &timing) FL_NO_EXCEPT
 Check if a chipset timing can be accurately represented by UART.
 
bool fl::canRepresentTimingForMaxBaud (const ChipsetTimingConfig &timing, u32 max_baud_rate) FL_NO_EXCEPT
 Timing feasibility with a backend-specific baud ceiling.
 
FL_IRAM FL_OPTIMIZE_FUNCTION size_t fl::encodeLedsToUart (const u8 *input, size_t input_size, u8 *output, size_t output_capacity) FL_NO_EXCEPT
 Legacy encoding using hardcoded WS2812 LUT (backward compat)
 
FL_IRAM FL_OPTIMIZE_FUNCTION size_t fl::encodeLedsToUart (const u8 *input, size_t input_size, u8 *output, size_t output_capacity, const Wave10Lut &lut) FL_NO_EXCEPT
 Encode LED pixel data to UART bytes using a Wave10 LUT.
 
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION u8 fl::detail::encodeUart2Bits (u8 two_bits) FL_NO_EXCEPT
 Legacy 2-bit encoding using hardcoded WS2812 LUT (backward compat)
 
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION u8 fl::detail::encodeUart2Bits (u8 two_bits, const Wave10Lut &lut) FL_NO_EXCEPT
 Encode 2 LED bits to 1 UART byte using a Wave10 LUT.
 
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION void fl::detail::encodeUartByte (u8 led_byte, u8 *output) FL_NO_EXCEPT
 Legacy byte encoding using hardcoded WS2812 LUT (backward compat)
 
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION void fl::detail::encodeUartByte (u8 led_byte, u8 *output, const Wave10Lut &lut) FL_NO_EXCEPT
 Encode 1 LED byte to 4 UART bytes using a Wave10 LUT.
 
ChipsetTiming fl::uartWireTiming (const ChipsetTimingConfig &timing, u32 max_baud_rate) FL_NO_EXCEPT
 The wire timing the UART encoder actually produces for a chipset.
 

Variables

constexpr u32 fl::kMaxUartBaudRate = 5000000
 Maximum UART baud rate supported by ESP32 variants.