kopia lustrzana https://github.com/OpenRTX/OpenRTX
Turn off GPS when it's turned off in settings
rodzic
31552ff2b2
commit
619cda7aeb
|
@ -67,6 +67,7 @@
|
|||
#include <rtx.h>
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/gps.h>
|
||||
#include <string.h>
|
||||
#include <battery.h>
|
||||
#include <input.h>
|
||||
|
@ -1046,23 +1047,30 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
_ui_menuBack(MENU_SETTINGS);
|
||||
break;
|
||||
case SETTINGS_GPS:
|
||||
if(msg.keys & KEY_LEFT || (msg.keys & KEY_UP && ui_state.edit_mode))
|
||||
if(msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT ||
|
||||
((msg.keys & KEY_UP || msg.keys & KEY_DOWN) && ui_state.edit_mode))
|
||||
{
|
||||
if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Enabled") == 0)
|
||||
state.settings.gps_enabled = !state.settings.gps_enabled;
|
||||
{
|
||||
// Disable or Enable GPS to stop or start GPS thread
|
||||
if(state.settings.gps_enabled)
|
||||
{
|
||||
state.settings.gps_enabled = !state.settings.gps_enabled;
|
||||
gps_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
state.settings.gps_enabled = !state.settings.gps_enabled;
|
||||
gps_enable();
|
||||
}
|
||||
}
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Set Time") == 0)
|
||||
state.settings.gps_set_time = !state.settings.gps_set_time;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "UTC Timezone") == 0)
|
||||
state.settings.utc_timezone -= 1;
|
||||
}
|
||||
else if(msg.keys & KEY_RIGHT || (msg.keys & KEY_DOWN && ui_state.edit_mode))
|
||||
{
|
||||
if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Enabled") == 0)
|
||||
state.settings.gps_enabled = !state.settings.gps_enabled;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "GPS Set Time") == 0)
|
||||
state.settings.gps_set_time = !state.settings.gps_set_time;
|
||||
else if(strcmp(settings_gps_items[ui_state.menu_selected], "UTC Timezone") == 0)
|
||||
state.settings.utc_timezone += 1;
|
||||
if(msg.keys & KEY_LEFT || msg.keys & KEY_UP)
|
||||
state.settings.utc_timezone -= 1;
|
||||
else if(msg.keys & KEY_RIGHT || msg.keys & KEY_DOWN)
|
||||
state.settings.utc_timezone += 1;
|
||||
}
|
||||
else if(msg.keys & KEY_UP)
|
||||
_ui_menuUp(settings_gps_num);
|
||||
|
|
|
@ -146,11 +146,13 @@ int _ui_getSettingsGPSValueName(char *buf, uint8_t max_len, uint8_t index)
|
|||
else if(strcmp(settings_gps_items[index], "GPS Set Time") == 0)
|
||||
snprintf(buf, max_len, "%s", (last_state.settings.gps_set_time) ? "ON" : "OFF");
|
||||
else if(strcmp(settings_gps_items[index], "UTC Timezone") == 0)
|
||||
{
|
||||
// Add + prefix to positive numbers
|
||||
if(last_state.settings.utc_timezone > 0)
|
||||
snprintf(buf, max_len, "+%d", last_state.settings.utc_timezone);
|
||||
else
|
||||
snprintf(buf, max_len, "%d", last_state.settings.utc_timezone);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -270,18 +272,15 @@ void _ui_drawMenuGPS(ui_state_t* ui_state)
|
|||
// Print "GPS" on top bar
|
||||
gfx_print(layout.top_pos, "GPS", layout.top_font,
|
||||
TEXT_ALIGN_CENTER, color_white);
|
||||
point_t fix_pos = {layout.line2_pos.x, SCREEN_HEIGHT * 2 / 5};
|
||||
// Print GPS status, if no fix, hide details
|
||||
if (last_state.gps_data.fix_quality == 0)
|
||||
{
|
||||
point_t fix_pos = {layout.line2_pos.x, SCREEN_HEIGHT * 2 / 5};
|
||||
gfx_print(fix_pos, "No Fix", layout.line3_font, TEXT_ALIGN_CENTER,
|
||||
color_white);
|
||||
} else if (last_state.gps_data.fix_quality == 6)
|
||||
{
|
||||
point_t fix_pos = {layout.line2_pos.x, SCREEN_HEIGHT * 2 / 5};
|
||||
gfx_print(fix_pos, "Fix Lost", layout.line3_font, TEXT_ALIGN_CENTER,
|
||||
color_white);
|
||||
} else
|
||||
if(!last_state.settings.gps_enabled)
|
||||
gfx_print(fix_pos, "GPS OFF", layout.line3_font, TEXT_ALIGN_CENTER, color_white);
|
||||
else if (last_state.gps_data.fix_quality == 0)
|
||||
gfx_print(fix_pos, "No Fix", layout.line3_font, TEXT_ALIGN_CENTER, color_white);
|
||||
else if (last_state.gps_data.fix_quality == 6)
|
||||
gfx_print(fix_pos, "Fix Lost", layout.line3_font, TEXT_ALIGN_CENTER, color_white);
|
||||
else
|
||||
{
|
||||
switch(last_state.gps_data.fix_quality)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue