From f2f84f3da12443e966de3adb985f066c2e6a77fc Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Wed, 1 Oct 2025 21:11:28 +0200 Subject: [PATCH] core: gps: add enums for GPS fix quality and type Signed-off-by: Silvano Seva --- openrtx/include/core/gps.h | 24 ++++++++++++++++++++++++ openrtx/src/ui/default/ui_menu.c | 22 +++++++++++++--------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/openrtx/include/core/gps.h b/openrtx/include/core/gps.h index 02face3a..199e5c1b 100644 --- a/openrtx/include/core/gps.h +++ b/openrtx/include/core/gps.h @@ -24,6 +24,30 @@ #include #include +/** + * Enumeration type for GPS fix quality, according to the quality + * indicator field of NMEA GGA sentence + */ +enum FixQuality { + FIX_QUALITY_NO_FIX = 0, + FIX_QUALITY_GPS, + FIX_QUALITY_DGPS, + FIX_QUALITY_PPS, + FIX_QUALITY_RTK, + FIX_QUALITY_RTK_FLOAT, + FIX_QUALITY_ESTIMATED, +}; + +/** + * Enumeration type for GPS fix type, according to the fix type field of + * NMEA GSA sentence + */ +enum FixType { + FIX_TYPE_NOT_AVAIL = 1, + FIX_TYPE_2D, + FIX_TYPE_3D, +}; + /** * Data structure representing a single satellite as part of a GPS fix. */ diff --git a/openrtx/src/ui/default/ui_menu.c b/openrtx/src/ui/default/ui_menu.c index 57f8b23c..9c588dd0 100644 --- a/openrtx/src/ui/default/ui_menu.c +++ b/openrtx/src/ui/default/ui_menu.c @@ -684,25 +684,29 @@ void _ui_drawMenuGPS() else if(!last_state.settings.gps_enabled) gfx_print(fix_pos, layout.line3_large_font, TEXT_ALIGN_CENTER, color_white, currentLanguage->gpsOff); - else if (last_state.gps_data.fix_quality == 0) + else if (last_state.gps_data.fix_quality == FIX_QUALITY_NO_FIX) gfx_print(fix_pos, layout.line3_large_font, TEXT_ALIGN_CENTER, color_white, currentLanguage->noFix); - else if (last_state.gps_data.fix_quality == 6) + else if (last_state.gps_data.fix_quality == FIX_QUALITY_ESTIMATED) gfx_print(fix_pos, layout.line3_large_font, TEXT_ALIGN_CENTER, color_white, currentLanguage->fixLost); else { switch(last_state.gps_data.fix_quality) { - case 1: - fix_buf = "SPS"; + case FIX_QUALITY_GPS: + fix_buf = "GPS"; break; - case 2: + case FIX_QUALITY_DGPS: fix_buf = "DGPS"; break; - case 3: + case FIX_QUALITY_PPS: fix_buf = "PPS"; break; + case FIX_QUALITY_RTK: + case FIX_QUALITY_RTK_FLOAT: + fix_buf = "RTK"; + break; default: fix_buf = (char*)currentLanguage->error; break; @@ -710,13 +714,13 @@ void _ui_drawMenuGPS() switch(last_state.gps_data.fix_type) { - case 1: + case FIX_TYPE_NOT_AVAIL: type_buf = ""; break; - case 2: + case FIX_TYPE_2D: type_buf = "2D"; break; - case 3: + case FIX_TYPE_3D: type_buf = "3D"; break; default: