diff --git a/Cargo.toml b/Cargo.toml index 8b413ab..e934995 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ name = "geode-piano" version = "0.1.0" edition = "2021" license = "GPL-3.0-only" -license-file = "LICENSE" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/geode_midi.rs b/src/geode_midi.rs index cc4fdb5..1ec2d5d 100644 --- a/src/geode_midi.rs +++ b/src/geode_midi.rs @@ -20,12 +20,8 @@ //! //! This sets up a queue of MIDI packets to send on behalf of other tasks. -use embassy_rp::{ - peripherals::USB, - usb::{Driver, Instance}, -}; +use embassy_rp::usb::{Driver, Instance}; use embassy_sync::{blocking_mutex::raw::ThreadModeRawMutex, channel::Channel}; -use embassy_time::Timer; use embassy_usb::{class::midi::MidiClass, driver::EndpointError}; struct NoteMsg { @@ -112,16 +108,6 @@ pub async fn midi_session<'d, T: Instance + 'd>( } } -/// Wrapper to reconnect to MIDI upon disconnection. -#[embassy_executor::task] -pub async fn midi_task(mut midi: MidiClass<'static, Driver<'static, USB>>) -> ! { - loop { - log::info!("Connected"); - midi_session(&mut midi); - log::info!("Disconnected"); - } -} - /// Public MIDI interface that can be used to send notes/control packets. pub struct MidiChannel { channel: u8, diff --git a/src/geode_usb.rs b/src/geode_usb.rs index e9efc12..ee67a64 100644 --- a/src/geode_usb.rs +++ b/src/geode_usb.rs @@ -33,12 +33,10 @@ DEALINGS IN THE SOFTWARE. use embassy_futures::join::join; use embassy_rp::{peripherals::USB, usb::Driver}; -use crate::geode_midi; use crate::geode_midi::midi_session; use embassy_usb::class::cdc_acm::CdcAcmClass; use embassy_usb::class::cdc_acm::State; use embassy_usb::class::midi::MidiClass; -use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config}; #[embassy_executor::task] @@ -96,8 +94,9 @@ pub async fn usb_task( let midi_fut = async { loop { + midi_class.wait_connection().await; log::info!("Connected"); - midi_session(&mut midi_class).await; + let _ = midi_session(&mut midi_class).await; log::info!("Disconnected"); } }; diff --git a/src/main.rs b/src/main.rs index 8354a25..598cfa7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,13 @@ #![no_std] #![no_main] -#![allow(dead_code)] -#![allow(unused)] use embassy_executor::Spawner; -use embassy_futures::join::join; use embassy_rp::bind_interrupts; use embassy_rp::gpio; use embassy_rp::gpio::AnyPin; use embassy_rp::gpio::Input; use embassy_rp::gpio::Pull; use embassy_rp::peripherals::USB; -use embassy_rp::usb::Instance; use embassy_rp::usb::{Driver, InterruptHandler}; use embassy_time::Timer; use geode_usb::usb_task; @@ -46,7 +42,7 @@ enum Note { #[embassy_executor::task(pool_size = 2)] async fn button(pin: AnyPin, note: Note) { let mut button = Input::new(pin, Pull::Up); - let mut chan = geode_midi::MidiChannel::new(0); + let chan = geode_midi::MidiChannel::new(0); loop { let mut counter = 10; button.wait_for_falling_edge().await;