From d57715a161c69a50a0d99a944d672c059e117750 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Tue, 28 Nov 2023 23:23:03 +0000 Subject: [PATCH] factorise a bit the example's boilerplate --- Cargo.toml | 5 -- adafruit-featherwing-oled128x64/Cargo.toml | 15 ++-- .../examples/basic.rs | 16 +--- .../examples/bsp/mod.rs | 16 ++++ .../examples/bsp/pico-explorer-boilerplate.rs | 79 +----------------- .../bsp/pico-explorer-minimal-boilerplate.rs | 8 +- .../bsp/pico-explorer-pio-boilerplate.rs | 83 ++----------------- .../bsp/promicro-rp2040-boilerplate.rs | 81 ++---------------- .../examples/bsp/rpi-pico-boilerplate.rs | 80 ++---------------- .../examples/bsp/timer.rs | 77 +++++++++++++++++ .../examples/embedded-graphics.rs | 16 +--- .../examples/fade-in-and-out.rs | 16 +--- .../examples/scrolling.rs | 16 +--- pico-explorer-boilerplate/Cargo.toml | 19 ----- pico-explorer-minimal-boilerplate/Cargo.toml | 16 ---- pico-explorer-pio-boilerplate/Cargo.toml | 17 ---- promicro-rp2040-boilerplate/Cargo.toml | 17 ---- rpi-pico-boilerplate/Cargo.toml | 17 ---- 18 files changed, 127 insertions(+), 467 deletions(-) create mode 100644 adafruit-featherwing-oled128x64/examples/bsp/mod.rs rename pico-explorer-boilerplate/src/lib.rs => adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-boilerplate.rs (52%) rename pico-explorer-minimal-boilerplate/src/lib.rs => adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-minimal-boilerplate.rs (94%) rename pico-explorer-pio-boilerplate/src/lib.rs => adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-pio-boilerplate.rs (54%) rename promicro-rp2040-boilerplate/src/lib.rs => adafruit-featherwing-oled128x64/examples/bsp/promicro-rp2040-boilerplate.rs (52%) rename rpi-pico-boilerplate/src/lib.rs => adafruit-featherwing-oled128x64/examples/bsp/rpi-pico-boilerplate.rs (52%) create mode 100644 adafruit-featherwing-oled128x64/examples/bsp/timer.rs delete mode 100644 pico-explorer-boilerplate/Cargo.toml delete mode 100644 pico-explorer-minimal-boilerplate/Cargo.toml delete mode 100644 pico-explorer-pio-boilerplate/Cargo.toml delete mode 100644 promicro-rp2040-boilerplate/Cargo.toml delete mode 100644 rpi-pico-boilerplate/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index eb89f86..cee8728 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,6 @@ resolver = "2" members = [ "adafruit-featherwing-oled128x64", "sh1107", - "promicro-rp2040-boilerplate", - "pico-explorer-boilerplate", - "pico-explorer-pio-boilerplate", - "pico-explorer-minimal-boilerplate", - "rpi-pico-boilerplate", ] [profile.release] diff --git a/adafruit-featherwing-oled128x64/Cargo.toml b/adafruit-featherwing-oled128x64/Cargo.toml index fc33898..63e6231 100644 --- a/adafruit-featherwing-oled128x64/Cargo.toml +++ b/adafruit-featherwing-oled128x64/Cargo.toml @@ -21,12 +21,10 @@ cortex-m = "0.7.7" cortex-m-rt = "0.7" embedded-hal = { version = "1.0.0-rc.1" } - -promicro-rp2040-boilerplate = { path = "../promicro-rp2040-boilerplate" } -pico-explorer-boilerplate = { path = "../pico-explorer-boilerplate" } -pico-explorer-pio-boilerplate = { path = "../pico-explorer-pio-boilerplate" } -pico-explorer-minimal-boilerplate = { path = "../pico-explorer-minimal-boilerplate" } -rpi-pico-boilerplate = { path = "../rpi-pico-boilerplate" } +critical-section = "1.1.2" +fugit = "0.3.7" +rp2040-async-i2c = { git = "https://github.com/ithinuel/rp2040-async-i2c", features = ["pio"] } +panic-probe = { version = "0.3.1", features = ["print-defmt"] } arrayvec = { version = "0.7.4", default-features = false } nostd_async = { version = "0.6.1", features = ["cortex_m"] } @@ -37,6 +35,11 @@ futures = { version = "0.3.29", default-features = false, features = [ "async-await", ] } +pimoroni-pico-explorer = { version = "0.7.0" } +rp-pico = { version = "0.8.0" } +sparkfun-pro-micro-rp2040 = { version = "0.7.0" } + + [features] promicro = [] pico-explorer = [] diff --git a/adafruit-featherwing-oled128x64/examples/basic.rs b/adafruit-featherwing-oled128x64/examples/basic.rs index 38a040a..263a923 100644 --- a/adafruit-featherwing-oled128x64/examples/basic.rs +++ b/adafruit-featherwing-oled128x64/examples/basic.rs @@ -1,21 +1,7 @@ #![no_std] #![no_main] -cfg_if::cfg_if! { - if #[cfg(feature = "pico-explorer")] { - use pico_explorer_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-pio")] { - use pico_explorer_pio_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-minimal")] { - use pico_explorer_minimal_boilerplate as bsp; - } else if #[cfg(feature = "promicro")] { - use promicro_rp2040_boilerplate as bsp; - } else if #[cfg(feature = "rpi-pico")] { - use rpi_pico_boilerplate as bsp; - } else { - compile_error!("One platform feature must be selected"); - } -} +mod bsp; use adafruit_featherwing_oled128x64::{Destination, Display, DisplayState}; use defmt_rtt as _; diff --git a/adafruit-featherwing-oled128x64/examples/bsp/mod.rs b/adafruit-featherwing-oled128x64/examples/bsp/mod.rs new file mode 100644 index 0000000..05fa60e --- /dev/null +++ b/adafruit-featherwing-oled128x64/examples/bsp/mod.rs @@ -0,0 +1,16 @@ +cfg_if::cfg_if! { + if #[cfg(feature = "pico-explorer")] { + include!("pico-explorer-boilerplate.rs"); + } else if #[cfg(feature = "pico-explorer-pio")] { + include!("pico-explorer-pio-boilerplate.rs"); + } else if #[cfg(feature = "pico-explorer-minimal")] { + include!("pico-explorer-minimal-boilerplate.rs"); + } else if #[cfg(feature = "promicro")] { + include!("promicro-rp2040-boilerplate.rs"); + } else if #[cfg(feature = "rpi-pico")] { + include!("rpi-pico-boilerplate.rs"); + } else { + compile_error!("One platform feature must be selected"); + } +} + diff --git a/pico-explorer-boilerplate/src/lib.rs b/adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-boilerplate.rs similarity index 52% rename from pico-explorer-boilerplate/src/lib.rs rename to adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-boilerplate.rs index 7fd94a9..fe268b4 100644 --- a/pico-explorer-boilerplate/src/lib.rs +++ b/adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-boilerplate.rs @@ -1,15 +1,7 @@ -#![no_std] - -use core::{ - cell::RefCell, - ops::{Deref, DerefMut}, - task::{Poll, Waker}, -}; +use core::{cell::RefCell, task::Waker}; use critical_section::Mutex; -use embedded_hal_async::i2c::ErrorType; -use fugit::{MicrosDurationU32, RateExtU32}; -use futures::{future, Future}; +use fugit::RateExtU32; use panic_probe as _; use pimoroni_pico_explorer::{all_pins::Pins, hal}; @@ -17,7 +9,6 @@ use hal::{ gpio::{bank0, FunctionI2C, Pin, PullUp}, pac::{self, interrupt}, sio::Sio, - timer::{Alarm, Alarm0}, watchdog::Watchdog, Clock, }; @@ -25,7 +16,6 @@ use hal::{ use rp2040_async_i2c::i2c::I2C; pub use embedded_hal_async::i2c::SevenBitAddress; -pub use hal::timer::Timer; pub use pimoroni_pico_explorer::entry; pub type I2CPeriph = I2C< @@ -36,69 +26,8 @@ pub type I2CPeriph = I2C< ), >; -type Alarm0WakerCTX = (Alarm0, Option); -static ALARM0_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); -pub async fn wait_for(timer: &Timer, delay: u32) { - if delay < 20 { - let start = timer.get_counter_low(); - future::poll_fn(|cx| { - if timer.get_counter_low().wrapping_sub(start) < delay { - cx.waker().wake_by_ref(); - Poll::Pending - } else { - Poll::Ready(()) - } - }) - .await; - } else { - let mut started = false; - future::poll_fn(move |cx| { - critical_section::with(|cs| { - if let Some((alarm, waker)) = ALARM0_WAKER.borrow_ref_mut(cs).as_mut() { - if !started { - alarm.clear_interrupt(); - alarm.enable_interrupt(); - alarm.schedule(MicrosDurationU32::micros(delay)).unwrap(); - started = true; - *waker = Some(cx.waker().clone()); - Poll::Pending - } else if alarm.finished() { - Poll::Ready(()) - } else { - *waker = Some(cx.waker().clone()); - Poll::Pending - } - } else { - unreachable!() - } - }) - }) - .await; - } -} - -pub async fn timed(op: &str, timer: &Timer, fut: impl Future) -> T { - let start = timer.get_counter_low(); - let res = fut.await; - let diff = timer.get_counter_low().wrapping_sub(start); - defmt::info!("{} took {}us", op, diff); - res -} - -#[interrupt] -#[allow(non_snake_case)] -fn TIMER_IRQ_0() { - critical_section::with(|cs| { - ALARM0_WAKER - .borrow_ref_mut(cs) - .as_mut() - .and_then(|(alarm, waker)| { - alarm.disable_interrupt(); - waker.take() - }) - .map(|waker| waker.wake()) - }); -} +mod timer; +pub use timer::*; static I2C_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); pub fn waker_setter(waker: Waker) { diff --git a/pico-explorer-minimal-boilerplate/src/lib.rs b/adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-minimal-boilerplate.rs similarity index 94% rename from pico-explorer-minimal-boilerplate/src/lib.rs rename to adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-minimal-boilerplate.rs index 1845f58..09d0c84 100644 --- a/pico-explorer-minimal-boilerplate/src/lib.rs +++ b/adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-minimal-boilerplate.rs @@ -1,11 +1,5 @@ -#![no_std] +use core::task::Poll; -use core::{ - ops::{Deref, DerefMut}, - task::Poll, -}; - -use embedded_hal_async::i2c::ErrorType; use fugit::{ExtU32, RateExtU32}; use futures::{future, Future}; use panic_probe as _; diff --git a/pico-explorer-pio-boilerplate/src/lib.rs b/adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-pio-boilerplate.rs similarity index 54% rename from pico-explorer-pio-boilerplate/src/lib.rs rename to adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-pio-boilerplate.rs index 6786a6c..3e37b7d 100644 --- a/pico-explorer-pio-boilerplate/src/lib.rs +++ b/adafruit-featherwing-oled128x64/examples/bsp/pico-explorer-pio-boilerplate.rs @@ -1,21 +1,13 @@ -#![no_std] - -use core::{ - cell::RefCell, - ops::{Deref, DerefMut}, - task::{Poll, Waker}, -}; +use core::cell::RefCell; use critical_section::Mutex; -use embedded_hal_async::i2c::ErrorType; -use fugit::{MicrosDurationU32, RateExtU32}; -use futures::{future, Future}; +use fugit::RateExtU32; use panic_probe as _; use pimoroni_pico_explorer::{ all_pins::Pins, hal::{ self, - gpio::{FunctionNull, PullUp, Pin}, + gpio::{FunctionNull, Pin, PullUp}, pio::PIOExt, pio::SM0, }, @@ -26,7 +18,6 @@ use hal::{ gpio::bank0, pac::{self, interrupt}, sio::Sio, - timer::{Alarm, Alarm0}, watchdog::Watchdog, Clock, }; @@ -34,9 +25,11 @@ use hal::{ use rp2040_async_i2c::pio::I2C; pub use embedded_hal_async::i2c::SevenBitAddress; -pub use hal::timer::Timer; pub use pimoroni_pico_explorer::entry; +mod timer; +pub use timer::*; + pub type I2CPeriph = I2C< 'static, PIO0, @@ -45,70 +38,6 @@ pub type I2CPeriph = I2C< Pin, >; -type Alarm0WakerCTX = (Alarm0, Option); -static ALARM0_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); -pub async fn wait_for(timer: &Timer, delay: u32) { - if delay < 20 { - let start = timer.get_counter_low(); - future::poll_fn(|cx| { - if timer.get_counter_low().wrapping_sub(start) < delay { - cx.waker().wake_by_ref(); - Poll::Pending - } else { - Poll::Ready(()) - } - }) - .await; - } else { - let mut started = false; - future::poll_fn(move |cx| { - critical_section::with(|cs| { - if let Some((alarm, waker)) = ALARM0_WAKER.borrow_ref_mut(cs).as_mut() { - if !started { - alarm.clear_interrupt(); - alarm.enable_interrupt(); - alarm.schedule(MicrosDurationU32::micros(delay)).unwrap(); - started = true; - *waker = Some(cx.waker().clone()); - Poll::Pending - } else if alarm.finished() { - Poll::Ready(()) - } else { - *waker = Some(cx.waker().clone()); - Poll::Pending - } - } else { - unreachable!() - } - }) - }) - .await; - } -} - -pub async fn timed(op: &str, timer: &Timer, fut: impl Future) -> T { - let start = timer.get_counter_low(); - let res = fut.await; - let diff = timer.get_counter_low().wrapping_sub(start); - defmt::info!("{} took {}us", op, diff); - res -} - -#[interrupt] -#[allow(non_snake_case)] -fn TIMER_IRQ_0() { - critical_section::with(|cs| { - ALARM0_WAKER - .borrow_ref_mut(cs) - .as_mut() - .and_then(|(alarm, waker)| { - alarm.disable_interrupt(); - waker.take() - }) - .map(|waker| waker.wake()) - }); -} - static mut PIO: Option> = None; static PIO_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); fn waker_setter(waker: core::task::Waker) { diff --git a/promicro-rp2040-boilerplate/src/lib.rs b/adafruit-featherwing-oled128x64/examples/bsp/promicro-rp2040-boilerplate.rs similarity index 52% rename from promicro-rp2040-boilerplate/src/lib.rs rename to adafruit-featherwing-oled128x64/examples/bsp/promicro-rp2040-boilerplate.rs index 2b35220..54fd8aa 100644 --- a/promicro-rp2040-boilerplate/src/lib.rs +++ b/adafruit-featherwing-oled128x64/examples/bsp/promicro-rp2040-boilerplate.rs @@ -1,15 +1,7 @@ -#![no_std] - -use core::{ - cell::RefCell, - ops::{Deref, DerefMut}, - task::{Poll, Waker}, -}; +use core::{cell::RefCell, task::Waker}; use critical_section::Mutex; -use embedded_hal_async::i2c::ErrorType; -use fugit::{MicrosDurationU32, RateExtU32}; -use futures::{future, Future}; +use fugit::RateExtU32; use panic_probe as _; use sparkfun_pro_micro_rp2040::{hal, Pins}; @@ -17,7 +9,6 @@ use hal::{ gpio::{bank0, FunctionI2C, Pin, PullUp}, pac::{self, interrupt}, sio::Sio, - timer::{Alarm, Alarm0}, watchdog::Watchdog, Clock, }; @@ -25,9 +16,11 @@ use hal::{ use rp2040_async_i2c::i2c::I2C; pub use embedded_hal_async::i2c::SevenBitAddress; -pub use hal::timer::Timer; pub use sparkfun_pro_micro_rp2040::entry; +mod timer; +pub use timer::*; + pub type I2CPeriph = I2C< pac::I2C0, ( @@ -36,70 +29,6 @@ pub type I2CPeriph = I2C< ), >; -type Alarm0WakerCTX = (Alarm0, Option); -static ALARM0_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); -pub async fn wait_for(timer: &Timer, delay: u32) { - if delay < 20 { - let start = timer.get_counter_low(); - future::poll_fn(|cx| { - if timer.get_counter_low().wrapping_sub(start) < delay { - cx.waker().wake_by_ref(); - Poll::Pending - } else { - Poll::Ready(()) - } - }) - .await; - } else { - let mut started = false; - future::poll_fn(move |cx| { - critical_section::with(|cs| { - if let Some((alarm, waker)) = ALARM0_WAKER.borrow_ref_mut(cs).as_mut() { - if !started { - alarm.clear_interrupt(); - alarm.enable_interrupt(); - alarm.schedule(MicrosDurationU32::micros(delay)).unwrap(); - started = true; - *waker = Some(cx.waker().clone()); - Poll::Pending - } else if alarm.finished() { - Poll::Ready(()) - } else { - *waker = Some(cx.waker().clone()); - Poll::Pending - } - } else { - unreachable!() - } - }) - }) - .await; - } -} - -pub async fn timed(op: &str, timer: &Timer, fut: impl Future) -> T { - let start = timer.get_counter_low(); - let res = fut.await; - let diff = timer.get_counter_low().wrapping_sub(start); - defmt::info!("{} took {}us", op, diff); - res -} - -#[interrupt] -#[allow(non_snake_case)] -fn TIMER_IRQ_0() { - critical_section::with(|cs| { - ALARM0_WAKER - .borrow_ref_mut(cs) - .as_mut() - .and_then(|(alarm, waker)| { - alarm.disable_interrupt(); - waker.take() - }) - .map(|waker| waker.wake()) - }); -} - static I2C_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); pub fn waker_setter(waker: Waker) { critical_section::with(|cs| { diff --git a/rpi-pico-boilerplate/src/lib.rs b/adafruit-featherwing-oled128x64/examples/bsp/rpi-pico-boilerplate.rs similarity index 52% rename from rpi-pico-boilerplate/src/lib.rs rename to adafruit-featherwing-oled128x64/examples/bsp/rpi-pico-boilerplate.rs index ec4826b..3e2793d 100644 --- a/rpi-pico-boilerplate/src/lib.rs +++ b/adafruit-featherwing-oled128x64/examples/bsp/rpi-pico-boilerplate.rs @@ -1,15 +1,7 @@ -#![no_std] - -use core::{ - cell::RefCell, - ops::{Deref, DerefMut}, - task::{Poll, Waker}, -}; +use core::{cell::RefCell, task::Waker}; use critical_section::Mutex; -use embedded_hal_async::i2c::ErrorType; -use fugit::{MicrosDurationU32, RateExtU32}; -use futures::{future, Future}; +use fugit::RateExtU32; use panic_probe as _; use rp_pico::{hal, Pins}; @@ -17,7 +9,6 @@ use hal::{ gpio::{bank0, FunctionI2C, Pin, PullUp}, pac::{self, interrupt}, sio::Sio, - timer::{Alarm, Alarm0}, watchdog::Watchdog, Clock, }; @@ -28,6 +19,9 @@ pub use embedded_hal_async::i2c::SevenBitAddress; pub use hal::timer::Timer; pub use rp_pico::entry; +mod timer; +pub use timer::*; + pub type I2CPeriph = I2C< pac::I2C1, ( @@ -36,70 +30,6 @@ pub type I2CPeriph = I2C< ), >; -type Alarm0WakerCTX = (Alarm0, Option); -static ALARM0_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); -pub async fn wait_for(timer: &Timer, delay: u32) { - if delay < 20 { - let start = timer.get_counter_low(); - future::poll_fn(|cx| { - if timer.get_counter_low().wrapping_sub(start) < delay { - cx.waker().wake_by_ref(); - Poll::Pending - } else { - Poll::Ready(()) - } - }) - .await; - } else { - let mut started = false; - future::poll_fn(move |cx| { - critical_section::with(|cs| { - if let Some((alarm, waker)) = ALARM0_WAKER.borrow_ref_mut(cs).as_mut() { - if !started { - alarm.clear_interrupt(); - alarm.enable_interrupt(); - alarm.schedule(MicrosDurationU32::micros(delay)).unwrap(); - started = true; - *waker = Some(cx.waker().clone()); - Poll::Pending - } else if alarm.finished() { - Poll::Ready(()) - } else { - *waker = Some(cx.waker().clone()); - Poll::Pending - } - } else { - unreachable!() - } - }) - }) - .await; - } -} - -pub async fn timed(op: &str, timer: &Timer, fut: impl Future) -> T { - let start = timer.get_counter_low(); - let res = fut.await; - let diff = timer.get_counter_low().wrapping_sub(start); - defmt::info!("{} took {}us", op, diff); - res -} - -#[interrupt] -#[allow(non_snake_case)] -fn TIMER_IRQ_0() { - critical_section::with(|cs| { - ALARM0_WAKER - .borrow_ref_mut(cs) - .as_mut() - .and_then(|(alarm, waker)| { - alarm.disable_interrupt(); - waker.take() - }) - .map(|waker| waker.wake()) - }); -} - static I2C_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); pub fn waker_setter(waker: Waker) { critical_section::with(|cs| { diff --git a/adafruit-featherwing-oled128x64/examples/bsp/timer.rs b/adafruit-featherwing-oled128x64/examples/bsp/timer.rs new file mode 100644 index 0000000..21f2fb9 --- /dev/null +++ b/adafruit-featherwing-oled128x64/examples/bsp/timer.rs @@ -0,0 +1,77 @@ +use core::{ + cell::RefCell, + task::{Poll, Waker}, +}; + +use critical_section::Mutex; +use fugit::MicrosDurationU32; +use futures::{future, Future}; +use panic_probe as _; + +use super::hal::{ + pac::interrupt, + timer::{Alarm, Alarm0, }, +}; +pub use super::hal::timer::Timer; + +type Alarm0WakerCTX = (Alarm0, Option); +pub static ALARM0_WAKER: Mutex>> = Mutex::new(RefCell::new(None)); +pub async fn wait_for(timer: &Timer, delay: u32) { + if delay < 20 { + let start = timer.get_counter_low(); + future::poll_fn(|cx| { + if timer.get_counter_low().wrapping_sub(start) < delay { + cx.waker().wake_by_ref(); + Poll::Pending + } else { + Poll::Ready(()) + } + }) + .await; + } else { + let mut started = false; + future::poll_fn(move |cx| { + critical_section::with(|cs| { + if let Some((alarm, waker)) = ALARM0_WAKER.borrow_ref_mut(cs).as_mut() { + if !started { + alarm.clear_interrupt(); + alarm.enable_interrupt(); + alarm.schedule(MicrosDurationU32::micros(delay)).unwrap(); + started = true; + *waker = Some(cx.waker().clone()); + Poll::Pending + } else if alarm.finished() { + Poll::Ready(()) + } else { + *waker = Some(cx.waker().clone()); + Poll::Pending + } + } else { + unreachable!() + } + }) + }) + .await; + } +} + +pub async fn timed(op: &str, timer: &Timer, fut: impl Future) -> T { + let start = timer.get_counter_low(); + let res = fut.await; + let diff = timer.get_counter_low().wrapping_sub(start); + defmt::info!("{} took {}us", op, diff); + res +} + +#[interrupt] +#[allow(non_snake_case)] +fn TIMER_IRQ_0() { + critical_section::with(|cs| { + let mut binding = ALARM0_WAKER.borrow_ref_mut(cs); + let Some((alarm, waker)) = binding.as_mut() else { + unreachable!() + }; + alarm.disable_interrupt(); + waker.take().map(Waker::wake); + }); +} diff --git a/adafruit-featherwing-oled128x64/examples/embedded-graphics.rs b/adafruit-featherwing-oled128x64/examples/embedded-graphics.rs index b9be7ab..bb35bfd 100644 --- a/adafruit-featherwing-oled128x64/examples/embedded-graphics.rs +++ b/adafruit-featherwing-oled128x64/examples/embedded-graphics.rs @@ -12,21 +12,7 @@ use embedded_graphics::{ Drawable, }; -cfg_if::cfg_if! { - if #[cfg(feature = "pico-explorer")] { - use pico_explorer_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-pio")] { - use pico_explorer_pio_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-minimal")] { - use pico_explorer_minimal_boilerplate as bsp; - } else if #[cfg(feature = "promicro")] { - use promicro_rp2040_boilerplate as bsp; - } else if #[cfg(feature = "rpi-pico")] { - use rpi_pico_boilerplate as bsp; - } else { - compile_error!("One platform feature must be selected"); - } -} +mod bsp; use adafruit_featherwing_oled128x64::{BufferedDisplay, DisplayState, PAGE}; use defmt_rtt as _; diff --git a/adafruit-featherwing-oled128x64/examples/fade-in-and-out.rs b/adafruit-featherwing-oled128x64/examples/fade-in-and-out.rs index b7a7c46..2a06311 100644 --- a/adafruit-featherwing-oled128x64/examples/fade-in-and-out.rs +++ b/adafruit-featherwing-oled128x64/examples/fade-in-and-out.rs @@ -1,21 +1,7 @@ #![no_std] #![no_main] -cfg_if::cfg_if! { - if #[cfg(feature = "pico-explorer")] { - use pico_explorer_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-pio")] { - use pico_explorer_pio_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-minimal")] { - use pico_explorer_minimal_boilerplate as bsp; - } else if #[cfg(feature = "promicro")] { - use promicro_rp2040_boilerplate as bsp; - } else if #[cfg(feature = "rpi-pico")] { - use rpi_pico_boilerplate as bsp; - } else { - compile_error!("One platform feature must be selected"); - } -} +mod bsp; use adafruit_featherwing_oled128x64::{Destination, Display, DisplayState}; use defmt_rtt as _; diff --git a/adafruit-featherwing-oled128x64/examples/scrolling.rs b/adafruit-featherwing-oled128x64/examples/scrolling.rs index 7efdd55..e3a405b 100644 --- a/adafruit-featherwing-oled128x64/examples/scrolling.rs +++ b/adafruit-featherwing-oled128x64/examples/scrolling.rs @@ -1,21 +1,7 @@ #![no_std] #![no_main] -cfg_if::cfg_if! { - if #[cfg(feature = "pico-explorer")] { - use pico_explorer_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-pio")] { - use pico_explorer_pio_boilerplate as bsp; - } else if #[cfg(feature = "pico-explorer-minimal")] { - use pico_explorer_minimal_boilerplate as bsp; - } else if #[cfg(feature = "promicro")] { - use promicro_rp2040_boilerplate as bsp; - } else if #[cfg(feature = "rpi-pico")] { - use rpi_pico_boilerplate as bsp; - } else { - compile_error!("One platform feature must be selected"); - } -} +mod bsp; use adafruit_featherwing_oled128x64::{Destination, Display, DisplayState}; use defmt_rtt as _; diff --git a/pico-explorer-boilerplate/Cargo.toml b/pico-explorer-boilerplate/Cargo.toml deleted file mode 100644 index 2a5e409..0000000 --- a/pico-explorer-boilerplate/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "pico-explorer-boilerplate" -version = "0.1.0" -edition = "2021" -# demo crate, not meant to be published -publish = false - -[dependencies] -critical-section = "1.1.2" -defmt = "0.3.5" -embedded-hal-async = "1.0.0-rc.1" -fugit = "0.3.7" -futures = { version = "0.3.29", default-features = false } -panic-probe = { version = "0.3.1", features = ["print-defmt"] } -pimoroni-pico-explorer = "0.7.0" -rp2040-async-i2c = { git = "https://github.com/ithinuel/rp2040-async-i2c", features = [ - "pio", -] } -sh1107 = { version = "0.1.0", path = "../sh1107" } diff --git a/pico-explorer-minimal-boilerplate/Cargo.toml b/pico-explorer-minimal-boilerplate/Cargo.toml deleted file mode 100644 index c9ba15c..0000000 --- a/pico-explorer-minimal-boilerplate/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "pico-explorer-minimal-boilerplate" -version = "0.1.0" -edition = "2021" -# demo crate, not meant to be published -publish = false - -[dependencies] -defmt = "0.3.5" -embedded-hal-async = "1.0.0-rc.1" -fugit = "0.3.7" -futures = { version = "0.3.29", default-features = false } -panic-probe = { version = "0.3.1", features = ["print-defmt"] } -pimoroni-pico-explorer = "0.7.0" -rp2040-async-i2c = { git = "https://github.com/ithinuel/rp2040-async-i2c", features = ["pio"] } -sh1107 = { version = "0.1.0", path = "../sh1107" } diff --git a/pico-explorer-pio-boilerplate/Cargo.toml b/pico-explorer-pio-boilerplate/Cargo.toml deleted file mode 100644 index c2857c1..0000000 --- a/pico-explorer-pio-boilerplate/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "pico-explorer-pio-boilerplate" -version = "0.1.0" -edition = "2021" -# demo crate, not meant to be published -publish = false - -[dependencies] -critical-section = "1.1.2" -defmt = "0.3.5" -embedded-hal-async = "1.0.0-rc.1" -fugit = "0.3.7" -futures = { version = "0.3.29", default-features = false } -panic-probe = { version = "0.3.1", features = ["print-defmt"] } -pimoroni-pico-explorer = "0.7.0" -rp2040-async-i2c = { git = "https://github.com/ithinuel/rp2040-async-i2c" } -sh1107 = { version = "0.1.0", path = "../sh1107" } diff --git a/promicro-rp2040-boilerplate/Cargo.toml b/promicro-rp2040-boilerplate/Cargo.toml deleted file mode 100644 index d694b61..0000000 --- a/promicro-rp2040-boilerplate/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "promicro-rp2040-boilerplate" -version = "0.1.0" -edition = "2021" -# demo crate, not meant to be published -publish = false - -[dependencies] -critical-section = "1.1.2" -defmt = "0.3.5" -embedded-hal-async = "1.0.0-rc.1" -fugit = "0.3.7" -futures = { version = "0.3.29", default-features = false } -panic-probe = { version = "0.3.1", features = ["print-defmt"] } -rp2040-async-i2c = { git = "https://github.com/ithinuel/rp2040-async-i2c" } -sh1107 = { version = "0.1.0", path = "../sh1107" } -sparkfun-pro-micro-rp2040 = "0.7.0" diff --git a/rpi-pico-boilerplate/Cargo.toml b/rpi-pico-boilerplate/Cargo.toml deleted file mode 100644 index 2f2371e..0000000 --- a/rpi-pico-boilerplate/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "rpi-pico-boilerplate" -version = "0.1.0" -edition = "2021" -# demo crate, not meant to be published -publish = false - -[dependencies] -critical-section = "1.1.2" -defmt = "0.3.5" -embedded-hal-async = "1.0.0-rc.1" -fugit = "0.3.7" -futures = { version = "0.3.29", default-features = false } -panic-probe = { version = "0.3.1", features = ["print-defmt"] } -rp-pico = "0.8.0" -rp2040-async-i2c = { git = "https://github.com/ithinuel/rp2040-async-i2c" } -sh1107 = { version = "0.1.0", path = "../sh1107" }