From c2a15441a4ba226e8481aafeb5e22566082d9261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Degerf=C3=A4lt?= Date: Wed, 26 Jun 2019 18:04:06 +0200 Subject: [PATCH] Fixed regression bug for patch select After the menu refactoring, switching patch with up/down buttons when screen was off didn't work correctly. Now it should work like before i.e. switch patch on first press of button and not requiring a second press. --- NuEVI/menu.cpp | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/NuEVI/menu.cpp b/NuEVI/menu.cpp index cb88b0d..5c6b443 100644 --- a/NuEVI/menu.cpp +++ b/NuEVI/menu.cpp @@ -1070,6 +1070,8 @@ static bool patchPageUpdate(KeyState& input, uint32_t timeNow) { int trills = readTrills(); switch (input.current){ case BTN_DOWN: + // fallthrough + case BTN_UP: if (trills && (fastPatch[trills-1] > 0)){ patch = fastPatch[trills-1]; activePatch = 0; @@ -1077,9 +1079,7 @@ static bool patchPageUpdate(KeyState& input, uint32_t timeNow) { FPD = 1; writeSetting(PATCH_ADDR,patch); } else if (!trills){ - if (patch > 1){ - patch--; - } else patch = 128; + patch = (((patch-1u) + ((input.current == BTN_UP)?1u:-1u))&127u) + 1u; activePatch = 0; doPatchUpdate = 1; FPD = 0; @@ -1099,24 +1099,6 @@ static bool patchPageUpdate(KeyState& input, uint32_t timeNow) { } break; - case BTN_UP: - if (trills && (fastPatch[trills-1] > 0)){ - patch = fastPatch[trills-1]; - activePatch = 0; - doPatchUpdate = 1; - FPD = 1; - writeSetting(PATCH_ADDR,patch); - } else if (!trills){ - if (patch < 128){ - patch++; - } else patch = 1; - activePatch = 0; - doPatchUpdate = 1; - FPD = 0; - } - drawPatchView(); - redraw = true; - break; case BTN_MENU: if (FPD < 2){ @@ -1160,18 +1142,13 @@ static bool idlePageUpdate(KeyState& __unused input, uint32_t __unused timeNow) if (input.changed) { int trills = readTrills(); switch (input.current){ - case BTN_UP: // fallthrough + case BTN_UP: + // fallthrough case BTN_DOWN: - if (trills && (fastPatch[trills-1] > 0)){ - patch = fastPatch[trills-1]; - activePatch = 0; - doPatchUpdate = 1; - FPD = 1; - } // else if (!trills) buttonPressedAndNotUsed = 1; // <- TODO: this is now broken, all input is consumed... solve in another way. - menuState= PATCH_VIEW; - stateFirstRun = 1; - break; - + if (!trills) { + patch = (((patch-1u) + ((input.current == BTN_UP)?1u:-1u))&127u) + 1u; + } + // fallthrough case BTN_ENTER: if (trills && (fastPatch[trills-1] > 0)){ patch = fastPatch[trills-1];