kopia lustrzana https://github.com/OpenRTX/OpenRTX
UI: Menu scrolling logic refactoring, add GPS Settings entry
rodzic
0a04650d58
commit
a803958c61
|
@ -53,6 +53,7 @@ enum uiScreen
|
||||||
SETTINGS_TIMEDATE,
|
SETTINGS_TIMEDATE,
|
||||||
SETTINGS_TIMEDATE_SET,
|
SETTINGS_TIMEDATE_SET,
|
||||||
SETTINGS_DISPLAY,
|
SETTINGS_DISPLAY,
|
||||||
|
SETTINGS_GPS,
|
||||||
LOW_BAT
|
LOW_BAT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ const char *settings_items[] =
|
||||||
"Time & Date",
|
"Time & Date",
|
||||||
#endif
|
#endif
|
||||||
"Display",
|
"Display",
|
||||||
|
"GPS"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *display_items[] =
|
const char *display_items[] =
|
||||||
|
@ -630,6 +631,22 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _ui_menuUp(uint8_t menu_entries)
|
||||||
|
{
|
||||||
|
if(ui_state.menu_selected > 0)
|
||||||
|
ui_state.menu_selected -= 1;
|
||||||
|
else
|
||||||
|
ui_state.menu_selected = menu_entries - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _ui_menuDown(uint8_t menu_entries)
|
||||||
|
{
|
||||||
|
if(ui_state.menu_selected < menu_entries - 1)
|
||||||
|
ui_state.menu_selected += 1;
|
||||||
|
else
|
||||||
|
ui_state.menu_selected = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ui_saveState()
|
void ui_saveState()
|
||||||
{
|
{
|
||||||
last_state = state;
|
last_state = state;
|
||||||
|
@ -777,19 +794,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
// Top menu screen
|
// Top menu screen
|
||||||
case MENU_TOP:
|
case MENU_TOP:
|
||||||
if(msg.keys & KEY_UP)
|
if(msg.keys & KEY_UP)
|
||||||
{
|
_ui_menuUp(menu_num);
|
||||||
if(ui_state.menu_selected > 0)
|
|
||||||
ui_state.menu_selected -= 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = menu_num-1;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_DOWN)
|
||||||
{
|
_ui_menuDown(menu_num);
|
||||||
if(ui_state.menu_selected < menu_num-1)
|
|
||||||
ui_state.menu_selected += 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = 0;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_ENTER)
|
else if(msg.keys & KEY_ENTER)
|
||||||
{
|
{
|
||||||
// Open selected menu item
|
// Open selected menu item
|
||||||
|
@ -838,10 +845,8 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
// Contacts menu screen
|
// Contacts menu screen
|
||||||
case MENU_CONTACTS:
|
case MENU_CONTACTS:
|
||||||
if(msg.keys & KEY_UP)
|
if(msg.keys & KEY_UP)
|
||||||
{
|
// Using 1 as parameter disables menu wrap around
|
||||||
if(ui_state.menu_selected > 0)
|
_ui_menuUp(1);
|
||||||
ui_state.menu_selected -= 1;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_DOWN)
|
||||||
{
|
{
|
||||||
if(state.ui_screen == MENU_ZONE)
|
if(state.ui_screen == MENU_ZONE)
|
||||||
|
@ -924,38 +929,19 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
// Settings menu screen
|
// Settings menu screen
|
||||||
case MENU_SETTINGS:
|
case MENU_SETTINGS:
|
||||||
if(msg.keys & KEY_UP)
|
if(msg.keys & KEY_UP)
|
||||||
{
|
_ui_menuUp(settings_num);
|
||||||
if(ui_state.menu_selected > 0)
|
|
||||||
ui_state.menu_selected -= 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = settings_num-1;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_DOWN)
|
||||||
{
|
_ui_menuDown(settings_num);
|
||||||
if(ui_state.menu_selected < settings_num-1)
|
|
||||||
ui_state.menu_selected += 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = 0;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_ENTER)
|
else if(msg.keys & KEY_ENTER)
|
||||||
{
|
{
|
||||||
// Open selected menu item
|
if(strcmp(settings_items[ui_state.menu_selected], "Time & Date") == 0)
|
||||||
switch(ui_state.menu_selected)
|
state.ui_screen = SETTINGS_TIMEDATE;
|
||||||
{
|
else if(strcmp(settings_items[ui_state.menu_selected], "Display") == 0)
|
||||||
#ifdef HAS_RTC
|
state.ui_screen = SETTINGS_DISPLAY;
|
||||||
// TODO: Add missing submenu states
|
else if(strcmp(settings_items[ui_state.menu_selected], "GPS") == 0)
|
||||||
case 0:
|
state.ui_screen = SETTINGS_GPS;
|
||||||
state.ui_screen = SETTINGS_TIMEDATE;
|
else
|
||||||
break;
|
state.ui_screen = MENU_TOP;
|
||||||
case 1:
|
|
||||||
#else
|
|
||||||
case 0:
|
|
||||||
#endif
|
|
||||||
state.ui_screen = SETTINGS_DISPLAY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state.ui_screen = MENU_TOP;
|
|
||||||
}
|
|
||||||
// Reset menu selection
|
// Reset menu selection
|
||||||
ui_state.menu_selected = 0;
|
ui_state.menu_selected = 0;
|
||||||
}
|
}
|
||||||
|
@ -970,19 +956,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
// Info menu screen
|
// Info menu screen
|
||||||
case MENU_INFO:
|
case MENU_INFO:
|
||||||
if(msg.keys & KEY_UP)
|
if(msg.keys & KEY_UP)
|
||||||
{
|
_ui_menuUp(info_num);
|
||||||
if(ui_state.menu_selected > 0)
|
|
||||||
ui_state.menu_selected -= 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = info_num-1;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_DOWN)
|
||||||
{
|
_ui_menuDown(info_num);
|
||||||
if(ui_state.menu_selected < info_num-1)
|
|
||||||
ui_state.menu_selected += 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = 0;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_ESC)
|
else if(msg.keys & KEY_ESC)
|
||||||
{
|
{
|
||||||
// Return to top menu
|
// Return to top menu
|
||||||
|
@ -1049,19 +1025,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
#endif
|
#endif
|
||||||
case SETTINGS_DISPLAY:
|
case SETTINGS_DISPLAY:
|
||||||
if(msg.keys & KEY_UP)
|
if(msg.keys & KEY_UP)
|
||||||
{
|
_ui_menuUp(display_num);
|
||||||
if(ui_state.menu_selected > 0)
|
|
||||||
ui_state.menu_selected -= 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = display_num-1;
|
|
||||||
}
|
|
||||||
else if(msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_DOWN)
|
||||||
{
|
_ui_menuDown(display_num);
|
||||||
if(ui_state.menu_selected < display_num-1)
|
|
||||||
ui_state.menu_selected += 1;
|
|
||||||
else
|
|
||||||
ui_state.menu_selected = 0;
|
|
||||||
}
|
|
||||||
if(msg.keys & KEY_LEFT)
|
if(msg.keys & KEY_LEFT)
|
||||||
{
|
{
|
||||||
if(strcmp(display_items[ui_state.menu_selected], "Brightness") == 0)
|
if(strcmp(display_items[ui_state.menu_selected], "Brightness") == 0)
|
||||||
|
|
Ładowanie…
Reference in New Issue