Struct Ws2812BlockingWriter

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

Source§

impl<SPI: Write<u8>> Ws2812BlockingWriter<SPI>

Source

pub fn new(spi: SPI) -> Self

Trait Implementations§

Source§

impl<SPI: Write<u8>> SmartLedsWrite for Ws2812BlockingWriter<SPI>

Source§

fn write<T, I>(&mut self, iterator: T) -> Result<(), SPI::Error>
where T: Iterator<Item = I>, I: Into<Self::Color>,

Write all the items of an iterator to a ws2812 strip

Source§

type Error = <SPI as Write<u8>>::Error

Source§

type Color = Rgb<u8>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.