ws2812-blocking-spi

Crates.iows2812-blocking-spi
lib.rsws2812-blocking-spi
version0.2.0
sourcesrc
created_at2022-04-09 16:42:21.063736
updated_at2022-04-15 15:02:58.367867
descriptionDriver based on embedded_hal::blocking::spi::Write for WS2812
homepage
repositoryhttps://github.com/andy31415/ws2812-blocking-spi-rs
max_upload_size
id564811
size5,123
Andrei Litvin (andy31415)

documentation

README

WS2812 driver for embedded-hal blocking spi traits

This crate adds an implementation using embedded_hal::spi::blocking for smart-leds

The ws2821 crate that is part of the smart-leds project is using a FullDuplex implementation of SPI which is not implemented on all platforms.

This crate pre-generates constants for all 8-bit patterns required to send to LEDs and this adds a 1KB flash space overhead.

Usage example

use ws2812_blocking_spi::Ws2812BlockingWriter;

// Requires a SPI interface. LEDs data pin should be
// connected to the MOSI pin (master-in-slave-out)
let spi: embedded_hal::blocking::spi::Write<u8> = /*... */;

// setup some data to write
let mut data = [RGB8::default(); 3];
data[0] = [0xFF_u8, 0_u8, 0_u8].into();  // Full RED
data[1] = [0_u8, 0xFF_u8, 0_u8].into();  // Full GREEN
data[2] = [0_u8, 0_u8, 0xFF_u8].into();  // Full BLUE

// Create a writer
let mut leds = Ws2812BlockingWriter::new(spi);

// does the data write
leds.write(data.iter().cloned());
Commit count: 15

cargo fmt