Adjustments to GPS screen

This commit is contained in:
HarukiToreda 2025-05-12 13:58:13 -04:00
parent 7293e542ec
commit c40fdc9a43

View File

@ -1149,10 +1149,14 @@ void drawStringWithEmotes(OLEDDisplay* display, int x, int y, const std::string&
} }
if (!matched) { if (!matched) {
uint8_t c = static_cast<uint8_t>(line[i]); uint8_t c = static_cast<uint8_t>(line[i]);
if ((c & 0xE0) == 0xC0) i += 2; if ((c & 0xE0) == 0xC0)
else if ((c & 0xF0) == 0xE0) i += 3; i += 2;
else if ((c & 0xF8) == 0xF0) i += 4; else if ((c & 0xF0) == 0xE0)
else i += 1; i += 3;
else if ((c & 0xF8) == 0xF0)
i += 4;
else
i += 1;
} }
} }
@ -1190,7 +1194,8 @@ void drawStringWithEmotes(OLEDDisplay* display, int x, int y, const std::string&
// Render normal text segment up to the emote or bold toggle // Render normal text segment up to the emote or bold toggle
size_t nextControl = std::min(nextEmotePos, line.find("**", i)); size_t nextControl = std::min(nextEmotePos, line.find("**", i));
if (nextControl == std::string::npos) nextControl = line.length(); if (nextControl == std::string::npos)
nextControl = line.length();
if (nextControl > i) { if (nextControl > i) {
std::string textChunk = line.substr(i, nextControl - i); std::string textChunk = line.substr(i, nextControl - i);
@ -2561,43 +2566,13 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
// === Content below header === // === Content below header ===
// === First Row: Region / Channel Utilization and GPS === // === First Row: Region / Channel Utilization and Uptime ===
bool origBold = config.display.heading_bold; bool origBold = config.display.heading_bold;
config.display.heading_bold = false; config.display.heading_bold = false;
// Display Region and Channel Utilization // Display Region and Channel Utilization
config.display.heading_bold = false;
drawNodes(display, x + 1, compactFirstLine + 3, nodeStatus, -1, false, "online"); drawNodes(display, x + 1, compactFirstLine + 3, nodeStatus, -1, false, "online");
#if HAS_GPS
auto number_of_satellites = gpsStatus->getNumSatellites();
int gps_rightchar_offset = (SCREEN_WIDTH > 128) ? -51 : -46;
if (number_of_satellites < 10) {
gps_rightchar_offset += (SCREEN_WIDTH > 128) ? 8 : 6;
}
if (!gpsStatus || !gpsStatus->getIsConnected()) {
gps_rightchar_offset = (SCREEN_WIDTH > 128) ? -20 : 2;
}
if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
String displayLine = "";
if (config.position.fixed_position) {
gps_rightchar_offset = (SCREEN_WIDTH > 128) ? -80 : -50;
displayLine = "Fixed GPS";
} else {
gps_rightchar_offset = (SCREEN_WIDTH > 128) ? -58 : -38;
displayLine = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off";
}
display->drawString(SCREEN_WIDTH + gps_rightchar_offset, compactFirstLine, displayLine);
} else {
drawGPS(display, SCREEN_WIDTH + gps_rightchar_offset, compactFirstLine + 3, gpsStatus);
}
#endif
config.display.heading_bold = origBold;
// === Second Row: Uptime and Voltage ===
uint32_t uptime = millis() / 1000; uint32_t uptime = millis() / 1000;
char uptimeStr[6]; char uptimeStr[6];
uint32_t minutes = uptime / 60, hours = minutes / 60, days = hours / 24; uint32_t minutes = uptime / 60, hours = minutes / 60, days = hours / 24;
@ -2618,7 +2593,28 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
char uptimeFullStr[16]; char uptimeFullStr[16];
snprintf(uptimeFullStr, sizeof(uptimeFullStr), "Uptime: %s", uptimeStr); snprintf(uptimeFullStr, sizeof(uptimeFullStr), "Uptime: %s", uptimeStr);
display->drawString(x, compactSecondLine, uptimeFullStr); display->drawString(SCREEN_WIDTH - display->getStringWidth(uptimeFullStr), compactFirstLine, uptimeFullStr);
config.display.heading_bold = origBold;
// === Second Row: Satellites and Voltage ===
config.display.heading_bold = false;
#if HAS_GPS
auto number_of_satellites = gpsStatus->getNumSatellites();
if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
String 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";
}
display->drawString(0, compactSecondLine, displayLine);
} else {
drawGPS(display, 0, compactSecondLine + 3, gpsStatus);
}
#endif
char batStr[20]; char batStr[20];
if (powerStatus->getHasBattery()) { if (powerStatus->getHasBattery()) {
@ -2630,6 +2626,8 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("USB"), compactSecondLine, String("USB")); display->drawString(x + SCREEN_WIDTH - display->getStringWidth("USB"), compactSecondLine, String("USB"));
} }
config.display.heading_bold = origBold;
// === Third Row: LongName Centered === // === Third Row: LongName Centered ===
// Blank // Blank
@ -2799,30 +2797,22 @@ static void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiStat
#if HAS_GPS #if HAS_GPS
bool origBold = config.display.heading_bold; bool origBold = config.display.heading_bold;
config.display.heading_bold = false; config.display.heading_bold = false;
auto number_of_satellites = gpsStatus->getNumSatellites();
String Satelite_String = "Sat:";
display->drawString(0, compactFirstLine, Satelite_String);
String displayLine = "";
if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
if (config.position.fixed_position) { if (config.position.fixed_position) {
display->drawString(x, compactFirstLine, "Sat:"); displayLine = "Fixed GPS";
if (SCREEN_WIDTH > 128) {
drawGPS(display, x + 32, compactFirstLine + 3, gpsStatus);
} else { } else {
drawGPS(display, x + 23, compactFirstLine + 3, gpsStatus); displayLine = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off";
} }
} else if (!gpsStatus || !gpsStatus->getIsConnected()) { display->drawString(display->getStringWidth(Satelite_String) + 3, compactFirstLine, displayLine);
String displayLine =
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off";
display->drawString(x, compactFirstLine, "Sat:");
if (SCREEN_WIDTH > 128) {
display->drawString(x + 32, compactFirstLine, displayLine);
} else { } else {
display->drawString(x + 23, compactFirstLine, displayLine); drawGPS(display, display->getStringWidth(Satelite_String) + 3, compactFirstLine + 3, gpsStatus);
}
} else {
display->drawString(x, compactFirstLine, "Sat:");
if (SCREEN_WIDTH > 128) {
drawGPS(display, x + 32, compactFirstLine + 3, gpsStatus);
} else {
drawGPS(display, x + 23, compactFirstLine + 3, gpsStatus);
}
} }
config.display.heading_bold = origBold; config.display.heading_bold = origBold;
// === Update GeoCoord === // === Update GeoCoord ===
@ -2841,6 +2831,9 @@ static void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiStat
validHeading = !isnan(heading); validHeading = !isnan(heading);
} }
// If GPS is off, no need to display these parts
if (displayLine != "GPS off" && displayLine != "No GPS") {
// === Second Row: Altitude === // === Second Row: Altitude ===
String displayLine; String displayLine;
displayLine = "Alt: " + String(geoCoord.getAltitude()) + "m"; displayLine = "Alt: " + String(geoCoord.getAltitude()) + "m";
@ -2853,10 +2846,11 @@ static void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiStat
snprintf(latStr, sizeof(latStr), "Lat: %.5f", geoCoord.getLatitude() * 1e-7); snprintf(latStr, sizeof(latStr), "Lat: %.5f", geoCoord.getLatitude() * 1e-7);
display->drawString(x, compactThirdLine, latStr); display->drawString(x, compactThirdLine, latStr);
// === Fifth Row: Longitude === // === Fourth Row: Longitude ===
char lonStr[32]; char lonStr[32];
snprintf(lonStr, sizeof(lonStr), "Lon: %.5f", geoCoord.getLongitude() * 1e-7); snprintf(lonStr, sizeof(lonStr), "Lon: %.5f", geoCoord.getLongitude() * 1e-7);
display->drawString(x, compactFourthLine, lonStr); display->drawString(x, compactFourthLine, lonStr);
}
// === Draw Compass if heading is valid === // === Draw Compass if heading is valid ===
if (validHeading) { if (validHeading) {