MIDI Stop Controller V1.0 suitable for driving Hauptwerk digital organ software. Written for the KL25Z uses BusInOut and will drive up to 16 illuminated push buttons each switch uses a single I/O pin to both drive the LED and act as a switch input. Pressing a button will alternately send MIDI note on / off messages and turn the LED on or off. If corresponding MIDI note on/off messages are received these will be used to drive the LEDs in preference to the locally generated LED signals. The MIDI channel used to send can be selected by jumpers on 4 pins of the J2 header.

Dependencies:   mbed

Committer:
djbottrill
Date:
Sat Sep 14 21:32:06 2013 +0000
Revision:
0:aac55e1fc12f
V1.0 MIDI Stop Controller

Who changed what in which revision?

UserRevisionLine numberNew contents of line
djbottrill 0:aac55e1fc12f 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
djbottrill 0:aac55e1fc12f 2 *
djbottrill 0:aac55e1fc12f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
djbottrill 0:aac55e1fc12f 4 * and associated documentation files (the "Software"), to deal in the Software without
djbottrill 0:aac55e1fc12f 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
djbottrill 0:aac55e1fc12f 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
djbottrill 0:aac55e1fc12f 7 * Software is furnished to do so, subject to the following conditions:
djbottrill 0:aac55e1fc12f 8 *
djbottrill 0:aac55e1fc12f 9 * The above copyright notice and this permission notice shall be included in all copies or
djbottrill 0:aac55e1fc12f 10 * substantial portions of the Software.
djbottrill 0:aac55e1fc12f 11 *
djbottrill 0:aac55e1fc12f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
djbottrill 0:aac55e1fc12f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
djbottrill 0:aac55e1fc12f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
djbottrill 0:aac55e1fc12f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
djbottrill 0:aac55e1fc12f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
djbottrill 0:aac55e1fc12f 17 */
djbottrill 0:aac55e1fc12f 18
djbottrill 0:aac55e1fc12f 19 #ifndef USBMIDI_H
djbottrill 0:aac55e1fc12f 20 #define USBMIDI_H
djbottrill 0:aac55e1fc12f 21
djbottrill 0:aac55e1fc12f 22 /* These headers are included for child class. */
djbottrill 0:aac55e1fc12f 23 #include "USBEndpoints.h"
djbottrill 0:aac55e1fc12f 24 #include "USBDescriptor.h"
djbottrill 0:aac55e1fc12f 25 #include "USBDevice_Types.h"
djbottrill 0:aac55e1fc12f 26
djbottrill 0:aac55e1fc12f 27 #include "USBDevice.h"
djbottrill 0:aac55e1fc12f 28 #include "MIDIMessage.h"
djbottrill 0:aac55e1fc12f 29
djbottrill 0:aac55e1fc12f 30 #define DEFAULT_CONFIGURATION (1)
djbottrill 0:aac55e1fc12f 31
djbottrill 0:aac55e1fc12f 32 /**
djbottrill 0:aac55e1fc12f 33 * USBMIDI example
djbottrill 0:aac55e1fc12f 34 *
djbottrill 0:aac55e1fc12f 35 * @code
djbottrill 0:aac55e1fc12f 36 * #include "mbed.h"
djbottrill 0:aac55e1fc12f 37 * #include "USBMIDI.h"
djbottrill 0:aac55e1fc12f 38 *
djbottrill 0:aac55e1fc12f 39 * USBMIDI midi;
djbottrill 0:aac55e1fc12f 40 *
djbottrill 0:aac55e1fc12f 41 * int main() {
djbottrill 0:aac55e1fc12f 42 * while (1) {
djbottrill 0:aac55e1fc12f 43 * for(int i=48; i<83; i++) { // send some messages!
djbottrill 0:aac55e1fc12f 44 * midi.write(MIDIMessage::NoteOn(i));
djbottrill 0:aac55e1fc12f 45 * wait(0.25);
djbottrill 0:aac55e1fc12f 46 * midi.write(MIDIMessage::NoteOff(i));
djbottrill 0:aac55e1fc12f 47 * wait(0.5);
djbottrill 0:aac55e1fc12f 48 * }
djbottrill 0:aac55e1fc12f 49 * }
djbottrill 0:aac55e1fc12f 50 * }
djbottrill 0:aac55e1fc12f 51 * @endcode
djbottrill 0:aac55e1fc12f 52 */
djbottrill 0:aac55e1fc12f 53 class USBMIDI: public USBDevice {
djbottrill 0:aac55e1fc12f 54 public:
djbottrill 0:aac55e1fc12f 55
djbottrill 0:aac55e1fc12f 56 /**
djbottrill 0:aac55e1fc12f 57 * Constructor
djbottrill 0:aac55e1fc12f 58 *
djbottrill 0:aac55e1fc12f 59 * @param vendor_id Your vendor_id
djbottrill 0:aac55e1fc12f 60 * @param product_id Your product_id
djbottrill 0:aac55e1fc12f 61 * @param product_release Your preoduct_release
djbottrill 0:aac55e1fc12f 62 */
djbottrill 0:aac55e1fc12f 63 USBMIDI(uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001);
djbottrill 0:aac55e1fc12f 64
djbottrill 0:aac55e1fc12f 65 /**
djbottrill 0:aac55e1fc12f 66 * Send a MIDIMessage
djbottrill 0:aac55e1fc12f 67 *
djbottrill 0:aac55e1fc12f 68 * @param m The MIDIMessage to send
djbottrill 0:aac55e1fc12f 69 */
djbottrill 0:aac55e1fc12f 70 void write(MIDIMessage m);
djbottrill 0:aac55e1fc12f 71
djbottrill 0:aac55e1fc12f 72 /**
djbottrill 0:aac55e1fc12f 73 * Attach a callback for when a MIDIEvent is received
djbottrill 0:aac55e1fc12f 74 *
djbottrill 0:aac55e1fc12f 75 * @param fptr function pointer
djbottrill 0:aac55e1fc12f 76 */
djbottrill 0:aac55e1fc12f 77 void attach(void (*fptr)(MIDIMessage));
djbottrill 0:aac55e1fc12f 78
djbottrill 0:aac55e1fc12f 79
djbottrill 0:aac55e1fc12f 80 protected:
djbottrill 0:aac55e1fc12f 81 virtual bool EP2_OUT_callback();
djbottrill 0:aac55e1fc12f 82 virtual bool USBCallback_setConfiguration(uint8_t configuration);
djbottrill 0:aac55e1fc12f 83 /*
djbottrill 0:aac55e1fc12f 84 * Get string product descriptor
djbottrill 0:aac55e1fc12f 85 *
djbottrill 0:aac55e1fc12f 86 * @returns pointer to the string product descriptor
djbottrill 0:aac55e1fc12f 87 */
djbottrill 0:aac55e1fc12f 88 virtual uint8_t * stringIproductDesc();
djbottrill 0:aac55e1fc12f 89
djbottrill 0:aac55e1fc12f 90 /*
djbottrill 0:aac55e1fc12f 91 * Get string interface descriptor
djbottrill 0:aac55e1fc12f 92 *
djbottrill 0:aac55e1fc12f 93 * @returns pointer to the string interface descriptor
djbottrill 0:aac55e1fc12f 94 */
djbottrill 0:aac55e1fc12f 95 virtual uint8_t * stringIinterfaceDesc();
djbottrill 0:aac55e1fc12f 96
djbottrill 0:aac55e1fc12f 97 /*
djbottrill 0:aac55e1fc12f 98 * Get configuration descriptor
djbottrill 0:aac55e1fc12f 99 *
djbottrill 0:aac55e1fc12f 100 * @returns pointer to the configuration descriptor
djbottrill 0:aac55e1fc12f 101 */
djbottrill 0:aac55e1fc12f 102 virtual uint8_t * configurationDesc();
djbottrill 0:aac55e1fc12f 103
djbottrill 0:aac55e1fc12f 104 private:
djbottrill 0:aac55e1fc12f 105 void (*midi_evt)(MIDIMessage);
djbottrill 0:aac55e1fc12f 106
djbottrill 0:aac55e1fc12f 107 };
djbottrill 0:aac55e1fc12f 108
djbottrill 0:aac55e1fc12f 109 #endif