diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-02-17 01:49:20 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-17 01:49:20 +0000 |
| commit | b7c98b9ec984d035188681d1b2445c6f3a42efcf (patch) | |
| tree | 864b90987526fe1274877af957abe5545dc65246 /examples | |
| parent | 6b0e4dfb2d920dc2d2cda987a46aea2e00dc420f (diff) | |
| parent | b4dc406e199a7e4aafcdd601aaef999c6b7ba590 (diff) | |
Merge pull request #2558 from CBJamo/ws2812_write_fixup
RP: Add explicit reset time to ws2812 write fn.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/src/bin/pio_ws2812.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/rp/src/bin/pio_ws2812.rs b/examples/rp/src/bin/pio_ws2812.rs index 9a97cb8a7..ac145933c 100644 --- a/examples/rp/src/bin/pio_ws2812.rs +++ b/examples/rp/src/bin/pio_ws2812.rs | |||
| @@ -12,7 +12,7 @@ use embassy_rp::pio::{ | |||
| 12 | Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 12 | Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 13 | }; | 13 | }; |
| 14 | use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef}; | 14 | use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef}; |
| 15 | use embassy_time::Timer; | 15 | use embassy_time::{Duration, Ticker, Timer}; |
| 16 | use fixed::types::U24F8; | 16 | use fixed::types::U24F8; |
| 17 | use fixed_macro::fixed; | 17 | use fixed_macro::fixed; |
| 18 | use smart_leds::RGB8; | 18 | use smart_leds::RGB8; |
| @@ -107,6 +107,8 @@ impl<'d, P: Instance, const S: usize, const N: usize> Ws2812<'d, P, S, N> { | |||
| 107 | 107 | ||
| 108 | // DMA transfer | 108 | // DMA transfer |
| 109 | self.sm.tx().dma_push(self.dma.reborrow(), &words).await; | 109 | self.sm.tx().dma_push(self.dma.reborrow(), &words).await; |
| 110 | |||
| 111 | Timer::after_micros(55).await; | ||
| 110 | } | 112 | } |
| 111 | } | 113 | } |
| 112 | 114 | ||
| @@ -143,6 +145,7 @@ async fn main(_spawner: Spawner) { | |||
| 143 | let mut ws2812 = Ws2812::new(&mut common, sm0, p.DMA_CH0, p.PIN_16); | 145 | let mut ws2812 = Ws2812::new(&mut common, sm0, p.DMA_CH0, p.PIN_16); |
| 144 | 146 | ||
| 145 | // Loop forever making RGB values and pushing them out to the WS2812. | 147 | // Loop forever making RGB values and pushing them out to the WS2812. |
| 148 | let mut ticker = Ticker::every(Duration::from_millis(10)); | ||
| 146 | loop { | 149 | loop { |
| 147 | for j in 0..(256 * 5) { | 150 | for j in 0..(256 * 5) { |
| 148 | debug!("New Colors:"); | 151 | debug!("New Colors:"); |
| @@ -152,7 +155,7 @@ async fn main(_spawner: Spawner) { | |||
| 152 | } | 155 | } |
| 153 | ws2812.write(&data).await; | 156 | ws2812.write(&data).await; |
| 154 | 157 | ||
| 155 | Timer::after_millis(10).await; | 158 | ticker.next().await; |
| 156 | } | 159 | } |
| 157 | } | 160 | } |
| 158 | } | 161 | } |
