kopia lustrzana https://github.com/OpenRTX/OpenRTX
UI: Add GPS settings menu
rodzic
a803958c61
commit
d66b59694a
|
@ -25,6 +25,9 @@ typedef struct
|
|||
{
|
||||
uint8_t brightness;
|
||||
uint8_t contrast;
|
||||
bool gps_enabled;
|
||||
bool gps_set_time;
|
||||
int8_t utc_timezone;
|
||||
}
|
||||
settings_t;
|
||||
|
||||
|
|
|
@ -123,11 +123,13 @@ extern settings_t settings;
|
|||
extern const char *menu_items[];
|
||||
extern const char *settings_items[];
|
||||
extern const char *display_items[];
|
||||
extern const char *settings_gps_items[];
|
||||
extern const char *info_items[];
|
||||
extern const char *authors[];
|
||||
extern const uint8_t menu_num;
|
||||
extern const uint8_t settings_num;
|
||||
extern const uint8_t display_num;
|
||||
extern const uint8_t settings_gps_num;
|
||||
extern const uint8_t info_num;
|
||||
extern const uint8_t author_num;
|
||||
extern const color_t color_black;
|
||||
|
|
|
@ -128,6 +128,13 @@ const char *display_items[] =
|
|||
#endif
|
||||
};
|
||||
|
||||
const char *settings_gps_items[] =
|
||||
{
|
||||
"GPS Enabled",
|
||||
"GPS Set Time",
|
||||
"UTC Timezone"
|
||||
};
|
||||
|
||||
const char *info_items[] =
|
||||
{
|
||||
"Bat. Voltage",
|
||||
|
@ -147,15 +154,13 @@ const char *authors[] =
|
|||
"Federico IU2NUO",
|
||||
"Fred IU2NRO",
|
||||
};
|
||||
// Calculate number of main menu entries
|
||||
|
||||
// Calculate number of menu entries
|
||||
const uint8_t menu_num = sizeof(menu_items)/sizeof(menu_items[0]);
|
||||
// Calculate number of settings menu entries
|
||||
const uint8_t settings_num = sizeof(settings_items)/sizeof(settings_items[0]);
|
||||
// Calculate number of display settings menu entries
|
||||
const uint8_t display_num = sizeof(display_items)/sizeof(display_items[0]);
|
||||
// Calculate number of info menu entries
|
||||
const uint8_t settings_gps_num = sizeof(settings_gps_items)/sizeof(settings_gps_items[0]);
|
||||
const uint8_t info_num = sizeof(info_items)/sizeof(info_items[0]);
|
||||
// Calculate number of authors
|
||||
const uint8_t author_num = sizeof(authors)/sizeof(authors[0]);
|
||||
|
||||
const color_t color_black = {0, 0, 0, 255};
|
||||
|
@ -1058,6 +1063,37 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
ui_state.menu_selected = 0;
|
||||
}
|
||||
break;
|
||||
case SETTINGS_GPS:
|
||||
if(msg.keys & KEY_UP)
|
||||
_ui_menuUp(settings_gps_num);
|
||||
else if(msg.keys & KEY_DOWN)
|
||||
_ui_menuDown(settings_gps_num);
|
||||
if(msg.keys & KEY_LEFT)
|
||||
{
|
||||
if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Enabled") == 0)
|
||||
settings.gps_enabled = !settings.gps_enabled;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Set Time") == 0)
|
||||
settings.gps_set_time = !settings.gps_set_time;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "UTC Timezone") == 0)
|
||||
settings.utc_timezone -= 1;
|
||||
}
|
||||
else if(msg.keys & KEY_RIGHT)
|
||||
{
|
||||
if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Enabled") == 0)
|
||||
settings.gps_enabled = !settings.gps_enabled;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Set Time") == 0)
|
||||
settings.gps_set_time = !settings.gps_set_time;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "UTC Timezone") == 0)
|
||||
settings.utc_timezone += 1;
|
||||
}
|
||||
else if(msg.keys & KEY_ESC)
|
||||
{
|
||||
// Return to settings menu
|
||||
state.ui_screen = MENU_SETTINGS;
|
||||
// Reset menu selection
|
||||
ui_state.menu_selected = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1126,9 +1162,14 @@ void ui_updateGUI()
|
|||
_ui_drawSettingsTimeDateSet(&ui_state);
|
||||
break;
|
||||
#endif
|
||||
// Display settings screen
|
||||
case SETTINGS_DISPLAY:
|
||||
_ui_drawSettingsDisplay(&ui_state);
|
||||
break;
|
||||
// GPS settings screen
|
||||
case SETTINGS_GPS:
|
||||
_ui_drawSettingsGPS(&ui_state);
|
||||
break;
|
||||
// Low battery screen
|
||||
case LOW_BAT:
|
||||
_ui_drawLowBatteryScreen();
|
||||
|
|
|
@ -124,6 +124,29 @@ int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int _ui_getSettingsGPSEntryName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
if(index >= settings_gps_num) return -1;
|
||||
snprintf(buf, max_len, "%s", settings_gps_items[index]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ui_getSettingsGPSValueName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
if(index >= settings_gps_num) return -1;
|
||||
if(strcmp(settings_gps_items[index], "GPS Enabled") == 0)
|
||||
snprintf(buf, max_len, "%s", (settings.gps_enabled) ? "ON" : "OFF");
|
||||
else if(strcmp(settings_gps_items[index], "GPS Set Time") == 0)
|
||||
snprintf(buf, max_len, "%s", (settings.gps_set_time) ? "ON" : "OFF");
|
||||
else if(strcmp(settings_gps_items[index], "UTC Timezone") == 0)
|
||||
// Add + prefix to positive numbers
|
||||
if(settings.utc_timezone > 0)
|
||||
snprintf(buf, max_len, "+%d", settings.utc_timezone);
|
||||
else
|
||||
snprintf(buf, max_len, "%d", settings.utc_timezone);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ui_getInfoEntryName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
if(index >= info_num) return -1;
|
||||
|
@ -367,6 +390,18 @@ void _ui_drawSettingsDisplay(ui_state_t* ui_state)
|
|||
_ui_getDisplayValueName);
|
||||
}
|
||||
|
||||
void _ui_drawSettingsGPS(ui_state_t* ui_state)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
// Print "GPS Settings" on top bar
|
||||
gfx_print(layout.top_pos, "GPS Settings", layout.top_font,
|
||||
TEXT_ALIGN_CENTER, color_white);
|
||||
// Print display settings entries
|
||||
_ui_drawMenuListValue(layout.line1_pos, ui_state->menu_selected,
|
||||
_ui_getSettingsGPSEntryName,
|
||||
_ui_getSettingsGPSValueName);
|
||||
}
|
||||
|
||||
#ifdef HAS_RTC
|
||||
void _ui_drawSettingsTimeDate()
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue