Expand description
Pure Rust WS2812 color utilities.
This crate provides hardware-independent color conversion and bit manipulation utilities for WS2812 (NeoPixel) LEDs. It has no ESP or embedded dependencies, making it fully testable on any platform.
§SPI Pre-rendering
prerender_spi encodes &[RGB8] into a byte buffer suitable for SPI-based
WS2812 transmission (4 SPI bits per WS2812 data bit, 12 bytes per LED).
The encoding is byte-for-byte compatible with
ws2812-spi v0.5.1’s prerendered module.
§Grid primitives
The grid module provides GridLayout, GridBuffer, and gamma/brightness
helpers for addressing WS2812 LEDs wired as a rectangular matrix.
Modules§
- grid
- Grid coordinate mapping, gamma correction, and brightness scaling.
Enums§
- SpiEncode
Error - Error returned by
prerender_spiwhen the output buffer is too small.
Constants§
- SPI_
RESET_ BYTES_ 2MHZ - Minimum reset bytes for 2 MHz SPI clock.
Functions§
- color_
to_ bits - Extracts bit values from a 24-bit color for WS2812 transmission.
- prerender_
spi - Pre-renders
colorsinto a WS2812-compatible SPI byte buffer. - rgb_
to_ grb - Converts RGB to GRB u32 format (WS2812 color order).
- spi_
data_ len - Returns the number of SPI data bytes required to encode
num_ledsLEDs.