Browse Source

add midi tx

Thomas Buck 8 months ago
parent
commit
274e89cdb8
1 changed files with 22 additions and 4 deletions
  1. 22
    4
      src/ui.c

+ 22
- 4
src/ui.c View File

25
 #include "buttons.h"
25
 #include "buttons.h"
26
 #include "lcd.h"
26
 #include "lcd.h"
27
 #include "led.h"
27
 #include "led.h"
28
+#include "pulse.h"
28
 #include "sequence.h"
29
 #include "sequence.h"
29
 #include "usb.h"
30
 #include "usb.h"
30
 #include "usb_midi.h"
31
 #include "usb_midi.h"
81
 static float last_percentage = 0.0f;
82
 static float last_percentage = 0.0f;
82
 static uint8_t midi_rx = 0, midi_tx = 0;
83
 static uint8_t midi_rx = 0, midi_tx = 0;
83
 
84
 
85
+static const uint32_t channel_times[NUM_CHANNELS] = CH_GPIO_TIMINGS;
86
+
84
 enum machine_modes ui_get_machinemode(void) {
87
 enum machine_modes ui_get_machinemode(void) {
85
     return machine_mode;
88
     return machine_mode;
86
 }
89
 }
236
 }
239
 }
237
 
240
 
238
 static void ui_buttons_midi(enum buttons btn, bool val) {
241
 static void ui_buttons_midi(enum buttons btn, bool val) {
239
-    // TODO
240
-    (void)btn;
241
-    (void)val;
242
+    switch (btn) {
243
+        case BTN_A:
244
+        case BTN_B:
245
+        case BTN_C:
246
+        case BTN_D:
247
+        case BTN_E:
248
+        case BTN_F:
249
+        case BTN_G:
250
+        case BTN_H: {
251
+            if (val) {
252
+                usb_midi_tx(midi_tx, btn - BTN_A, 0x7F);
253
+                pulse_trigger_led(btn - BTN_A, channel_times[0]);
254
+            }
255
+        }
256
+
257
+        default:
258
+            break;
259
+    }
242
 }
260
 }
243
 
261
 
244
 static void ui_buttons(enum buttons btn, bool val) {
262
 static void ui_buttons(enum buttons btn, bool val) {
384
 
402
 
385
     note = note % NUM_CHANNELS;
403
     note = note % NUM_CHANNELS;
386
     if (velocity > 0) {
404
     if (velocity > 0) {
387
-        sequence_handle_button_loopstation(BTN_A + note, false);
405
+        pulse_trigger_out(note, channel_times[note]);
388
     }
406
     }
389
 }
407
 }
390
 
408
 

Loading…
Cancel
Save