mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Menu Navigation - Long-Press Speed Ramping (#238)
Exponential button acceleration from @jonnieZG
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user