Skip to content

Commit 4b48829

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

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

embassy-rp/src/pio_programs/ws2812.rs

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

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

0 commit comments

Comments
 (0)