Skip to main content

Crate bunting

Crate bunting 

Source
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§

SpiEncodeError
Error returned by prerender_spi when 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 colors into 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_leds LEDs.