Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PinDetect USBDevice_STM32F103 mbed-STM32F103C8T6
Diff: midiswitch.cpp
- Revision:
- 11:ff22140b5119
- Parent:
- 9:d5fa853818dd
- Child:
- 12:d9ccbfd2cc8c
diff -r f9a48eedfd59 -r ff22140b5119 midiswitch.cpp
--- a/midiswitch.cpp Fri Aug 04 06:08:29 2017 +0200
+++ b/midiswitch.cpp Fri Aug 04 07:23:38 2017 +0200
@@ -29,31 +29,29 @@
bool SwitchHandler::make_message(bool onoff) {
uint8_t value = (onoff ? cfg.on_value : cfg.off_value) & 0x7F;
msg.data[0] = CABLE_NUM | cfg.type;
- msg.data[1] = cfg.type;
+ msg.data[1] = (cfg.type << 4) | (cfg.channel & 0x0F);
+ msg.data[2] = 0x00;
+ msg.data[3] = 0x00;
switch(cfg.type) {
- case 0xFA: // START
- case 0xFB: // CONTINUE
- case 0xFC: // STOP
- msg.data[2] = 0x00;
- msg.data[3] = 0x00;
+ case 2: // START
+ case 3: // CONTINUE
+ case 4: // STOP
+ msg.data[0] = 0xF;
+ msg.data[1] = 0xF8 + cfg.type;
break;
- case 0xC0: // Program change
- case 0xD0: // Channel Aftertouch
- msg.data[1] = msg.data[1] | (cfg.channel & 0x0F);
+ case 0xC: // Program change
+ case 0xD: // Channel Aftertouch
msg.data[2] = value;
- msg.data[3] = 0x00;
break;
- case 0x80: // Note off
- case 0x90: // Note on
- msg.data[1] = msg.data[1] | (cfg.channel & 0x0F);
+ case 0x8: // Note off
+ case 0x9: // Note on
msg.data[3] = value;
msg.data[2] = cfg.data1 & 0x0F;
break;
- case 0xA0: // Poly pressure
- case 0xB0: // Control change
- case 0xE0: // PitchBend
- msg.data[1] = msg.data[1] | (cfg.channel & 0x0F);
+ case 0xA: // Poly pressure
+ case 0xB: // Control change
+ case 0xE: // PitchBend
msg.data[2] = cfg.data1 & 0x0F;
msg.data[3] = value;
break;