summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-02-08 14:42:58 +0100
committerBad Diode <bd@badd10de.dev>2023-02-08 14:42:58 +0100
commitc5095a38738d0f432245d14f91098c6309c1f6cc (patch)
tree36b36ef25eabac6c0c7ee69398378b2d395db2d7
parent08983247025697848579b35ef693d0b44904f728 (diff)
downloadlaunchpad-polymaker-c5095a38738d0f432245d14f91098c6309c1f6cc.tar.gz
launchpad-polymaker-c5095a38738d0f432245d14f91098c6309c1f6cc.zip
Add a voice counter
-rw-r--r--src/app.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/app.c b/src/app.c
index 013025c..9258965 100644
--- a/src/app.c
+++ b/src/app.c
@@ -32,6 +32,10 @@
32 32
33#include "app.h" 33#include "app.h"
34 34
35// Housekeeping and debugging.
36u16 frame = 0;
37u16 value = 0;
38
35// store ADC frame pointer 39// store ADC frame pointer
36static const u16 *g_ADC = 0; 40static const u16 *g_ADC = 0;
37 41
@@ -155,6 +159,11 @@ app_midi_event(u8 port, u8 status, u8 d1, u8 d2) {
155 if (port == DINMIDI) { 159 if (port == DINMIDI) {
156 hal_send_midi(USBMIDI, status, d1, d2); 160 hal_send_midi(USBMIDI, status, d1, d2);
157 } 161 }
162 if ((status & 0xF0) == NOTEON) {
163 value++;
164 } else if ((status & 0xF0) == NOTEOFF) {
165 value--;
166 }
158} 167}
159 168
160void 169void
@@ -192,20 +201,17 @@ print_number(u8 n, u16 r, u16 g, u16 b, u8 x, u8 y) {
192 } 201 }
193} 202}
194 203
195u16 frame = 0;
196u16 value = 0;
197
198void 204void
199update(void) { 205update(void) {
200 for (int i = 0; i < PAD_COUNT; ++i) { 206 // for (int i = 0; i < PAD_COUNT; ++i) {
201 // Get the first detected button value. 207 // // Get the first detected button value.
202 u16 x = (99 * g_ADC[i]) >> 12; 208 // u16 x = (99 * g_ADC[i]) >> 12;
203 if (x > 3) { 209 // if (x > 3) {
204 value = x; 210 // value = x;
205 return; 211 // return;
206 } 212 // }
207 } 213 // }
208 value = 0; 214 // value = 0;
209} 215}
210 216
211void 217void