Simple USB-MIDI foot controller

Dependencies:   PinDetect USBDevice_STM32F103 mbed-STM32F103C8T6

Committer:
SpotlightKid
Date:
Fri Aug 04 05:22:22 2017 +0200
Revision:
8:75c5ec68765e
Parent:
6:2f804d29cbb0
Child:
9:d5fa853818dd
Make MIDI message type configurable

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SpotlightKid 3:8b8cb5392fa0 1 #ifndef MIDISWITCH_H
SpotlightKid 3:8b8cb5392fa0 2 #define MIDISWITCH_H
SpotlightKid 3:8b8cb5392fa0 3
SpotlightKid 3:8b8cb5392fa0 4 #include "mbed.h"
SpotlightKid 3:8b8cb5392fa0 5 #include "mbed_events.h"
SpotlightKid 3:8b8cb5392fa0 6 #include "PinDetect.h"
SpotlightKid 3:8b8cb5392fa0 7 #include "USBMIDI.h"
SpotlightKid 3:8b8cb5392fa0 8
SpotlightKid 6:2f804d29cbb0 9
SpotlightKid 3:8b8cb5392fa0 10 typedef struct SwitchConfig {
SpotlightKid 3:8b8cb5392fa0 11 PinName pin;
SpotlightKid 8:75c5ec68765e 12 uint8_t type;
SpotlightKid 3:8b8cb5392fa0 13 uint8_t channel;
SpotlightKid 8:75c5ec68765e 14 uint8_t data1;
SpotlightKid 8:75c5ec68765e 15 int8_t on_value;
SpotlightKid 8:75c5ec68765e 16 int8_t off_value;
SpotlightKid 3:8b8cb5392fa0 17 } SwitchConfig;
SpotlightKid 3:8b8cb5392fa0 18
SpotlightKid 3:8b8cb5392fa0 19 typedef void (*MIDI_CB)(MIDIMessage);
SpotlightKid 3:8b8cb5392fa0 20
SpotlightKid 3:8b8cb5392fa0 21 class SwitchHandler {
SpotlightKid 3:8b8cb5392fa0 22 public:
SpotlightKid 8:75c5ec68765e 23 SwitchHandler(EventQueue * queue, MIDI_CB cb, SwitchConfig sw);
SpotlightKid 3:8b8cb5392fa0 24 void handle_pressed(void);
SpotlightKid 3:8b8cb5392fa0 25 void handle_released(void);
SpotlightKid 3:8b8cb5392fa0 26 private:
SpotlightKid 8:75c5ec68765e 27 bool make_message(bool onoff);
SpotlightKid 3:8b8cb5392fa0 28 EventQueue * queue;
SpotlightKid 3:8b8cb5392fa0 29 MIDI_CB write_cb;
SpotlightKid 3:8b8cb5392fa0 30 PinDetect btn;
SpotlightKid 8:75c5ec68765e 31 SwitchConfig cfg;
SpotlightKid 8:75c5ec68765e 32 MIDIMessage msg;
SpotlightKid 3:8b8cb5392fa0 33 };
SpotlightKid 3:8b8cb5392fa0 34
SpotlightKid 3:8b8cb5392fa0 35 #endif /* MIDISWITCH_H */