Bladeren bron

add midi tx

Thomas Buck 1 maand geleden
bovenliggende
commit
274e89cdb8
1 gewijzigde bestanden met toevoegingen van 22 en 4 verwijderingen
  1. 22
    4
      src/ui.c

+ 22
- 4
src/ui.c Bestand weergeven

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
 

Laden…
Annuleren
Opslaan