@@ -20,6 +20,7 @@ use rp2040_hal::{
2020 pio:: { PIOExt , StateMachineIndex , Tx , UninitStateMachine , PIO } ,
2121} ;
2222use smart_leds_trait:: SmartLedsWrite ;
23+ use smart_leds_trait_0_2:: SmartLedsWrite as SmartLedsWrite02 ;
2324
2425/// This is the WS2812 PIO Driver.
2526///
@@ -166,7 +167,7 @@ where
166167 /// PIO FIFO until all data has been transmitted to the LED chain.
167168 fn write < T , J > ( & mut self , iterator : T ) -> Result < ( ) , ( ) >
168169 where
169- T : Iterator < Item = J > ,
170+ T : IntoIterator < Item = J > ,
170171 J : Into < Self :: Color > ,
171172 {
172173 for item in iterator {
@@ -182,6 +183,30 @@ where
182183 }
183184}
184185
186+ impl < P , SM , I > SmartLedsWrite02 for Ws2812Direct < P , SM , I >
187+ where
188+ I : AnyPin < Function = P :: PinFunction > ,
189+ P : PIOExt ,
190+ SM : StateMachineIndex ,
191+ {
192+ type Color = smart_leds_trait:: RGB8 ;
193+ type Error = ( ) ;
194+ /// If you call this function, be advised that you will have to wait
195+ /// at least 60 microseconds between calls of this function!
196+ /// That means, either you get hold on a timer and the timing
197+ /// requirements right your self, or rather use [Ws2812].
198+ ///
199+ /// Please bear in mind, that it still blocks when writing into the
200+ /// PIO FIFO until all data has been transmitted to the LED chain.
201+ fn write < T , J > ( & mut self , iterator : T ) -> Result < ( ) , ( ) >
202+ where
203+ T : Iterator < Item = J > ,
204+ J : Into < Self :: Color > ,
205+ {
206+ SmartLedsWrite :: write ( self , iterator)
207+ }
208+ }
209+
185210/// Instance of a WS2812 LED chain.
186211///
187212/// Use the [Ws2812::write] method to update the WS2812 LED chain.
@@ -256,7 +281,7 @@ where
256281 type Error = ( ) ;
257282 fn write < T , J > ( & mut self , iterator : T ) -> Result < ( ) , ( ) >
258283 where
259- T : Iterator < Item = J > ,
284+ T : IntoIterator < Item = J > ,
260285 J : Into < Self :: Color > ,
261286 {
262287 self . driver . tx . clear_stalled_flag ( ) ;
@@ -265,6 +290,25 @@ where
265290 self . cd . start ( 60u32 . micros ( ) ) ;
266291 let _ = nb:: block!( self . cd. wait( ) ) ;
267292
268- self . driver . write ( iterator)
293+ SmartLedsWrite :: write ( & mut self . driver , iterator)
294+ }
295+ }
296+
297+ impl < P , SM , I , C > SmartLedsWrite02 for Ws2812 < P , SM , C , I >
298+ where
299+ C : CountDown ,
300+ C :: Time : From < MicrosDurationU32 > ,
301+ I : AnyPin < Function = P :: PinFunction > ,
302+ P : PIOExt ,
303+ SM : StateMachineIndex ,
304+ {
305+ type Color = smart_leds_trait:: RGB8 ;
306+ type Error = ( ) ;
307+ fn write < T , J > ( & mut self , iterator : T ) -> Result < ( ) , ( ) >
308+ where
309+ T : IntoIterator < Item = J > ,
310+ J : Into < Self :: Color > ,
311+ {
312+ SmartLedsWrite :: write ( self , iterator)
269313 }
270314}
0 commit comments