Last active
October 15, 2020 22:38
-
-
Save johnty/f11681173a0dd5edd79c0863cf116b61 to your computer and use it in GitHub Desktop.
CC MIDI packet with running status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Also, between CC and messages, we need to send another status byte
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The idea worked perfectly, with just a few modifications. I'm sending all in 1 packet (37 bytes), and no problem. I guess I was spamming notify()