diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 62 |
1 files changed, 60 insertions, 2 deletions
@@ -51,37 +51,94 @@ static const u16 *g_ADC = 0; | |||
51 | 51 | ||
52 | void app_surface_event(u8 type, u8 index, u8 value) | 52 | void app_surface_event(u8 type, u8 index, u8 value) |
53 | { | 53 | { |
54 | switch (type) | ||
55 | { | ||
56 | case TYPEPAD: | ||
57 | { | ||
58 | // example - light / extinguish pad LEDs, send MIDI | ||
59 | hal_plot_led(TYPEPAD, index, value, value, value); | ||
60 | hal_send_midi(DINMIDI, NOTEON | 0, index, value); | ||
61 | } | ||
62 | break; | ||
63 | |||
64 | case TYPESETUP: | ||
65 | { | ||
66 | // example - light the setup LED | ||
67 | hal_plot_led(TYPESETUP, 0, value, value, value); | ||
68 | } | ||
69 | break; | ||
70 | } | ||
54 | } | 71 | } |
55 | 72 | ||
56 | //______________________________________________________________________________ | 73 | //______________________________________________________________________________ |
57 | 74 | ||
58 | void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) | 75 | void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) |
59 | { | 76 | { |
77 | // example - MIDI interface functionality for USB "MIDI" port -> DIN port | ||
78 | if (port == USBMIDI) | ||
79 | { | ||
80 | hal_send_midi(DINMIDI, status, d1, d2); | ||
81 | } | ||
82 | |||
83 | // // example -MIDI interface functionality for DIN -> USB "MIDI" port port | ||
84 | if (port == DINMIDI) | ||
85 | { | ||
86 | hal_send_midi(USBMIDI, status, d1, d2); | ||
87 | } | ||
60 | } | 88 | } |
61 | 89 | ||
62 | //______________________________________________________________________________ | 90 | //______________________________________________________________________________ |
63 | 91 | ||
64 | void app_sysex_event(u8 port, u8 * data, u16 count) | 92 | void app_sysex_event(u8 port, u8 * data, u16 count) |
65 | { | 93 | { |
94 | // example - respond to UDI messages? | ||
66 | } | 95 | } |
67 | 96 | ||
68 | //______________________________________________________________________________ | 97 | //______________________________________________________________________________ |
69 | 98 | ||
70 | void app_aftertouch_event(u8 index, u8 value) | 99 | void app_aftertouch_event(u8 index, u8 value) |
71 | { | 100 | { |
101 | // example - send poly aftertouch to MIDI ports | ||
102 | hal_send_midi(USBMIDI, POLYAFTERTOUCH | 0, index, value); | ||
103 | |||
104 | // example - set LED to white, brightness in proportion to pressure | ||
105 | hal_plot_led(TYPEPAD, index, value/2, value/2, value/2); | ||
72 | } | 106 | } |
73 | 107 | ||
74 | //______________________________________________________________________________ | 108 | //______________________________________________________________________________ |
75 | 109 | ||
76 | void app_cable_event(u8 type, u8 value) | 110 | void app_cable_event(u8 type, u8 value) |
77 | { | 111 | { |
112 | // example - light the Setup LED to indicate cable connections | ||
113 | if (type == MIDI_IN_CABLE) | ||
114 | { | ||
115 | hal_plot_led(TYPESETUP, 0, 0, value, 0); // green | ||
116 | } | ||
117 | else if (type == MIDI_OUT_CABLE) | ||
118 | { | ||
119 | hal_plot_led(TYPESETUP, 0, value, 0, 0); // red | ||
120 | } | ||
78 | } | 121 | } |
79 | 122 | ||
80 | //______________________________________________________________________________ | 123 | //______________________________________________________________________________ |
81 | 124 | ||
82 | void app_timer_event() | 125 | void app_timer_event() |
83 | { | 126 | { |
84 | // render raw ADC data as LEDs | 127 | // example - send MIDI clock at 125bpm |
128 | #define TICK_MS 20 | ||
129 | |||
130 | static u8 ms = TICK_MS; | ||
131 | |||
132 | if (++ms >= TICK_MS) | ||
133 | { | ||
134 | ms = 0; | ||
135 | |||
136 | // send a clock pulse up the USB | ||
137 | hal_send_midi(USBSTANDALONE, MIDITIMINGCLOCK, 0, 0); | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | // alternative example - show raw ADC data as LEDs | ||
85 | for (int i=0; i < PAD_COUNT; ++i) | 142 | for (int i=0; i < PAD_COUNT; ++i) |
86 | { | 143 | { |
87 | // raw adc values are 12 bit, but LEDs are 6 bit. | 144 | // raw adc values are 12 bit, but LEDs are 6 bit. |
@@ -109,6 +166,7 @@ void app_timer_event() | |||
109 | 166 | ||
110 | hal_plot_led(TYPEPAD, ADC_MAP[i], r, g, b); | 167 | hal_plot_led(TYPEPAD, ADC_MAP[i], r, g, b); |
111 | } | 168 | } |
169 | */ | ||
112 | } | 170 | } |
113 | 171 | ||
114 | //______________________________________________________________________________ | 172 | //______________________________________________________________________________ |