Skip to main content

Sk6812Driver

Struct Sk6812Driver 

Source
pub struct Sk6812Driver<const CODES: usize = MAX_CODES> { /* private fields */ }
Expand description

CODES sizes the pulse buffer: pass codes_for with the strip length.

It is a parameter because that buffer lives across the transmit await, so it sits in the caller’s future — 24 codes per LED at 4 bytes each is 1.5 KiB for the default 16 LEDs, and a fire27’s main-task stack region has about that much slack in total (its link assert is what found this). A board with ten LEDs should pay for ten: Sk6812Driver::<{ codes_for(10) }>.

It is the code count rather than the LED count because generic_const_exprs is unstable, so the buffer length cannot be computed from a generic.

Implementations§

Source§

impl<const CODES: usize> Sk6812Driver<CODES>

Source

pub fn new(rmt: RMT<'static>, pin: AnyPin<'static>) -> Result<Self, Sk6812Error>

Claim the WHOLE RMT peripheral (TX channel 0) and drive pin as the LED data line.

Convenience for an app that uses RMT for nothing else. If it also reads DS18B20 sensors, use Self::with_channel and crate::driver::ds18b20::Ds18b20Driver::with_channels with channels from crate::board::rmt::RmtChannels.

Source

pub fn with_channel( tx: impl TxChannelCreator<'static, Async>, pin: AnyPin<'static>, blocks: u8, ) -> Result<Self, Sk6812Error>

Drive pin as the LED data line using the given RMT TX channel, which claims blocks of channel RAM from that channel upwards.

Leaves the rest of the peripheral free — which is the whole point: the 1-Wire driver needs a TX and an RX channel of its own, and both drivers used to take the peripheral by value, so a board could have temperature sensing or light bars but not both.

blocks decides whether a frame transmits straight out of channel RAM or is refilled by the CPU mid-stream, which is a visible correctness matter rather than a tuning knob — crate::board::rmt::LED_BLOCKS is the board’s answer, and its module docs carry the reasoning. The claim must not reach another channel in use, or configure_tx rejects it.

Source

pub async fn write(&mut self, colors: &[Rgb]) -> Result<(), Sk6812Error>

Push a frame of colours to the strip (LED 0 first). Holds the line low afterwards to latch. Errors if the frame needs more than CODES pulse codes, i.e. more LEDs than this instance was sized for.

Source

pub async fn write_frame( &mut self, frame: &[PulseCode], ) -> Result<(), Sk6812Error>

Transmit a frame built elsewhere — typically a const one from uniform_frame, living in flash.

The only path that needs no frame storage in RAM.

Source

pub async fn fill(&mut self, color: Rgb, len: usize) -> Result<(), Sk6812Error>

Convenience: set every LED in a strip of len to the same colour.

Auto Trait Implementations§

§

impl<const CODES: usize = MAX_CODES> !Send for Sk6812Driver<CODES>

§

impl<const CODES: usize = MAX_CODES> !UnwindSafe for Sk6812Driver<CODES>

§

impl<const CODES: usize> Freeze for Sk6812Driver<CODES>

§

impl<const CODES: usize> PsramSafe for Sk6812Driver<CODES>

§

impl<const CODES: usize> RefUnwindSafe for Sk6812Driver<CODES>

§

impl<const CODES: usize> Sync for Sk6812Driver<CODES>

§

impl<const CODES: usize> Unpin for Sk6812Driver<CODES>

§

impl<const CODES: usize> UnsafeUnpin for Sk6812Driver<CODES>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.