Skip to content

Commit

Permalink
Updated example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcebox committed Oct 7, 2024
1 parent b433d0f commit 1f40313
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,31 @@ This crate requires the use of a HAL that implements the `usb-device` traits.
Turn on an LED as long as note C2 is pressed. The example only shows the hardware-independent parts.

```rust
use usb_device::prelude::*;
use usbd_midi::{
data::{
midi::{channel::Channel, message::Message, notes::Note},
usb_midi::midi_packet_reader::MidiPacketBufferReader,
},
midi_device::MidiClass,
};

// Prerequisites, must be setup according to the used board.
let mut led = todo!(); // Must implement `embedded_hal::digital::OutputPin`.
let usb_bus = todo!(); // Must be of type `usb_device::bus::UsbBusAllocator`.

// Create a MIDI class with 1 input and 1 output jack.
let mut midi = MidiClass::new(&usb_bus, 1, 1);

let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x5e4))
.product("MIDI Test")
.device_class(0)
.device_sub_class(0)
.build();
let mut midi = MidiClass::new(&usb_bus, 1, 1).unwrap();

let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x5e4))
.device_class(0)
.device_sub_class(0)
.strings(&[StringDescriptors::default()
.manufacturer("Music Company")
.product("MIDI Device")
.serial_number("12345678")])
.unwrap()
.build();

loop {
if !usb_dev.poll(&mut [&mut midi]) {
Expand Down

0 comments on commit 1f40313

Please sign in to comment.