Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ documentation = "https://docs.rs/ws2812-pio"
repository = "https://github.com/rp-rs/ws2812-pio-rs/"

[dependencies]
embedded-hal = "0.2.5"
embedded-hal = "1.0.0-alpha.11"
fugit = "0.3.5"
rp2040-hal = "0.9.0-alpha.1"
rp2040-hal = { version = "0.9.0-alpha.1", features = [ "eh1_0_alpha", ] }
pio = "0.2.0"
smart-leds-trait = "0.2.1"
nb = "1.0.0"
Expand Down
23 changes: 12 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//! Bear in mind that you will have to take care of timing requirements
//! yourself then.

use cortex_m;
use embedded_hal::timer::CountDown;
use cortex_m::prelude::_embedded_hal_timer_CountDown;
use fugit::{ExtU32, HertzU32};
use rp2040_hal::{
gpio::AnyPin,
pio::{PIOExt, StateMachineIndex, Tx, UninitStateMachine, PIO},
timer::CountDown,
};
use smart_leds_trait::SmartLedsWrite;

Expand Down Expand Up @@ -143,7 +143,10 @@ where

sm.start();

Self { tx, _pin: I::from(pin) }
Self {
tx,
_pin: I::from(pin),
}
}
}

Expand Down Expand Up @@ -210,20 +213,18 @@ where
/// // Do other stuff here...
/// };
///```
pub struct Ws2812<P, SM, C, I>
pub struct Ws2812<'timer, P, SM, I>
where
C: CountDown,
I: AnyPin<Function = P::PinFunction>,
P: PIOExt,
SM: StateMachineIndex,
{
driver: Ws2812Direct<P, SM, I>,
cd: C,
cd: CountDown<'timer>,
}

impl<P, SM, C, I> Ws2812<P, SM, C, I>
impl<'timer, P, SM, I> Ws2812<'timer, P, SM, I>
where
C: CountDown,
I: AnyPin<Function = P::PinFunction>,
P: PIOExt,
SM: StateMachineIndex,
Expand All @@ -234,15 +235,15 @@ where
pio: &mut PIO<P>,
sm: UninitStateMachine<(P, SM)>,
clock_freq: fugit::HertzU32,
cd: C,
) -> Ws2812<P, SM, C, I> {
cd: CountDown<'timer>,
) -> Ws2812<'timer, P, SM, I> {
let driver = Ws2812Direct::new(pin, pio, sm, clock_freq);

Self { driver, cd }
}
}

impl<'timer, P, SM, I> SmartLedsWrite for Ws2812<P, SM, rp2040_hal::timer::CountDown<'timer>, I>
impl<'timer, P, SM, I> SmartLedsWrite for Ws2812<'timer, P, SM, I>
where
I: AnyPin<Function = P::PinFunction>,
P: PIOExt,
Expand Down