1
0
forked from me/IronOS

Merge pull request #532 from Ralim/menu-should-timeout

Menu should timeout
This commit is contained in:
Ben V. Brown
2019-12-28 11:10:06 +11:00
committed by GitHub
2 changed files with 11 additions and 10 deletions

View File

@@ -756,7 +756,6 @@ void startGUITask(void const *argument __unused) {
break; break;
case BUTTON_B_SHORT: case BUTTON_B_SHORT:
enterSettingsMenu(); // enter the settings menu enterSettingsMenu(); // enter the settings menu
saveSettings();
buttonLockout = true; buttonLockout = true;
break; break;
default: default:

View File

@@ -12,7 +12,7 @@
#include "TipThermoModel.h" #include "TipThermoModel.h"
#include "string.h" #include "string.h"
extern uint32_t lastButtonTime; extern uint32_t lastButtonTime;
void gui_Menu(const menuitem* menu); void gui_Menu(const menuitem *menu);
#ifdef MODEL_TS100 #ifdef MODEL_TS100
static void settings_setInputVRange(void); static void settings_setInputVRange(void);
static void settings_displayInputVRange(void); static void settings_displayInputVRange(void);
@@ -105,9 +105,8 @@ const menuitem rootSettingsMenu[] {
* Exit * Exit
*/ */
#ifdef MODEL_TS100 #ifdef MODEL_TS100
{ (const char*)SettingsDescriptions[0], { (const char*) SettingsDescriptions[0], { settings_setInputVRange }, {
{ settings_setInputVRange}, settings_displayInputVRange } }, /*Voltage input*/
{ settings_displayInputVRange}}, /*Voltage input*/
#else #else
{ (const char*) SettingsDescriptions[20], { settings_setInputPRange }, { { (const char*) SettingsDescriptions[20], { settings_setInputPRange }, {
settings_displayInputPRange } }, /*Voltage input*/ settings_displayInputPRange } }, /*Voltage input*/
@@ -231,7 +230,7 @@ static void printShortDescription(uint32_t shortDescIndex,
OLED::setCharCursor(cursorCharPosition, 0); OLED::setCharCursor(cursorCharPosition, 0);
} }
static int userConfirmation(const char* message) { static int userConfirmation(const char *message) {
uint16_t messageWidth = FONT_12_WIDTH * (strlen(message) + 7); uint16_t messageWidth = FONT_12_WIDTH * (strlen(message) + 7);
uint32_t messageStart = xTaskGetTickCount(); uint32_t messageStart = xTaskGetTickCount();
@@ -697,7 +696,7 @@ static void settings_enterAdvancedMenu(void) {
gui_Menu(advancedMenu); gui_Menu(advancedMenu);
} }
void gui_Menu(const menuitem* menu) { void gui_Menu(const menuitem *menu) {
// Draw the settings menu and provide iteration support etc // Draw the settings menu and provide iteration support etc
uint8_t currentScreen = 0; uint8_t currentScreen = 0;
uint32_t autoRepeatTimer = 0; uint32_t autoRepeatTimer = 0;
@@ -731,11 +730,8 @@ void gui_Menu(const menuitem* menu) {
/ (systemSettings.descriptionScrollSpeed == 1 ? / (systemSettings.descriptionScrollSpeed == 1 ?
1 : 2)); 1 : 2));
descriptionOffset %= descriptionWidth; // Roll around at the end descriptionOffset %= descriptionWidth; // Roll around at the end
if (lastOffset != descriptionOffset) { if (lastOffset != descriptionOffset) {
OLED::clearScreen(); OLED::clearScreen();
//^ Rolling offset based on time
OLED::setCursor((OLED_WIDTH - descriptionOffset), 0); OLED::setCursor((OLED_WIDTH - descriptionOffset), 0);
OLED::print(menu[currentScreen].description); OLED::print(menu[currentScreen].description);
lastOffset = descriptionOffset; lastOffset = descriptionOffset;
@@ -807,6 +803,12 @@ void gui_Menu(const menuitem* menu) {
osDelay(40); osDelay(40);
lcdRefresh = false; lcdRefresh = false;
} }
if ((xTaskGetTickCount() - lastButtonTime) > (1000 * 30)) {
// If user has not pressed any buttons in 30 seconds, exit back a menu layer
// This will trickle the user back to the main screen eventually
earlyExit = true;
descriptionStart = 0;
}
} }
} }