From c8609e9ef146db7d2db83dd5e16f4772bc90762b Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Sat, 2 Oct 2021 10:04:15 +0100 Subject: [PATCH] Update WS2812 usage after PIO api's breaking change. --- .../feather_rp2040/examples/feather_neopixel_rainbow.rs | 6 ++++-- boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs | 7 ++++--- boards/qt_py_rp2040/examples/qt_py_rainbow.rs | 8 +++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs b/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs index 29cd5af..c59b461 100644 --- a/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs +++ b/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs @@ -22,6 +22,7 @@ use feather_rp2040::{ Pins, XOSC_CRYSTAL_FREQ, }; use panic_halt as _; +use rp2040_hal::pio::PIOExt; use smart_leds::{brightness, SmartLedsWrite, RGB8}; use ws2812_pio::Ws2812; #[link_section = ".boot2"] @@ -60,11 +61,12 @@ fn main() -> ! { let mut delay = timer.count_down(); // Configure the addressable LED + let (mut pio, sm0, _, _, _) = pac.PIO0.split(&mut pac.RESETS); let mut ws = Ws2812::new( // The onboard NeoPixel is attached to GPIO pin #16 on the Feather RP2040. 16, - pac.PIO0, - &mut pac.RESETS, + &mut pio, + sm0, clocks.peripheral_clock.freq(), timer.count_down(), ); diff --git a/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs b/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs index ae825e5..d18ceeb 100644 --- a/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs +++ b/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs @@ -25,6 +25,7 @@ use pro_micro_rp2040::{ }, XOSC_CRYSTAL_FREQ, }; +use rp2040_hal::pio::PIOExt; use smart_leds::{brightness, SmartLedsWrite, RGB8}; use ws2812_pio::Ws2812; @@ -75,11 +76,11 @@ fn main() -> ! { let mut delay = timer.count_down(); // Configure the addressable LED - + let (mut pio, sm0, _, _, _) = pac.PIO0.split(&mut pac.RESETS); let mut ws = Ws2812::new( 25, - pac.PIO0, - &mut pac.RESETS, + &mut pio, + sm0, clocks.peripheral_clock.freq(), timer.count_down(), ); diff --git a/boards/qt_py_rp2040/examples/qt_py_rainbow.rs b/boards/qt_py_rp2040/examples/qt_py_rainbow.rs index b9008b8..367238b 100644 --- a/boards/qt_py_rp2040/examples/qt_py_rainbow.rs +++ b/boards/qt_py_rp2040/examples/qt_py_rainbow.rs @@ -8,6 +8,7 @@ use embedded_hal::digital::v2::OutputPin; use embedded_hal::timer::CountDown; use embedded_time::duration::Extensions; use panic_halt as _; +use rp2040_hal::pio::PIOExt; use smart_leds::{brightness, SmartLedsWrite, RGB8}; use ws2812_pio::Ws2812; @@ -59,13 +60,14 @@ fn main() -> ! { .set_high() .unwrap(); - let timer = rp2040_hal::timer::Timer::new(pac.TIMER); + let timer = rp2040_hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS); let mut delay = timer.count_down(); + let (mut pio, sm0, _, _, _) = pac.PIO0.split(&mut pac.RESETS); let mut ws = Ws2812::new( 12, - pac.PIO0, - &mut pac.RESETS, + &mut pio, + sm0, clocks.peripheral_clock.freq(), timer.count_down(), );