Simple USB-MIDI foot controller

Dependencies:   PinDetect USBDevice_STM32F103 mbed-STM32F103C8T6

Revision:
3:8b8cb5392fa0
Child:
6:2f804d29cbb0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/midiswitch.h	Fri Aug 04 03:15:52 2017 +0200
@@ -0,0 +1,38 @@
+#ifndef MIDISWITCH_H
+#define MIDISWITCH_H
+
+#include "mbed.h"
+#include "mbed_events.h"
+#include "PinDetect.h"
+#include "USBMIDI.h"
+
+typedef struct SwitchConfig {
+    PinName pin;
+    uint8_t channel;
+    uint8_t control;
+    uint8_t on_value;
+    uint8_t off_value;
+} SwitchConfig;
+
+
+typedef void (*MIDI_CB)(MIDIMessage);
+
+class SwitchHandler {
+public:
+    SwitchHandler(EventQueue * queue, MIDI_CB cb, SwitchConfig * sw);
+    void handle_pressed(void);
+    void handle_released(void);
+#ifndef NDEBUG
+    void setSerial(Serial * s) { serial = s; };
+#endif  /* NDEBUG */
+private:
+    EventQueue * queue;
+    MIDI_CB write_cb;
+    PinDetect btn;
+    uint8_t control, channel, on_value, off_value;
+#ifndef NDEBUG
+    Serial * serial;
+#endif  /* NDEBUG */
+};
+
+#endif  /* MIDISWITCH_H */