diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/app.h | 84 | ||||
-rw-r--r-- | include/app_defs.h | 65 |
2 files changed, 149 insertions, 0 deletions
diff --git a/include/app.h b/include/app.h new file mode 100644 index 0000000..51eef58 --- /dev/null +++ b/include/app.h | |||
@@ -0,0 +1,84 @@ | |||
1 | // | ||
2 | // app.h | ||
3 | // | ||
4 | |||
5 | #ifndef LAUNCHPAD_APP_H | ||
6 | #define LAUNCHPAD_APP_H | ||
7 | |||
8 | // ____________________________________________________________________________ | ||
9 | // | ||
10 | #include "app_defs.h" | ||
11 | |||
12 | // ____________________________________________________________________________ | ||
13 | // | ||
14 | // Interface to the hardware (implemented in launchpad_pro.a library) | ||
15 | // ____________________________________________________________________________ | ||
16 | |||
17 | /** | ||
18 | * Set an LED's RGB value. This function is safe to call from any | ||
19 | * of the app functions below, at any time. | ||
20 | */ | ||
21 | void hal_plot_led(u8 type, u8 index, u8 red, u8 green, u8 blue); | ||
22 | |||
23 | /** | ||
24 | * Send a MIDI message to either USB port or to the DIN output. | ||
25 | */ | ||
26 | void hal_send_midi(u8 port, u8 status, u8 d1, u8 d2); | ||
27 | |||
28 | /** | ||
29 | * Send system exclusive to USB or DIN. Messages must be correctly formatted | ||
30 | * (F0 ... F7) and must not exceed 320 bytes. | ||
31 | */ | ||
32 | void hal_send_sysex(u8 port, const u8* data, u16 length); | ||
33 | |||
34 | // ____________________________________________________________________________ | ||
35 | // | ||
36 | // Interface from the hardware (implemented in app.c) | ||
37 | // ____________________________________________________________________________ | ||
38 | |||
39 | /** | ||
40 | * Called on startup, this is a good place to do any initialisation. | ||
41 | */ | ||
42 | void app_init(); | ||
43 | |||
44 | /** | ||
45 | * 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. | ||
47 | * | ||
48 | * You will get jitter. | ||
49 | */ | ||
50 | void app_timer_event(); | ||
51 | |||
52 | /** | ||
53 | * Called when a MIDI message is received from USB or DIN. | ||
54 | */ | ||
55 | void app_midi_event(u8 port, u8 status, u8 d1, u8 d2); | ||
56 | |||
57 | /** | ||
58 | * 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. | ||
60 | */ | ||
61 | void app_sysex_event(u8 port, u8 * data, u16 count); | ||
62 | |||
63 | /** | ||
64 | * 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. | ||
66 | */ | ||
67 | void app_cable_event(u8 type, u8 value); | ||
68 | |||
69 | /** | ||
70 | * Called when the user presses or releases any button or pad on the control surface. | ||
71 | */ | ||
72 | void app_surface_event(u8 type, u8 index, u8 value); | ||
73 | |||
74 | /** | ||
75 | * Called when the low level pad scanning reports an aftertouch (pad pressure) event. | ||
76 | * A pad press event will always come first. Note that the factory firmware sets a | ||
77 | * 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, | ||
79 | * with the side effect that aftertouch onset is more rapid. | ||
80 | */ | ||
81 | void app_aftertouch_event(u8 index, u8 value); | ||
82 | |||
83 | |||
84 | #endif | ||
diff --git a/include/app_defs.h b/include/app_defs.h new file mode 100644 index 0000000..b339ed1 --- /dev/null +++ b/include/app_defs.h | |||
@@ -0,0 +1,65 @@ | |||
1 | |||
2 | #ifndef APP_TYPES_H | ||
3 | #define APP_TYPES_H | ||
4 | |||
5 | // ____________________________________________________________________________ | ||
6 | // | ||
7 | // Types | ||
8 | // ____________________________________________________________________________ | ||
9 | |||
10 | typedef signed long s32; | ||
11 | typedef signed short s16; | ||
12 | typedef signed char s8; | ||
13 | |||
14 | typedef unsigned long u32; | ||
15 | typedef unsigned short u16; | ||
16 | typedef unsigned char u8; | ||
17 | |||
18 | // ____________________________________________________________________________ | ||
19 | // | ||
20 | // App structure | ||
21 | // ____________________________________________________________________________ | ||
22 | |||
23 | #define TYPEPAD 0 | ||
24 | #define TYPESETUP 1 | ||
25 | |||
26 | #define MAXLED 63 | ||
27 | |||
28 | // ____________________________________________________________________________ | ||
29 | // | ||
30 | // Useful MIDI constants | ||
31 | // ____________________________________________________________________________ | ||
32 | |||
33 | #define NOTEON 0x90 | ||
34 | #define NOTEOFF 0x80 | ||
35 | #define POLYAFTERTOUCH 0xA0 | ||
36 | #define CC 0xB0 | ||
37 | #define CHANNELAFTERTOUCH 0xD0 | ||
38 | #define SONGPOSITIONPOINTER 0xF2 | ||
39 | #define MIDITIMINGCLOCK 0xF8 | ||
40 | #define MIDISTART 0xFA | ||
41 | #define MIDICONTINUE 0xFB | ||
42 | #define MIDISTOP 0xFC | ||
43 | |||
44 | // ____________________________________________________________________________ | ||
45 | // | ||
46 | // MIDI ports | ||
47 | // ____________________________________________________________________________ | ||
48 | |||
49 | // USB MIDI: "Standalone" port | ||
50 | #define USBSTANDALONE 0 | ||
51 | |||
52 | // USB MIDI: "MIDI" port | ||
53 | #define USBMIDI 1 | ||
54 | |||
55 | // MIDI DIN port | ||
56 | #define DINMIDI 2 | ||
57 | |||
58 | |||
59 | // MIDI Jack Socket Switch IDs | ||
60 | |||
61 | #define MIDI_IN_CABLE 0 | ||
62 | #define MIDI_OUT_CABLE 1 | ||
63 | |||
64 | // ____________________________________________________________________________ | ||
65 | #endif | ||