From 1be6e533165cb773979739c203b745df24ff1ecf Mon Sep 17 00:00:00 2001 From: Caleb Jamison Date: Tue, 9 May 2023 17:05:39 -0400 Subject: [PATCH] Pin fix, improve fifo handling --- examples/rp/src/bin/{ws2812-pio.rs => pio_ws2812.rs} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename examples/rp/src/bin/{ws2812-pio.rs => pio_ws2812.rs} (95%) diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/pio_ws2812.rs similarity index 95% rename from examples/rp/src/bin/ws2812-pio.rs rename to examples/rp/src/bin/pio_ws2812.rs index f4c2d631..4915c7e9 100644 --- a/examples/rp/src/bin/ws2812-pio.rs +++ b/examples/rp/src/bin/pio_ws2812.rs @@ -48,6 +48,8 @@ impl<'d, P: Instance, const S: usize> Ws2812<'d, P, S> { // Pin config let out_pin = pio.make_pio_pin(pin); + cfg.set_out_pins(&[&out_pin]); + cfg.set_set_pins(&[&out_pin]); let relocated = RelocatedProgram::new(&prg); cfg.use_program(&pio.load_program(&relocated), &[&out_pin]); @@ -76,7 +78,9 @@ impl<'d, P: Instance, const S: usize> Ws2812<'d, P, S> { pub async fn write(&mut self, colors: &[RGB8]) { for color in colors { let word = (u32::from(color.g) << 24) | (u32::from(color.r) << 16) | (u32::from(color.b) << 8); - self.sm.tx().wait_push(word).await; + if !self.sm.tx().try_push(word) { + self.sm.tx().wait_push(word).await; + } } } }