Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Committer:
gert_lauritsen
Date:
Fri Jul 05 12:55:53 2019 +0000
Branch:
MbedBMAGThrRev
Revision:
61:52a6d0ffd8e5
dato rettel og ID i file lagt ind i version 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gert_lauritsen 61:52a6d0ffd8e5 1 /* Copyright (c) 2014 mbed.org, MIT License
gert_lauritsen 61:52a6d0ffd8e5 2 *
gert_lauritsen 61:52a6d0ffd8e5 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
gert_lauritsen 61:52a6d0ffd8e5 4 * and associated documentation files (the "Software"), to deal in the Software without
gert_lauritsen 61:52a6d0ffd8e5 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
gert_lauritsen 61:52a6d0ffd8e5 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
gert_lauritsen 61:52a6d0ffd8e5 7 * Software is furnished to do so, subject to the following conditions:
gert_lauritsen 61:52a6d0ffd8e5 8 *
gert_lauritsen 61:52a6d0ffd8e5 9 * The above copyright notice and this permission notice shall be included in all copies or
gert_lauritsen 61:52a6d0ffd8e5 10 * substantial portions of the Software.
gert_lauritsen 61:52a6d0ffd8e5 11 *
gert_lauritsen 61:52a6d0ffd8e5 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
gert_lauritsen 61:52a6d0ffd8e5 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
gert_lauritsen 61:52a6d0ffd8e5 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
gert_lauritsen 61:52a6d0ffd8e5 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
gert_lauritsen 61:52a6d0ffd8e5 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
gert_lauritsen 61:52a6d0ffd8e5 17 */
gert_lauritsen 61:52a6d0ffd8e5 18
gert_lauritsen 61:52a6d0ffd8e5 19 #ifndef USBHOSTMIDI_H
gert_lauritsen 61:52a6d0ffd8e5 20 #define USBHOSTMIDI_H
gert_lauritsen 61:52a6d0ffd8e5 21
gert_lauritsen 61:52a6d0ffd8e5 22 #include "USBHostConf.h"
gert_lauritsen 61:52a6d0ffd8e5 23
gert_lauritsen 61:52a6d0ffd8e5 24 #if USBHOST_MIDI
gert_lauritsen 61:52a6d0ffd8e5 25
gert_lauritsen 61:52a6d0ffd8e5 26 #include "USBHost.h"
gert_lauritsen 61:52a6d0ffd8e5 27
gert_lauritsen 61:52a6d0ffd8e5 28 /**
gert_lauritsen 61:52a6d0ffd8e5 29 * A class to communicate a USB MIDI device
gert_lauritsen 61:52a6d0ffd8e5 30 */
gert_lauritsen 61:52a6d0ffd8e5 31 class USBHostMIDI : public IUSBEnumerator {
gert_lauritsen 61:52a6d0ffd8e5 32 public:
gert_lauritsen 61:52a6d0ffd8e5 33 /**
gert_lauritsen 61:52a6d0ffd8e5 34 * Constructor
gert_lauritsen 61:52a6d0ffd8e5 35 */
gert_lauritsen 61:52a6d0ffd8e5 36 USBHostMIDI();
gert_lauritsen 61:52a6d0ffd8e5 37
gert_lauritsen 61:52a6d0ffd8e5 38 /**
gert_lauritsen 61:52a6d0ffd8e5 39 * Check if a USB MIDI device is connected
gert_lauritsen 61:52a6d0ffd8e5 40 *
gert_lauritsen 61:52a6d0ffd8e5 41 * @returns true if a midi device is connected
gert_lauritsen 61:52a6d0ffd8e5 42 */
gert_lauritsen 61:52a6d0ffd8e5 43 bool connected();
gert_lauritsen 61:52a6d0ffd8e5 44
gert_lauritsen 61:52a6d0ffd8e5 45 /**
gert_lauritsen 61:52a6d0ffd8e5 46 * Try to connect a midi device
gert_lauritsen 61:52a6d0ffd8e5 47 *
gert_lauritsen 61:52a6d0ffd8e5 48 * @return true if connection was successful
gert_lauritsen 61:52a6d0ffd8e5 49 */
gert_lauritsen 61:52a6d0ffd8e5 50 bool connect();
gert_lauritsen 61:52a6d0ffd8e5 51
gert_lauritsen 61:52a6d0ffd8e5 52 /**
gert_lauritsen 61:52a6d0ffd8e5 53 * Attach a callback called when miscellaneous function code is received
gert_lauritsen 61:52a6d0ffd8e5 54 *
gert_lauritsen 61:52a6d0ffd8e5 55 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 56 * prototype: void onMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 57 */
gert_lauritsen 61:52a6d0ffd8e5 58 inline void attachMiscellaneousFunctionCode(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 59 miscellaneousFunctionCode = fn;
gert_lauritsen 61:52a6d0ffd8e5 60 }
gert_lauritsen 61:52a6d0ffd8e5 61
gert_lauritsen 61:52a6d0ffd8e5 62 /**
gert_lauritsen 61:52a6d0ffd8e5 63 * Attach a callback called when cable event is received
gert_lauritsen 61:52a6d0ffd8e5 64 *
gert_lauritsen 61:52a6d0ffd8e5 65 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 66 * prototype: void onCableEvent(uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 67 */
gert_lauritsen 61:52a6d0ffd8e5 68 inline void attachCableEvent(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 69 cableEvent = fn;
gert_lauritsen 61:52a6d0ffd8e5 70 }
gert_lauritsen 61:52a6d0ffd8e5 71
gert_lauritsen 61:52a6d0ffd8e5 72 /**
gert_lauritsen 61:52a6d0ffd8e5 73 * Attach a callback called when system exclusive is received
gert_lauritsen 61:52a6d0ffd8e5 74 *
gert_lauritsen 61:52a6d0ffd8e5 75 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 76 * prototype: void onSystemCommonTwoBytes(uint8_t data1, uint8_t data2);
gert_lauritsen 61:52a6d0ffd8e5 77 */
gert_lauritsen 61:52a6d0ffd8e5 78 inline void attachSystemCommonTwoBytes(void (*fn)(uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 79 systemCommonTwoBytes = fn;
gert_lauritsen 61:52a6d0ffd8e5 80 }
gert_lauritsen 61:52a6d0ffd8e5 81
gert_lauritsen 61:52a6d0ffd8e5 82 /**
gert_lauritsen 61:52a6d0ffd8e5 83 * Attach a callback called when system exclusive is received
gert_lauritsen 61:52a6d0ffd8e5 84 *
gert_lauritsen 61:52a6d0ffd8e5 85 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 86 * prototype: void onSystemCommonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 87 */
gert_lauritsen 61:52a6d0ffd8e5 88 inline void attachSystemCommonThreeBytes(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 89 systemCommonThreeBytes = fn;
gert_lauritsen 61:52a6d0ffd8e5 90 }
gert_lauritsen 61:52a6d0ffd8e5 91
gert_lauritsen 61:52a6d0ffd8e5 92 /**
gert_lauritsen 61:52a6d0ffd8e5 93 * Attach a callback called when system exclusive is received
gert_lauritsen 61:52a6d0ffd8e5 94 *
gert_lauritsen 61:52a6d0ffd8e5 95 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 96 * prototype: void onSystemExclusive(uint8_t *data, uint16_t length, bool hasNextData);
gert_lauritsen 61:52a6d0ffd8e5 97 */
gert_lauritsen 61:52a6d0ffd8e5 98 inline void attachSystemExclusive(void (*fn)(uint8_t *, uint16_t, bool)) {
gert_lauritsen 61:52a6d0ffd8e5 99 systemExclusive = fn;
gert_lauritsen 61:52a6d0ffd8e5 100 }
gert_lauritsen 61:52a6d0ffd8e5 101
gert_lauritsen 61:52a6d0ffd8e5 102 /**
gert_lauritsen 61:52a6d0ffd8e5 103 * Attach a callback called when note on is received
gert_lauritsen 61:52a6d0ffd8e5 104 *
gert_lauritsen 61:52a6d0ffd8e5 105 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 106 * prototype: void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity);
gert_lauritsen 61:52a6d0ffd8e5 107 */
gert_lauritsen 61:52a6d0ffd8e5 108 inline void attachNoteOn(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 109 noteOn = fn;
gert_lauritsen 61:52a6d0ffd8e5 110 }
gert_lauritsen 61:52a6d0ffd8e5 111
gert_lauritsen 61:52a6d0ffd8e5 112 /**
gert_lauritsen 61:52a6d0ffd8e5 113 * Attach a callback called when note off is received
gert_lauritsen 61:52a6d0ffd8e5 114 *
gert_lauritsen 61:52a6d0ffd8e5 115 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 116 * prototype: void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity);
gert_lauritsen 61:52a6d0ffd8e5 117 */
gert_lauritsen 61:52a6d0ffd8e5 118 inline void attachNoteOff(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 119 noteOff = fn;
gert_lauritsen 61:52a6d0ffd8e5 120 }
gert_lauritsen 61:52a6d0ffd8e5 121
gert_lauritsen 61:52a6d0ffd8e5 122 /**
gert_lauritsen 61:52a6d0ffd8e5 123 * Attach a callback called when poly keypress is received
gert_lauritsen 61:52a6d0ffd8e5 124 *
gert_lauritsen 61:52a6d0ffd8e5 125 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 126 * prototype: void onPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure);
gert_lauritsen 61:52a6d0ffd8e5 127 */
gert_lauritsen 61:52a6d0ffd8e5 128 inline void attachPolyKeyPress(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 129 polyKeyPress = fn;
gert_lauritsen 61:52a6d0ffd8e5 130 }
gert_lauritsen 61:52a6d0ffd8e5 131
gert_lauritsen 61:52a6d0ffd8e5 132 /**
gert_lauritsen 61:52a6d0ffd8e5 133 * Attach a callback called when control change is received
gert_lauritsen 61:52a6d0ffd8e5 134 *
gert_lauritsen 61:52a6d0ffd8e5 135 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 136 * prototype: void onControlChange(uint8_t channel, uint8_t key, uint8_t value);
gert_lauritsen 61:52a6d0ffd8e5 137 */
gert_lauritsen 61:52a6d0ffd8e5 138 inline void attachControlChange(void (*fn)(uint8_t, uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 139 controlChange = fn;
gert_lauritsen 61:52a6d0ffd8e5 140 }
gert_lauritsen 61:52a6d0ffd8e5 141
gert_lauritsen 61:52a6d0ffd8e5 142 /**
gert_lauritsen 61:52a6d0ffd8e5 143 * Attach a callback called when program change is received
gert_lauritsen 61:52a6d0ffd8e5 144 *
gert_lauritsen 61:52a6d0ffd8e5 145 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 146 * prototype: void onProgramChange(uint8_t channel, uint8_t program);
gert_lauritsen 61:52a6d0ffd8e5 147 */
gert_lauritsen 61:52a6d0ffd8e5 148 inline void attachProgramChange(void (*fn)(uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 149 programChange = fn;
gert_lauritsen 61:52a6d0ffd8e5 150 }
gert_lauritsen 61:52a6d0ffd8e5 151
gert_lauritsen 61:52a6d0ffd8e5 152 /**
gert_lauritsen 61:52a6d0ffd8e5 153 * Attach a callback called when channel pressure is received
gert_lauritsen 61:52a6d0ffd8e5 154 *
gert_lauritsen 61:52a6d0ffd8e5 155 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 156 * prototype: void onChannelPressure(uint8_t channel, uint8_t pressure);
gert_lauritsen 61:52a6d0ffd8e5 157 */
gert_lauritsen 61:52a6d0ffd8e5 158 inline void attachChannelPressure(void (*fn)(uint8_t, uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 159 channelPressure = fn;
gert_lauritsen 61:52a6d0ffd8e5 160 }
gert_lauritsen 61:52a6d0ffd8e5 161
gert_lauritsen 61:52a6d0ffd8e5 162 /**
gert_lauritsen 61:52a6d0ffd8e5 163 * Attach a callback called when pitch bend is received
gert_lauritsen 61:52a6d0ffd8e5 164 *
gert_lauritsen 61:52a6d0ffd8e5 165 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 166 * prototype: void onPitchBend(uint8_t channel, uint16_t value);
gert_lauritsen 61:52a6d0ffd8e5 167 */
gert_lauritsen 61:52a6d0ffd8e5 168 inline void attachPitchBend(void (*fn)(uint8_t, uint16_t)) {
gert_lauritsen 61:52a6d0ffd8e5 169 pitchBend = fn;
gert_lauritsen 61:52a6d0ffd8e5 170 }
gert_lauritsen 61:52a6d0ffd8e5 171
gert_lauritsen 61:52a6d0ffd8e5 172 /**
gert_lauritsen 61:52a6d0ffd8e5 173 * Attach a callback called when single byte is received
gert_lauritsen 61:52a6d0ffd8e5 174 *
gert_lauritsen 61:52a6d0ffd8e5 175 * @param ptr function pointer
gert_lauritsen 61:52a6d0ffd8e5 176 * prototype: void onSingleByte(uint8_t value);
gert_lauritsen 61:52a6d0ffd8e5 177 */
gert_lauritsen 61:52a6d0ffd8e5 178 inline void attachSingleByte(void (*fn)(uint8_t)) {
gert_lauritsen 61:52a6d0ffd8e5 179 singleByte = fn;
gert_lauritsen 61:52a6d0ffd8e5 180 }
gert_lauritsen 61:52a6d0ffd8e5 181
gert_lauritsen 61:52a6d0ffd8e5 182 /**
gert_lauritsen 61:52a6d0ffd8e5 183 * Send a cable event with 3 bytes event
gert_lauritsen 61:52a6d0ffd8e5 184 *
gert_lauritsen 61:52a6d0ffd8e5 185 * @param data1 0-255
gert_lauritsen 61:52a6d0ffd8e5 186 * @param data2 0-255
gert_lauritsen 61:52a6d0ffd8e5 187 * @param data3 0-255
gert_lauritsen 61:52a6d0ffd8e5 188 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 189 */
gert_lauritsen 61:52a6d0ffd8e5 190 bool sendMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 191
gert_lauritsen 61:52a6d0ffd8e5 192 /**
gert_lauritsen 61:52a6d0ffd8e5 193 * Send a cable event with 3 bytes event
gert_lauritsen 61:52a6d0ffd8e5 194 *
gert_lauritsen 61:52a6d0ffd8e5 195 * @param data1 0-255
gert_lauritsen 61:52a6d0ffd8e5 196 * @param data2 0-255
gert_lauritsen 61:52a6d0ffd8e5 197 * @param data3 0-255
gert_lauritsen 61:52a6d0ffd8e5 198 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 199 */
gert_lauritsen 61:52a6d0ffd8e5 200 bool sendCableEvent(uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 201
gert_lauritsen 61:52a6d0ffd8e5 202 /**
gert_lauritsen 61:52a6d0ffd8e5 203 * Send a system common message with 2 bytes event
gert_lauritsen 61:52a6d0ffd8e5 204 *
gert_lauritsen 61:52a6d0ffd8e5 205 * @param data1 0-255
gert_lauritsen 61:52a6d0ffd8e5 206 * @param data2 0-255
gert_lauritsen 61:52a6d0ffd8e5 207 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 208 */
gert_lauritsen 61:52a6d0ffd8e5 209 bool sendSystemCommmonTwoBytes(uint8_t data1, uint8_t data2);
gert_lauritsen 61:52a6d0ffd8e5 210
gert_lauritsen 61:52a6d0ffd8e5 211 /**
gert_lauritsen 61:52a6d0ffd8e5 212 * Send a system common message with 3 bytes event
gert_lauritsen 61:52a6d0ffd8e5 213 *
gert_lauritsen 61:52a6d0ffd8e5 214 * @param data1 0-255
gert_lauritsen 61:52a6d0ffd8e5 215 * @param data2 0-255
gert_lauritsen 61:52a6d0ffd8e5 216 * @param data3 0-255
gert_lauritsen 61:52a6d0ffd8e5 217 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 218 */
gert_lauritsen 61:52a6d0ffd8e5 219 bool sendSystemCommmonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 220
gert_lauritsen 61:52a6d0ffd8e5 221 /**
gert_lauritsen 61:52a6d0ffd8e5 222 * Send a system exclusive event
gert_lauritsen 61:52a6d0ffd8e5 223 *
gert_lauritsen 61:52a6d0ffd8e5 224 * @param buffer, starts with 0xF0, and end with 0xf7
gert_lauritsen 61:52a6d0ffd8e5 225 * @param length
gert_lauritsen 61:52a6d0ffd8e5 226 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 227 */
gert_lauritsen 61:52a6d0ffd8e5 228 bool sendSystemExclusive(uint8_t *buffer, int length);
gert_lauritsen 61:52a6d0ffd8e5 229
gert_lauritsen 61:52a6d0ffd8e5 230 /**
gert_lauritsen 61:52a6d0ffd8e5 231 * Send a note off event
gert_lauritsen 61:52a6d0ffd8e5 232 *
gert_lauritsen 61:52a6d0ffd8e5 233 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 234 * @param note 0-127
gert_lauritsen 61:52a6d0ffd8e5 235 * @param velocity 0-127
gert_lauritsen 61:52a6d0ffd8e5 236 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 237 */
gert_lauritsen 61:52a6d0ffd8e5 238 bool sendNoteOff(uint8_t channel, uint8_t note, uint8_t velocity);
gert_lauritsen 61:52a6d0ffd8e5 239
gert_lauritsen 61:52a6d0ffd8e5 240 /**
gert_lauritsen 61:52a6d0ffd8e5 241 * Send a note on event
gert_lauritsen 61:52a6d0ffd8e5 242 *
gert_lauritsen 61:52a6d0ffd8e5 243 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 244 * @param note 0-127
gert_lauritsen 61:52a6d0ffd8e5 245 * @param velocity 0-127 (0 means note off)
gert_lauritsen 61:52a6d0ffd8e5 246 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 247 */
gert_lauritsen 61:52a6d0ffd8e5 248 bool sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity);
gert_lauritsen 61:52a6d0ffd8e5 249
gert_lauritsen 61:52a6d0ffd8e5 250 /**
gert_lauritsen 61:52a6d0ffd8e5 251 * Send a poly keypress event
gert_lauritsen 61:52a6d0ffd8e5 252 *
gert_lauritsen 61:52a6d0ffd8e5 253 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 254 * @param note 0-127
gert_lauritsen 61:52a6d0ffd8e5 255 * @param pressure 0-127
gert_lauritsen 61:52a6d0ffd8e5 256 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 257 */
gert_lauritsen 61:52a6d0ffd8e5 258 bool sendPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure);
gert_lauritsen 61:52a6d0ffd8e5 259
gert_lauritsen 61:52a6d0ffd8e5 260 /**
gert_lauritsen 61:52a6d0ffd8e5 261 * Send a control change event
gert_lauritsen 61:52a6d0ffd8e5 262 *
gert_lauritsen 61:52a6d0ffd8e5 263 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 264 * @param key 0-127
gert_lauritsen 61:52a6d0ffd8e5 265 * @param value 0-127
gert_lauritsen 61:52a6d0ffd8e5 266 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 267 */
gert_lauritsen 61:52a6d0ffd8e5 268 bool sendControlChange(uint8_t channel, uint8_t key, uint8_t value);
gert_lauritsen 61:52a6d0ffd8e5 269
gert_lauritsen 61:52a6d0ffd8e5 270 /**
gert_lauritsen 61:52a6d0ffd8e5 271 * Send a program change event
gert_lauritsen 61:52a6d0ffd8e5 272 *
gert_lauritsen 61:52a6d0ffd8e5 273 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 274 * @param program 0-127
gert_lauritsen 61:52a6d0ffd8e5 275 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 276 */
gert_lauritsen 61:52a6d0ffd8e5 277 bool sendProgramChange(uint8_t channel, uint8_t program);
gert_lauritsen 61:52a6d0ffd8e5 278
gert_lauritsen 61:52a6d0ffd8e5 279 /**
gert_lauritsen 61:52a6d0ffd8e5 280 * Send a channel pressure event
gert_lauritsen 61:52a6d0ffd8e5 281 *
gert_lauritsen 61:52a6d0ffd8e5 282 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 283 * @param pressure 0-127
gert_lauritsen 61:52a6d0ffd8e5 284 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 285 */
gert_lauritsen 61:52a6d0ffd8e5 286 bool sendChannelPressure(uint8_t channel, uint8_t pressure);
gert_lauritsen 61:52a6d0ffd8e5 287
gert_lauritsen 61:52a6d0ffd8e5 288 /**
gert_lauritsen 61:52a6d0ffd8e5 289 * Send a control change event
gert_lauritsen 61:52a6d0ffd8e5 290 *
gert_lauritsen 61:52a6d0ffd8e5 291 * @param channel 0-15
gert_lauritsen 61:52a6d0ffd8e5 292 * @param key 0(lower)-8191(center)-16383(higher)
gert_lauritsen 61:52a6d0ffd8e5 293 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 294 */
gert_lauritsen 61:52a6d0ffd8e5 295 bool sendPitchBend(uint8_t channel, uint16_t value);
gert_lauritsen 61:52a6d0ffd8e5 296
gert_lauritsen 61:52a6d0ffd8e5 297 /**
gert_lauritsen 61:52a6d0ffd8e5 298 * Send a single byte event
gert_lauritsen 61:52a6d0ffd8e5 299 *
gert_lauritsen 61:52a6d0ffd8e5 300 * @param data 0-255
gert_lauritsen 61:52a6d0ffd8e5 301 * @return true if message sent successfully
gert_lauritsen 61:52a6d0ffd8e5 302 */
gert_lauritsen 61:52a6d0ffd8e5 303 bool sendSingleByte(uint8_t data);
gert_lauritsen 61:52a6d0ffd8e5 304
gert_lauritsen 61:52a6d0ffd8e5 305 protected:
gert_lauritsen 61:52a6d0ffd8e5 306 //From IUSBEnumerator
gert_lauritsen 61:52a6d0ffd8e5 307 virtual void setVidPid(uint16_t vid, uint16_t pid);
gert_lauritsen 61:52a6d0ffd8e5 308 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
gert_lauritsen 61:52a6d0ffd8e5 309 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
gert_lauritsen 61:52a6d0ffd8e5 310
gert_lauritsen 61:52a6d0ffd8e5 311 private:
gert_lauritsen 61:52a6d0ffd8e5 312 USBHost * host;
gert_lauritsen 61:52a6d0ffd8e5 313 USBDeviceConnected * dev;
gert_lauritsen 61:52a6d0ffd8e5 314 USBEndpoint * bulk_in;
gert_lauritsen 61:52a6d0ffd8e5 315 USBEndpoint * bulk_out;
gert_lauritsen 61:52a6d0ffd8e5 316 uint32_t size_bulk_in;
gert_lauritsen 61:52a6d0ffd8e5 317 uint32_t size_bulk_out;
gert_lauritsen 61:52a6d0ffd8e5 318
gert_lauritsen 61:52a6d0ffd8e5 319 bool dev_connected;
gert_lauritsen 61:52a6d0ffd8e5 320
gert_lauritsen 61:52a6d0ffd8e5 321 void init();
gert_lauritsen 61:52a6d0ffd8e5 322
gert_lauritsen 61:52a6d0ffd8e5 323 uint8_t buf[64];
gert_lauritsen 61:52a6d0ffd8e5 324
gert_lauritsen 61:52a6d0ffd8e5 325 void rxHandler();
gert_lauritsen 61:52a6d0ffd8e5 326
gert_lauritsen 61:52a6d0ffd8e5 327 uint16_t sysExBufferPos;
gert_lauritsen 61:52a6d0ffd8e5 328 uint8_t sysExBuffer[64];
gert_lauritsen 61:52a6d0ffd8e5 329
gert_lauritsen 61:52a6d0ffd8e5 330 void (*miscellaneousFunctionCode)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 331 void (*cableEvent)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 332 void (*systemCommonTwoBytes)(uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 333 void (*systemCommonThreeBytes)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 334 void (*systemExclusive)(uint8_t *, uint16_t, bool);
gert_lauritsen 61:52a6d0ffd8e5 335 void (*noteOff)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 336 void (*noteOn)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 337 void (*polyKeyPress)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 338 void (*controlChange)(uint8_t, uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 339 void (*programChange)(uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 340 void (*channelPressure)(uint8_t, uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 341 void (*pitchBend)(uint8_t, uint16_t);
gert_lauritsen 61:52a6d0ffd8e5 342 void (*singleByte)(uint8_t);
gert_lauritsen 61:52a6d0ffd8e5 343
gert_lauritsen 61:52a6d0ffd8e5 344 bool sendMidiBuffer(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3);
gert_lauritsen 61:52a6d0ffd8e5 345
gert_lauritsen 61:52a6d0ffd8e5 346 int midi_intf;
gert_lauritsen 61:52a6d0ffd8e5 347 bool midi_device_found;
gert_lauritsen 61:52a6d0ffd8e5 348
gert_lauritsen 61:52a6d0ffd8e5 349 };
gert_lauritsen 61:52a6d0ffd8e5 350
gert_lauritsen 61:52a6d0ffd8e5 351 #endif /* USBHOST_MIDI */
gert_lauritsen 61:52a6d0ffd8e5 352
gert_lauritsen 61:52a6d0ffd8e5 353 #endif /* USBHOSTMIDI_H */