Skip to content

Instantly share code, notes, and snippets.

@johnty
Last active October 15, 2020 22:38
Show Gist options
  • Save johnty/f11681173a0dd5edd79c0863cf116b61 to your computer and use it in GitHub Desktop.
Save johnty/f11681173a0dd5edd79c0863cf116b61 to your computer and use it in GitHub Desktop.
CC MIDI packet with running status
uint8_t midiPacket[15] = {
0b10000000,  // header
0b10000000,  // timestamp, not implemented
0b00000000,  // status byte
21,
midi.mapMIDI(abs(imu.getAccelX()), 0, 50));// CC 021 (0b00010101) (for X-axis accelerometer)
22,
midi.mapMIDI(abs(imu.getAccelY()), 0, 50));// CC 022 (0b00010110) (for Y-axis accelerometer)
23,
midi.mapMIDI(abs(imu.getAccelZ()), 0, 50));// CC 023 (0b00010111) (for Z-axis accelerometer)
24,
midi.mapMIDI(abs(imu.getGyroX()), 0, 25)); // CC 024 (0b00011000) (for X-axis gyroscope)
25,
midi.mapMIDI(abs(imu.getGyroY()), 0, 25)); // CC 025 (0b00011001) (for Y-axis gyroscope)
26,
midi.mapMIDI(abs(imu.getGyroZ()), 0, 25)); // CC 026 (0b00011010) (for Z-axis gyroscope)
};
pCharacteristic->setValue(midiPacket, 15);
pCharacteristic->notify();
@edumeneses
Copy link

Also, between CC and messages, we need to send another status byte

@johnty
Copy link
Author

johnty commented Oct 15, 2020

great! in the past i think you can only do 20 bytes, but maybe now it supports longer packets. just double check all 37 bytes make it to the other end and it should be good.

for the status byte - do you just need a status byte for it to work when changing message types, or do you need another "timestamp low" byte as well? from the specs below, its not clear what one should do if the message type changes.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment