diff options
author | DaveHodder67 <dave.hodder@focusrite.com> | 2015-07-02 10:13:27 +0100 |
---|---|---|
committer | DaveHodder67 <dave.hodder@focusrite.com> | 2015-07-02 10:13:27 +0100 |
commit | b610731696267a1c3c778c2668870ed249607115 (patch) | |
tree | d19edc15ec1f7cac721920f47117b36e683339c9 /include | |
parent | 328639587cf341f057a1e278648be02b94d71f6d (diff) | |
download | launchpad-polymaker-b610731696267a1c3c778c2668870ed249607115.tar.gz launchpad-polymaker-b610731696267a1c3c778c2668870ed249607115.zip |
improved documentation (slightly!)
Diffstat (limited to 'include')
-rw-r--r-- | include/app.h | 94 | ||||
-rw-r--r-- | include/app_defs.h | 32 |
2 files changed, 117 insertions, 9 deletions
diff --git a/include/app.h b/include/app.h index 51eef58..8f33e48 100644 --- a/include/app.h +++ b/include/app.h | |||
@@ -1,14 +1,54 @@ | |||
1 | // | ||
2 | // app.h | ||
3 | // | ||
4 | |||
5 | #ifndef LAUNCHPAD_APP_H | 1 | #ifndef LAUNCHPAD_APP_H |
6 | #define LAUNCHPAD_APP_H | 2 | #define LAUNCHPAD_APP_H |
7 | 3 | ||
8 | // ____________________________________________________________________________ | 4 | /****************************************************************************** |
5 | |||
6 | Copyright (c) 2015, Focusrite Audio Engineering Ltd. | ||
7 | All rights reserved. | ||
8 | |||
9 | Redistribution and use in source and binary forms, with or without | ||
10 | modification, are permitted provided that the following conditions are met: | ||
11 | |||
12 | * Redistributions of source code must retain the above copyright notice, this | ||
13 | list of conditions and the following disclaimer. | ||
14 | |||
15 | * Redistributions in binary form must reproduce the above copyright notice, | ||
16 | this list of conditions and the following disclaimer in the documentation | ||
17 | and/or other materials provided with the distribution. | ||
18 | |||
19 | * Neither the name of Focusrite Audio Engineering Ltd., nor the names of its | ||
20 | contributors may be used to endorse or promote products derived from | ||
21 | this software without specific prior written permission. | ||
22 | |||
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
24 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
27 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
29 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
31 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | |||
34 | *****************************************************************************/ | ||
35 | |||
36 | // ____________________________________________________________________________ | ||
9 | // | 37 | // |
10 | #include "app_defs.h" | 38 | #include "app_defs.h" |
11 | 39 | ||
40 | /****************************************************************************** | ||
41 | Button indexing is as follows - numbers in brackets do not correspond to real | ||
42 | buttons, but can be harmessly sent in hal_set_led. | ||
43 | |||
44 | (90)91 92 93 94 95 96 97 98 (99) | ||
45 | ....... | ||
46 | 20 21 22 23 24 25 26 27 28 29 | ||
47 | 10 11 12 13 14 15 16 17 18 19 | ||
48 | (0) 1 2 3 4 5 6 7 8 (9) | ||
49 | |||
50 | *****************************************************************************/ | ||
51 | |||
12 | // ____________________________________________________________________________ | 52 | // ____________________________________________________________________________ |
13 | // | 53 | // |
14 | // Interface to the hardware (implemented in launchpad_pro.a library) | 54 | // Interface to the hardware (implemented in launchpad_pro.a library) |
@@ -17,17 +57,34 @@ | |||
17 | /** | 57 | /** |
18 | * Set an LED's RGB value. This function is safe to call from any | 58 | * Set an LED's RGB value. This function is safe to call from any |
19 | * of the app functions below, at any time. | 59 | * of the app functions below, at any time. |
60 | * | ||
61 | * @param type - TYPEPAD to address any pad or button, TYPESETUP to address the Setup button | ||
62 | * @param index - The index of the button. The buttons are indexed from the bottom left as detailed above. | ||
63 | * @param red - red colour value, in [0, MAXLED] | ||
64 | * @param green - green colour value, in [0, MAXLED] | ||
65 | * @param blue - blue colour value, in [0, MAXLED] | ||
20 | */ | 66 | */ |
21 | void hal_plot_led(u8 type, u8 index, u8 red, u8 green, u8 blue); | 67 | void hal_plot_led(u8 type, u8 index, u8 red, u8 green, u8 blue); |
22 | 68 | ||
23 | /** | 69 | /** |
24 | * Send a MIDI message to either USB port or to the DIN output. | 70 | * Send a MIDI message to either USB port or to the DIN output. |
71 | * | ||
72 | * @param port - which port to send the message to - can be USBSTANDALONE, USBMIDI or DINMIDI. | ||
73 | * @param status - MIDI status byte | ||
74 | * @param data1 - first MIDI data byte | ||
75 | * @param data2 - second MIDI data byte | ||
76 | * | ||
77 | * There is little error checking in this code - if you send invalid MIDI, the results are undefined! | ||
25 | */ | 78 | */ |
26 | void hal_send_midi(u8 port, u8 status, u8 d1, u8 d2); | 79 | void hal_send_midi(u8 port, u8 status, u8 data1, u8 data2); |
27 | 80 | ||
28 | /** | 81 | /** |
29 | * Send system exclusive to USB or DIN. Messages must be correctly formatted | 82 | * Send system exclusive to USB or DIN. Messages must be correctly formatted |
30 | * (F0 ... F7) and must not exceed 320 bytes. | 83 | * (F0 ... F7) and must not exceed 320 bytes. |
84 | * | ||
85 | * @param port - which port to send the message to - can be USBSTANDALONE, USBMIDI or DINMIDI. | ||
86 | * @param data - pointer to array containing sysex data. | ||
87 | * @param length - must not exceed 320 bytes. | ||
31 | */ | 88 | */ |
32 | void hal_send_sysex(u8 port, const u8* data, u16 length); | 89 | void hal_send_sysex(u8 port, const u8* data, u16 length); |
33 | 90 | ||
@@ -45,29 +102,45 @@ void app_init(); | |||
45 | * 1kHz (1ms) timer. You can set LEDs and send MIDI out from this function, | 102 | * 1kHz (1ms) timer. You can set LEDs and send MIDI out from this function, |
46 | * but you will get LED tearing as there is (currently) no double buffering. | 103 | * but you will get LED tearing as there is (currently) no double buffering. |
47 | * | 104 | * |
48 | * You will get jitter. | 105 | * You will get some jitter. |
49 | */ | 106 | */ |
50 | void app_timer_event(); | 107 | void app_timer_event(); |
51 | 108 | ||
52 | /** | 109 | /** |
53 | * Called when a MIDI message is received from USB or DIN. | 110 | * Called when a MIDI message is received from USB or DIN. |
111 | * | ||
112 | * @param port - the port the message was received from - USBSTANDALONE, USBMIDI or DINMIDI. | ||
113 | * @param status - MIDI status byte | ||
114 | * @param data1 - first MIDI data byte | ||
115 | * @param data2 - second MIDI data byte | ||
54 | */ | 116 | */ |
55 | void app_midi_event(u8 port, u8 status, u8 d1, u8 d2); | 117 | void app_midi_event(u8 port, u8 status, u8 d1, u8 d2); |
56 | 118 | ||
57 | /** | 119 | /** |
58 | * As above, but for system exclusive messages. Low level hardware buffering sets | 120 | * As above, but for system exclusive messages. Low level hardware buffering sets |
59 | * a maximum message size of 320 bytes, messages larger than this will not work. | 121 | * a maximum message size of 320 bytes, messages larger than this will not work. |
122 | * | ||
123 | * @param port - the port the message was received from - USBSTANDALONE, USBMIDI or DINMIDI. | ||
124 | * @param data - pointer to array containing sysex data. | ||
125 | * @param length - the amount of data received. | ||
60 | */ | 126 | */ |
61 | void app_sysex_event(u8 port, u8 * data, u16 count); | 127 | void app_sysex_event(u8 port, u8 * data, u16 count); |
62 | 128 | ||
63 | /** | 129 | /** |
64 | * Called when a MIDI DIN breakout cable is connected or disconnected. Note that | 130 | * Called when a MIDI DIN breakout cable is connected or disconnected. Note that |
65 | * you can still write MIDI events to the DIN ports even if no cable is connected. | 131 | * you can still write MIDI events to the DIN ports even if no cable is connected. |
132 | * | ||
133 | * @param type - which cable was connected/disconnected - MIDI_IN_CABLE or MIDI_OUT_CABLE. | ||
134 | * @param value - 0 = disconnected, nonzero = connected. | ||
66 | */ | 135 | */ |
67 | void app_cable_event(u8 type, u8 value); | 136 | void app_cable_event(u8 type, u8 value); |
68 | 137 | ||
69 | /** | 138 | /** |
70 | * Called when the user presses or releases any button or pad on the control surface. | 139 | * Called when the user presses or releases any button or pad on the control surface. |
140 | * | ||
141 | * @param type - TYPEPAD for normal pads or buttons, TYPESETUP for the Setup button | ||
142 | * @param index - The index of the button, as detailed at the start of this file. | ||
143 | * @param value - 0 for release, nonzero for press. | ||
71 | */ | 144 | */ |
72 | void app_surface_event(u8 type, u8 index, u8 value); | 145 | void app_surface_event(u8 type, u8 index, u8 value); |
73 | 146 | ||
@@ -77,6 +150,9 @@ void app_surface_event(u8 type, u8 index, u8 value); | |||
77 | * threshold to prevent excessive aftertouch after the initial hit, at the expense of | 150 | * threshold to prevent excessive aftertouch after the initial hit, at the expense of |
78 | * dynamic range. This firmware does not - the full range of the pad is transmitted, | 151 | * dynamic range. This firmware does not - the full range of the pad is transmitted, |
79 | * with the side effect that aftertouch onset is more rapid. | 152 | * with the side effect that aftertouch onset is more rapid. |
153 | * | ||
154 | * @param index - The index of the pad, as detailed at the start of this file. | ||
155 | * @param value - the aftertouch value in [0, 127] | ||
80 | */ | 156 | */ |
81 | void app_aftertouch_event(u8 index, u8 value); | 157 | void app_aftertouch_event(u8 index, u8 value); |
82 | 158 | ||
diff --git a/include/app_defs.h b/include/app_defs.h index b339ed1..cc7493b 100644 --- a/include/app_defs.h +++ b/include/app_defs.h | |||
@@ -2,6 +2,38 @@ | |||
2 | #ifndef APP_TYPES_H | 2 | #ifndef APP_TYPES_H |
3 | #define APP_TYPES_H | 3 | #define APP_TYPES_H |
4 | 4 | ||
5 | /****************************************************************************** | ||
6 | |||
7 | Copyright (c) 2015, Focusrite Audio Engineering Ltd. | ||
8 | All rights reserved. | ||
9 | |||
10 | Redistribution and use in source and binary forms, with or without | ||
11 | modification, are permitted provided that the following conditions are met: | ||
12 | |||
13 | * Redistributions of source code must retain the above copyright notice, this | ||
14 | list of conditions and the following disclaimer. | ||
15 | |||
16 | * Redistributions in binary form must reproduce the above copyright notice, | ||
17 | this list of conditions and the following disclaimer in the documentation | ||
18 | and/or other materials provided with the distribution. | ||
19 | |||
20 | * Neither the name of Focusrite Audio Engineering Ltd., nor the names of its | ||
21 | contributors may be used to endorse or promote products derived from | ||
22 | this software without specific prior written permission. | ||
23 | |||
24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
28 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
32 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
34 | |||
35 | *****************************************************************************/ | ||
36 | |||
5 | // ____________________________________________________________________________ | 37 | // ____________________________________________________________________________ |
6 | // | 38 | // |
7 | // Types | 39 | // Types |