Browse Source

fix some scrolling issues

Thomas Buck 6 months ago
parent
commit
cb60d65568
2 changed files with 3 additions and 2 deletions
  1. 1
    1
      include/ui.h
  2. 2
    1
      src/ui.c

+ 1
- 1
include/ui.h View File

22
 #include <stdint.h>
22
 #include <stdint.h>
23
 
23
 
24
 #define KEEP_IN_RANGE(val, min, len) { \
24
 #define KEEP_IN_RANGE(val, min, len) { \
25
-    while (val > (len - min)) {        \
25
+    while ((val - min) >= len) {       \
26
         val -= len;                    \
26
         val -= len;                    \
27
     }                                  \
27
     }                                  \
28
     while (val < min) {                \
28
     while (val < min) {                \

+ 2
- 1
src/ui.c View File

322
 
322
 
323
             // midi only when connected to pc
323
             // midi only when connected to pc
324
             if ((tmp == MODE_MIDI) && !usb_is_connected()) {
324
             if ((tmp == MODE_MIDI) && !usb_is_connected()) {
325
-                tmp = (tmp + 1) % MACHINE_NUM_MODES;
325
+                tmp = tmp + val;
326
+                KEEP_IN_RANGE(tmp, 0, MACHINE_NUM_MODES);
326
             }
327
             }
327
 
328
 
328
             enum machine_modes prev_mode = machine_mode;
329
             enum machine_modes prev_mode = machine_mode;

Loading…
Cancel
Save