aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/pio_programs/ws2812.rs36
1 files changed, 30 insertions, 6 deletions
diff --git a/embassy-rp/src/pio_programs/ws2812.rs b/embassy-rp/src/pio_programs/ws2812.rs
index 38f95facb..20f7d827b 100644
--- a/embassy-rp/src/pio_programs/ws2812.rs
+++ b/embassy-rp/src/pio_programs/ws2812.rs
@@ -94,7 +94,7 @@ impl<'a, PIO: Instance> PioWs2812Program<'a, PIO> {
94 94
95/// Pio backed RGB ws2812 driver 95/// Pio backed RGB ws2812 driver
96/// Const N is the number of ws2812 leds attached to this pin 96/// Const N is the number of ws2812 leds attached to this pin
97pub struct PioWs2812<'d, P: Instance, const S: usize, const N: usize, ORDER = Grb> 97pub struct PioWs2812<'d, P: Instance, const S: usize, const N: usize, ORDER>
98where 98where
99 ORDER: RgbColorOrder, 99 ORDER: RgbColorOrder,
100{ 100{
@@ -103,12 +103,24 @@ where
103 _order: core::marker::PhantomData<ORDER>, 103 _order: core::marker::PhantomData<ORDER>,
104} 104}
105 105
106impl<'d, P: Instance, const S: usize, const N: usize, ORDER = Grb> PioWs2812<'d, P, S, N, ORDER> 106impl<'d, P: Instance, const S: usize, const N: usize> PioWs2812<'d, P, S, N, Grb> {
107 pub fn new(
108 pio: &mut Common<'d, P>,
109 sm: StateMachine<'d, P, S>,
110 dma: Peri<'d, impl Channel>,
111 pin: Peri<'d, impl PioPin>,
112 program: &PioWs2812Program<'d, P>,
113 ) -> Self {
114 Self::with_color_order(pio, sm, dma, pin, program)
115 }
116}
117
118impl<'d, P: Instance, const S: usize, const N: usize, ORDER> PioWs2812<'d, P, S, N, ORDER>
107where 119where
108 ORDER: RgbColorOrder, 120 ORDER: RgbColorOrder,
109{ 121{
110 /// Configure a pio state machine to use the loaded ws2812 program. 122 /// Configure a pio state machine to use the loaded ws2812 program.
111 pub fn new( 123 pub fn with_color_order(
112 pio: &mut Common<'d, P>, 124 pio: &mut Common<'d, P>,
113 mut sm: StateMachine<'d, P, S>, 125 mut sm: StateMachine<'d, P, S>,
114 dma: Peri<'d, impl Channel>, 126 dma: Peri<'d, impl Channel>,
@@ -167,7 +179,7 @@ where
167/// Pio backed RGBW ws2812 driver 179/// Pio backed RGBW ws2812 driver
168/// This version is intended for ws2812 leds with 4 addressable lights 180/// This version is intended for ws2812 leds with 4 addressable lights
169/// Const N is the number of ws2812 leds attached to this pin 181/// Const N is the number of ws2812 leds attached to this pin
170pub struct RgbwPioWs2812<'d, P: Instance, const S: usize, const N: usize, ORDER = Grbw> 182pub struct RgbwPioWs2812<'d, P: Instance, const S: usize, const N: usize, ORDER>
171where 183where
172 ORDER: RgbwColorOrder, 184 ORDER: RgbwColorOrder,
173{ 185{
@@ -176,12 +188,24 @@ where
176 _order: core::marker::PhantomData<ORDER>, 188 _order: core::marker::PhantomData<ORDER>,
177} 189}
178 190
179impl<'d, P: Instance, const S: usize, const N: usize, ORDER = Grbw> RgbwPioWs2812<'d, P, S, N, ORDER> 191impl<'d, P: Instance, const S: usize, const N: usize> RgbwPioWs2812<'d, P, S, N, Grbw> {
192 pub fn new(
193 pio: &mut Common<'d, P>,
194 sm: StateMachine<'d, P, S>,
195 dma: Peri<'d, impl Channel>,
196 pin: Peri<'d, impl PioPin>,
197 program: &PioWs2812Program<'d, P>,
198 ) -> Self {
199 Self::with_color_order(pio, sm, dma, pin, program)
200 }
201}
202
203impl<'d, P: Instance, const S: usize, const N: usize, ORDER> RgbwPioWs2812<'d, P, S, N, ORDER>
180where 204where
181 ORDER: RgbwColorOrder, 205 ORDER: RgbwColorOrder,
182{ 206{
183 /// Configure a pio state machine to use the loaded ws2812 program. 207 /// Configure a pio state machine to use the loaded ws2812 program.
184 pub fn new( 208 pub fn with_color_order(
185 pio: &mut Common<'d, P>, 209 pio: &mut Common<'d, P>,
186 mut sm: StateMachine<'d, P, S>, 210 mut sm: StateMachine<'d, P, S>,
187 dma: Peri<'d, impl Channel>, 211 dma: Peri<'d, impl Channel>,