Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 17 additions & 56 deletions src/graphics/draw/UIRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ NodeNum UIRenderer::currentFavoriteNodeNum = 0;
std::vector<meshtastic_NodeInfoLite *> 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;
Expand Down Expand Up @@ -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
Expand All @@ -525,26 +516,24 @@ 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];

char textString[12];
if (config.position.fixed_position) {
// GPS coordinates are currently fixed
snprintf(textString, sizeof(textString), "Fixed");
}
if (!gps->getIsConnected()) {
// 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");
}
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
Expand Down Expand Up @@ -1188,20 +1177,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)
Expand Down Expand Up @@ -1579,22 +1555,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;

Expand Down Expand Up @@ -1637,8 +1598,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();
Expand Down
Loading