diff --git a/workspace/TS100/inc/gui.hpp b/workspace/TS100/inc/gui.hpp index d5168d8d..d79b71dd 100644 --- a/workspace/TS100/inc/gui.hpp +++ b/workspace/TS100/inc/gui.hpp @@ -11,6 +11,11 @@ #include "Settings.h" #include "hardware.h" +#define PRESS_ACCEL_STEP 3 +#define PRESS_ACCEL_INTERVAL_MIN 10 +#define PRESS_ACCEL_INTERVAL_MAX 30 + + //GUI holds the menu structure and all its methods for the menu itself //Declarations for all the methods for the settings menu (at end of this file) diff --git a/workspace/TS100/src/gui.cpp b/workspace/TS100/src/gui.cpp index eb6c81b7..2371774f 100644 --- a/workspace/TS100/src/gui.cpp +++ b/workspace/TS100/src/gui.cpp @@ -609,10 +609,12 @@ void gui_Menu(const menuitem* menu) { // Draw the settings menu and provide iteration support etc uint8_t currentScreen = 0; uint32_t autoRepeatTimer = 0; + uint8_t autoRepeatAcceleration = 0; bool earlyExit = false; uint32_t descriptionStart = 0; int16_t lastOffset = -1; bool lcdRefresh = true; + ButtonState lastButtonState = BUTTON_NONE; while ((menu[currentScreen].draw.func != NULL) && earlyExit == false) { lcd.setFont(0); @@ -651,6 +653,11 @@ void gui_Menu(const menuitem* menu) { ButtonState buttons = getButtonState(); + if (buttons != lastButtonState) { + autoRepeatAcceleration = 0; + lastButtonState = buttons; + } + switch (buttons) { case BUTTON_BOTH: earlyExit = true; // will make us exit next loop @@ -672,19 +679,24 @@ void gui_Menu(const menuitem* menu) { else descriptionStart = 0; break; - //#TODO: Impliment ramping change case BUTTON_F_LONG: - if (xTaskGetTickCount() - autoRepeatTimer > 30) { + if (xTaskGetTickCount() - autoRepeatTimer + + autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) { menu[currentScreen].incrementHandler.func(); autoRepeatTimer = xTaskGetTickCount(); descriptionStart = 0; + + autoRepeatAcceleration += PRESS_ACCEL_STEP; } break; case BUTTON_B_LONG: - if (xTaskGetTickCount() - autoRepeatTimer > 30) { + if (xTaskGetTickCount() - autoRepeatTimer + + autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) { currentScreen++; autoRepeatTimer = xTaskGetTickCount(); descriptionStart = 0; + + autoRepeatAcceleration += PRESS_ACCEL_STEP; } break; case BUTTON_NONE: @@ -692,6 +704,11 @@ void gui_Menu(const menuitem* menu) { break; } + if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) + < PRESS_ACCEL_INTERVAL_MIN) { + autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN; + } + if (lcdRefresh) { lcd.refresh(); // update the LCD osDelay(20);