Simple USB-MIDI foot controller
Dependencies: PinDetect USBDevice_STM32F103 mbed-STM32F103C8T6
Diff: main.cpp
- Revision:
- 1:61415f07477d
- Parent:
- 0:2f530d7169a6
- Child:
- 3:8b8cb5392fa0
diff -r 2f530d7169a6 -r 61415f07477d main.cpp --- a/main.cpp Sun Jul 30 20:26:29 2017 +0000 +++ b/main.cpp Mon Jul 31 04:40:06 2017 +0000 @@ -14,8 +14,9 @@ class SwitchHandler { public: - SwitchHandler(int ctrl, int ch = 1, int on = 0, int off = 127) : - control(ctrl), channel(ch), on_value(on), off_value(off), b_pressed(false), b_released(false) {}; + explicit SwitchHandler(uint8_t ctrl, uint8_t ch = 1, uint8_t on = 0, uint8_t off = 127) : + control(ctrl), channel(ch), on_value(on), off_value(off), b_pressed(false), b_released(false) { + }; void handle_pressed(void) { b_pressed = true; @@ -30,19 +31,19 @@ led1->write(0); led_ontime = timer->read_us(); serial->printf("Switch pressed: controller=%d channel=%d value=%d\r\n", control, channel, on_value); - midi->write(MIDIMessage::ControlChange(control, on_value, channel)); + midi->write(MIDIMessage::ControlChange((int) control, (int) on_value, (int) (channel - 1))); b_pressed = false; } else if (b_released) { led1->write(0); led_ontime = timer->read_us(); serial->printf("Switch released: control=%d channel=%d value=%d\r\n", control, channel, off_value); - midi->write(MIDIMessage::ControlChange(control, off_value, channel)); + midi->write(MIDIMessage::ControlChange((int) control, (int) off_value, (int) (channel - 1))); b_released = false; } } private: + uint8_t control, channel, on_value, off_value; bool b_pressed, b_released; - int control, channel, on_value, off_value; }; int main() {