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,6 +25,7 @@
25 25
 #include "buttons.h"
26 26
 #include "lcd.h"
27 27
 #include "led.h"
28
+#include "pulse.h"
28 29
 #include "sequence.h"
29 30
 #include "usb.h"
30 31
 #include "usb_midi.h"
@@ -81,6 +82,8 @@ static float last_voltage = 0.0f;
81 82
 static float last_percentage = 0.0f;
82 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 87
 enum machine_modes ui_get_machinemode(void) {
85 88
     return machine_mode;
86 89
 }
@@ -236,9 +239,24 @@ static void ui_buttons_drummachine(enum buttons btn, bool val) {
236 239
 }
237 240
 
238 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 262
 static void ui_buttons(enum buttons btn, bool val) {
@@ -384,7 +402,7 @@ void ui_midi_set(uint8_t channel, uint8_t note, uint8_t velocity) {
384 402
 
385 403
     note = note % NUM_CHANNELS;
386 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