From c6738b4f8730e3b2d86243d4e147895b57d4941b Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 5 Apr 2021 22:36:35 +0200 Subject: [PATCH] cleanup rp examples --- embassy-rp-examples/src/bin/blinky.rs | 3 ++- embassy-rp-examples/src/bin/button.rs | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/embassy-rp-examples/src/bin/blinky.rs b/embassy-rp-examples/src/bin/blinky.rs index 8454ca56d..34e3cafc3 100644 --- a/embassy-rp-examples/src/bin/blinky.rs +++ b/embassy-rp-examples/src/bin/blinky.rs @@ -13,12 +13,13 @@ use defmt::*; use embassy::executor::Spawner; use embassy_rp::{gpio, Peripherals}; use embedded_hal::digital::v2::OutputPin; +use gpio::{Level, Output}; #[embassy::main] async fn main(_spawner: Spawner) { let p = unwrap!(Peripherals::take()); - let mut led = gpio::Output::new(p.PIN_25, gpio::Level::Low); + let mut led = Output::new(p.PIN_25, Level::Low); loop { info!("led on!"); diff --git a/embassy-rp-examples/src/bin/button.rs b/embassy-rp-examples/src/bin/button.rs index 2b3285ce6..77d4c57a9 100644 --- a/embassy-rp-examples/src/bin/button.rs +++ b/embassy-rp-examples/src/bin/button.rs @@ -11,18 +11,22 @@ mod example_common; use defmt::*; use embassy::executor::Spawner; -use embassy_rp::gpio::{Input, Pull}; +use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::Peripherals; -use embedded_hal::digital::v2::InputPin; +use embedded_hal::digital::v2::{InputPin, OutputPin}; #[embassy::main] async fn main(_spawner: Spawner) { let p = unwrap!(Peripherals::take()); let button = Input::new(p.PIN_28, Pull::Up); + let mut led = Output::new(p.PIN_25, Level::Low); loop { - info!("high? {=bool}", button.is_high().unwrap()); - cortex_m::asm::delay(1_000_000); + if button.is_high().unwrap() { + led.set_high().unwrap(); + } else { + led.set_low().unwrap(); + } } }