pub struct Ws2812BlockingWriter<SPI> { /* private fields */ }
Expand description
Wraps a SPI Writer to represent a WS2821 LED array.
§Examples:
use ws2812_blocking_spi::Ws2812BlockingWriter;
use embedded_hal::blocking::spi::Write;
use smart_leds_trait::{RGB8, SmartLedsWrite};
//
// Displays 3 LEDs: red, green and blue
//
fn show<SPI: Write<u8>>(spi: SPI) {
let mut leds = Ws2812BlockingWriter::new(spi);
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
leds.write(data.iter().cloned());
}
Implementations§
Trait Implementations§
Source§impl<SPI: Write<u8>> SmartLedsWrite for Ws2812BlockingWriter<SPI>
impl<SPI: Write<u8>> SmartLedsWrite for Ws2812BlockingWriter<SPI>
Auto Trait Implementations§
impl<SPI> Freeze for Ws2812BlockingWriter<SPI>where
SPI: Freeze,
impl<SPI> RefUnwindSafe for Ws2812BlockingWriter<SPI>where
SPI: RefUnwindSafe,
impl<SPI> Send for Ws2812BlockingWriter<SPI>where
SPI: Send,
impl<SPI> Sync for Ws2812BlockingWriter<SPI>where
SPI: Sync,
impl<SPI> Unpin for Ws2812BlockingWriter<SPI>where
SPI: Unpin,
impl<SPI> UnwindSafe for Ws2812BlockingWriter<SPI>where
SPI: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more