diff options
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/app.c b/src/app.c new file mode 100644 index 0000000..662007e --- /dev/null +++ b/src/app.c | |||
@@ -0,0 +1,92 @@ | |||
1 | //______________________________________________________________________________ | ||
2 | // | ||
3 | // Headers | ||
4 | //______________________________________________________________________________ | ||
5 | |||
6 | #include "app.h" | ||
7 | |||
8 | //______________________________________________________________________________ | ||
9 | |||
10 | void app_surface_event(u8 type, u8 index, u8 value) | ||
11 | { | ||
12 | switch (type) | ||
13 | { | ||
14 | case TYPEPAD: | ||
15 | { | ||
16 | // example - light / extinguish pad LEDs, send MIDI | ||
17 | hal_plot_led(TYPEPAD, index, value, value, value); | ||
18 | hal_send_midi(USBSTANDALONE, NOTEON | 0, index, value); | ||
19 | } | ||
20 | break; | ||
21 | |||
22 | case TYPESETUP: | ||
23 | { | ||
24 | // example - light the setup LED | ||
25 | hal_plot_led(TYPESETUP, 0, value, value, value); | ||
26 | } | ||
27 | break; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) | ||
32 | { | ||
33 | // example - MIDI interface functionality for USB "MIDI" port -> DIN port | ||
34 | if (port == USBMIDI) | ||
35 | { | ||
36 | hal_send_midi(DINMIDI, status, d1, d2); | ||
37 | } | ||
38 | |||
39 | // // example -MIDI interface functionality for DIN -> USB "MIDI" port port | ||
40 | if (port == DINMIDI) | ||
41 | { | ||
42 | hal_send_midi(USBMIDI, status, d1, d2); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void app_sysex_event(u8 port, u8 * data, u16 count) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | void app_aftertouch_event(u8 index, u8 value) | ||
51 | { | ||
52 | // example - send poly aftertouch to MIDI ports | ||
53 | hal_send_midi(USBMIDI, POLYAFTERTOUCH | 0, index, value); | ||
54 | |||
55 | // example - set LED to white, brightness in proportion to pressure | ||
56 | hal_plot_led(TYPEPAD, index, value/2, value/2, value/2); | ||
57 | } | ||
58 | |||
59 | void app_cable_event(u8 type, u8 value) | ||
60 | { | ||
61 | // example - light the Setup LED to indicate cable connection | ||
62 | if (type == MIDI_IN_CABLE) | ||
63 | { | ||
64 | hal_plot_led(TYPESETUP, 0, 0, value, 0); | ||
65 | } | ||
66 | else if (type == MIDI_OUT_CABLE) | ||
67 | { | ||
68 | hal_plot_led(TYPESETUP, 0, value, 0, 0); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | void app_timer_event() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | //______________________________________________________________________________ | ||
77 | |||
78 | void app_init() | ||
79 | { | ||
80 | // example - light the LEDs to say hello! | ||
81 | for (int i=0; i < 10; ++i) | ||
82 | { | ||
83 | for (int j=0; j < 10; ++j) | ||
84 | { | ||
85 | u8 r = i < 5 ? (MAXLED * (5-i))/5 : 0; | ||
86 | u8 g = i < 5 ? (MAXLED * i)/5 : (MAXLED * (10-i))/5; | ||
87 | u8 b = i < 5 ? 0 : (MAXLED * (i-5))/5; | ||
88 | |||
89 | hal_plot_led(TYPEPAD, j*10 + i, r, b, g); | ||
90 | } | ||
91 | } | ||
92 | } | ||