Skip to content

Commit 0f824b7

Browse files
committed
embassy-rp: implement SmartLedsWriteAsync
1 parent 4b12925 commit 0f824b7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

embassy-rp/src/pio_programs/ws2812.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! [ws2812](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf)
22
3+
use core::convert::Infallible;
34
use embassy_time::Timer;
45
use fixed::types::U24F8;
5-
use smart_leds::RGB8;
6+
use smart_leds::{SmartLedsWriteAsync, RGB8};
67

78
use crate::clocks::clk_sys_freq;
89
use crate::dma::{AnyChannel, Channel};
@@ -117,3 +118,17 @@ impl<'d, P: Instance, const S: usize, const N: usize> PioWs2812<'d, P, S, N> {
117118
Timer::after_micros(55).await;
118119
}
119120
}
121+
122+
impl<'d, P: Instance, const S: usize, const N: usize> SmartLedsWriteAsync for PioWs2812<'d, P, S, N> {
123+
type Error = Infallible;
124+
type Color = RGB8;
125+
126+
async fn write<T, I>(&mut self, iterator: T) -> Result<(), Self::Error>
127+
where
128+
T: IntoIterator<Item = I>,
129+
I: Into<RGB8>,
130+
{
131+
self.write(iterator).await;
132+
Ok(())
133+
}
134+
}

0 commit comments

Comments
 (0)