Skip to content

Repository files navigation

led-strip

English | 简体中文

CI codecov

A no_std driver for single-wire addressable LED strips (WS2812B, SK6812, WS2811, WS2816) with compile-time buffer sizing and zero heap allocations.

Features

  • SPI backend via embedded-hal — the only fully implemented backend today
  • RMT & PIO backends — compile-time skeletons; full transmit/encode paths pending
  • Typed pixel formats: Rgb (8-bit), Rgbw (8-bit + white), Rgb16 (16-bit)
  • Typed protocol presets: Ws2812, Ws2812B, Ws2811, Sk6812, Ws2816
  • Compile-time capacity checks in LedStrip::write; encode + transmit in one call
  • SPI encoding plan validation at construction time (bit-by-bit symbol simulation + timing tolerance vs protocol spec)
  • Explicit SpiEncodeError::InternalConsistency for impossible post-check encode overflows
  • invert_output support for boards with external inverter circuits
  • Destructure with into_parts() to reuse backends across multiple strips

Usage

use led_strip::{LedStrip, SpiCodec, SpiBackend, SpiEncodingPlan, Rgb, RgbOrder, Ws2812B};

// Type-alias to reduce turbofish noise
type MyStrip = LedStrip<Rgb, Ws2812B, SpiCodec<Rgb, Ws2812B>, SpiBackend<MySpi>, 1024>;

let codec = SpiCodec::<Rgb, Ws2812B>::for_protocol(SpiEncodingPlan::ws2812_3bit(), false).unwrap();
let backend = SpiBackend::new(spi); // spi: impl embedded_hal::spi::SpiBus<u8>

let mut strip = MyStrip::new(RgbOrder::Grb, codec, backend);

let pixels = [Rgb::new(255, 0, 0); 60];
strip.write(&pixels).unwrap();

Releasing

This project uses release-plz to automate releases:

  1. Every push to main triggers release-plz to open/update a Release PR with the correct version bumps and a changelog derived from Conventional Commits.
  2. Merge the Release PR when ready — release-plz will then:
    • Create the git tag (led-strip-v<version>)
    • Publish to crates.io
    • Create a GitHub release with release notes

License

Licensed under either of

at your option.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages