From 453f88515a374772872a9bfef74899312faf6ead Mon Sep 17 00:00:00 2001 From: Jason P Date: Fri, 31 Jul 2026 08:45:51 -0500 Subject: [PATCH 1/2] Update UIRenderer.cpp --- src/graphics/draw/UIRenderer.cpp | 76 ++++++++------------------------ 1 file changed, 19 insertions(+), 57 deletions(-) diff --git a/src/graphics/draw/UIRenderer.cpp b/src/graphics/draw/UIRenderer.cpp index 82baf81d800..e4690dec1c4 100644 --- a/src/graphics/draw/UIRenderer.cpp +++ b/src/graphics/draw/UIRenderer.cpp @@ -38,16 +38,6 @@ NodeNum UIRenderer::currentFavoriteNodeNum = 0; std::vector graphics::UIRenderer::favoritedNodes; static bool gBootSplashBoldPass = false; -static inline void drawSatelliteIcon(OLEDDisplay *display, int16_t x, int16_t y) -{ - int yOffset = (currentResolution == ScreenResolution::High) ? 0 : 1; - if (currentResolution == ScreenResolution::High) { - NodeListRenderer::drawScaledXBitmap16x16(x, y + yOffset, imgGPS_width, imgGPS_height, imgGPS, display); - } else { - display->drawXbm(x + 1, y + yOffset, imgGPS_width, imgGPS_height, imgGPS); - } -} - struct StandardCompassNeedlePoints { int16_t northTipX; int16_t northTipY; @@ -516,7 +506,8 @@ extern GeoCoord geoCoord; // Threshold values for the GPS lock accuracy bar display extern uint32_t dopThresholds[5]; -// Draw GPS status summary +// Draw GPS status summary (satellite icon + status text). +// Handles all GPS states: disabled / not present / fixed position / no lock / sat count. void UIRenderer::drawGps(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gps) { // Draw satellite image @@ -525,26 +516,25 @@ void UIRenderer::drawGps(OLEDDisplay *display, int16_t x, int16_t y, const mesht } else { display->drawXbm(x + 1, y + 3, imgGPS_width, imgGPS_height, imgGPS); } - char textString[10]; - if (config.position.fixed_position) { - // GPS coordinates are currently fixed - snprintf(textString, sizeof(textString), "Fixed"); - } - if (!gps->getIsConnected()) { + char textString[12]; + if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) { + // GPS is disabled or not present + if (config.position.fixed_position) { + snprintf(textString, sizeof(textString), "Fixed GPS"); + } else { + snprintf(textString, sizeof(textString), "%s", + config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off"); + } + } else if (!gps || !gps->getIsConnected()) { snprintf(textString, sizeof(textString), "No Lock"); - } - if (!gps->getHasLock()) { - // Draw "No sats" to the right of the icon with slightly more gap + } else if (!gps->getHasLock()) { snprintf(textString, sizeof(textString), "No Sats"); } else { snprintf(textString, sizeof(textString), "%u sats", gps->getNumSatellites()); } - if (currentResolution == ScreenResolution::High) { - display->drawString(x + 18, y, textString); - } else { - display->drawString(x + 11, y, textString); - } + + display->drawString(x + ((currentResolution == ScreenResolution::High) ? 18 : 11), y, textString); } // Draw status when GPS is disabled or not present @@ -1188,20 +1178,7 @@ void UIRenderer::drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *sta config.display.heading_bold = false; #if HAS_GPS - if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) { - const char *displayLine; - if (config.position.fixed_position) { - displayLine = "Fixed GPS"; - } else { - displayLine = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off"; - } - int yOffset = (currentResolution == ScreenResolution::High) ? 0 : 2; - drawSatelliteIcon(display, x, getTextPositions(display)[line] + yOffset); - int xOffset = (currentResolution == ScreenResolution::High) ? 6 : 0; - display->drawString(x + 11 + xOffset, getTextPositions(display)[line], displayLine); - } else { - UIRenderer::drawGps(display, 0, getTextPositions(display)[line], gpsStatus); - } + UIRenderer::drawGps(display, x, getTextPositions(display)[line], gpsStatus); #endif #if defined(OLED_TINY) @@ -1579,22 +1556,7 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU bool origBold = config.display.heading_bold; config.display.heading_bold = false; - const char *displayLine = ""; // Initialize to empty string by default - - if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) { - if (config.position.fixed_position) { - displayLine = "Fixed GPS"; - } else { - displayLine = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off"; - } - int yOffset = (currentResolution == ScreenResolution::High) ? 1 : 3; - drawSatelliteIcon(display, x, textPos[line] + yOffset); - int xOffset = (currentResolution == ScreenResolution::High) ? 6 : 0; - display->drawString(x + 11 + xOffset, textPos[line++], displayLine); - } else { - // Onboard GPS - UIRenderer::drawGps(display, 0, textPos[line++], gpsStatus); - } + UIRenderer::drawGps(display, x, textPos[line++], gpsStatus); config.display.heading_bold = origBold; @@ -1637,8 +1599,8 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU } } - // If GPS is off, no need to display these parts - if (strcmp(displayLine, "GPS off") != 0 && strcmp(displayLine, "No GPS") != 0) { + // If GPS is off or not present (and position isn't fixed), no need to display these parts + if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED || config.position.fixed_position) { // === Second Row: Last GPS Fix === if (gpsStatus->getLastFixMillis() > 0) { uint32_t delta = millis() - gpsStatus->getLastFixMillis(); From 3b7262796e6c9e5a3cbe7f1ba6ccda23ee3e17ba Mon Sep 17 00:00:00 2001 From: Jason P Date: Fri, 31 Jul 2026 09:18:56 -0500 Subject: [PATCH 2/2] Update GPS code path --- src/graphics/draw/UIRenderer.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/graphics/draw/UIRenderer.cpp b/src/graphics/draw/UIRenderer.cpp index e4690dec1c4..c09ddeed5eb 100644 --- a/src/graphics/draw/UIRenderer.cpp +++ b/src/graphics/draw/UIRenderer.cpp @@ -518,14 +518,13 @@ void UIRenderer::drawGps(OLEDDisplay *display, int16_t x, int16_t y, const mesht } char textString[12]; - if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) { - // GPS is disabled or not present - if (config.position.fixed_position) { - snprintf(textString, sizeof(textString), "Fixed GPS"); - } else { - snprintf(textString, sizeof(textString), "%s", - config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off"); - } + if (config.position.fixed_position) { + // Fixed position overrides live GPS state, regardless of gps_mode + snprintf(textString, sizeof(textString), "Fixed GPS"); + } else if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) { + snprintf(textString, sizeof(textString), "No GPS"); + } else if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) { + snprintf(textString, sizeof(textString), "GPS off"); } else if (!gps || !gps->getIsConnected()) { snprintf(textString, sizeof(textString), "No Lock"); } else if (!gps->getHasLock()) {