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

+ 2
- 1
src/ui.c View File

@@ -322,7 +322,8 @@ void ui_encoder(int32_t val) {
322 322
 
323 323
             // midi only when connected to pc
324 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 329
             enum machine_modes prev_mode = machine_mode;

Loading…
Cancel
Save