
Simple USB-MIDI foot controller
Dependencies: PinDetect USBDevice_STM32F103 mbed-STM32F103C8T6
midiswitch.h@13:f9eb1f79cd0a, 2018-01-09 (annotated)
- Committer:
- SpotlightKid
- Date:
- Tue Jan 09 21:59:10 2018 +0100
- Revision:
- 13:f9eb1f79cd0a
- Parent:
- 9:d5fa853818dd
Remove STM32F103C8T6 library and reduced stack sizes
Who changed what in which revision?
User | Revision | Line number | New 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 |
9:d5fa853818dd | 26 | void setConfig(SwitchConfig sw) { cfg = sw; }; |
SpotlightKid |
3:8b8cb5392fa0 | 27 | private: |
SpotlightKid |
8:75c5ec68765e | 28 | bool make_message(bool onoff); |
SpotlightKid |
3:8b8cb5392fa0 | 29 | EventQueue * queue; |
SpotlightKid |
3:8b8cb5392fa0 | 30 | MIDI_CB write_cb; |
SpotlightKid |
3:8b8cb5392fa0 | 31 | PinDetect btn; |
SpotlightKid |
8:75c5ec68765e | 32 | SwitchConfig cfg; |
SpotlightKid |
8:75c5ec68765e | 33 | MIDIMessage msg; |
SpotlightKid |
3:8b8cb5392fa0 | 34 | }; |
SpotlightKid |
3:8b8cb5392fa0 | 35 | |
SpotlightKid |
3:8b8cb5392fa0 | 36 | #endif /* MIDISWITCH_H */ |