Update Sys screen for new uptime, add label to Freq/Chan on LoRa

This commit is contained in:
Jason P 2025-06-03 21:16:11 -05:00
parent c847ae0509
commit fc00af4b55

View File

@ -428,9 +428,13 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
float freq = RadioLibInterface::instance->getFreq(); float freq = RadioLibInterface::instance->getFreq();
snprintf(freqStr, sizeof(freqStr), "%.3f", freq); snprintf(freqStr, sizeof(freqStr), "%.3f", freq);
if (config.lora.channel_num == 0) { if (config.lora.channel_num == 0) {
snprintf(frequencyslot, sizeof(frequencyslot), "Freq: %s", freqStr); snprintf(frequencyslot, sizeof(frequencyslot), "Freq: %smhz", freqStr);
} else { } else {
snprintf(frequencyslot, sizeof(frequencyslot), "Freq/Chan: %s (%d)", freqStr, config.lora.channel_num); if (SCREEN_WIDTH > 128) {
snprintf(frequencyslot, sizeof(frequencyslot), "Freq/Chan: %smhz (%d)", freqStr, config.lora.channel_num);
} else {
snprintf(frequencyslot, sizeof(frequencyslot), "Frq/Ch: %smhz (%d)", freqStr, config.lora.channel_num);
}
} }
size_t len = strlen(frequencyslot); size_t len = strlen(frequencyslot);
if (len >= 4 && strcmp(frequencyslot + len - 4, " (0)") == 0) { if (len >= 4 && strcmp(frequencyslot + len - 4, " (0)") == 0) {
@ -614,29 +618,21 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
if (SCREEN_HEIGHT > 64 || (SCREEN_HEIGHT <= 64 && line < 4)) { // Only show uptime if the screen can show it if (SCREEN_HEIGHT > 64 || (SCREEN_HEIGHT <= 64 && line < 4)) { // Only show uptime if the screen can show it
line += 1; line += 1;
char uptimeStr[32] = "";
uint32_t uptime = millis() / 1000; uint32_t uptime = millis() / 1000;
char uptimeStr[6]; uint32_t days = uptime / 86400;
uint32_t minutes = uptime / 60, hours = minutes / 60, days = hours / 24; uint32_t hours = (uptime % 86400) / 3600;
uint32_t mins = (uptime % 3600) / 60;
if (days > 365) { // Show as "Up: 2d 3h", "Up: 5h 14m", or "Up: 37m"
snprintf(uptimeStr, sizeof(uptimeStr), "?"); if (days)
} else { snprintf(uptimeStr, sizeof(uptimeStr), " Up: %ud %uh", days, hours);
snprintf(uptimeStr, sizeof(uptimeStr), "%u%c", else if (hours)
days ? days snprintf(uptimeStr, sizeof(uptimeStr), " Up: %uh %um", hours, mins);
: hours ? hours else
: minutes ? minutes snprintf(uptimeStr, sizeof(uptimeStr), " Uptime: %um", mins);
: (int)uptime, textWidth = display->getStringWidth(uptimeStr);
days ? 'd'
: hours ? 'h'
: minutes ? 'm'
: 's');
}
char uptimeFullStr[16];
snprintf(uptimeFullStr, sizeof(uptimeFullStr), "Uptime: %s", uptimeStr);
textWidth = display->getStringWidth(uptimeFullStr);
nameX = (SCREEN_WIDTH - textWidth) / 2; nameX = (SCREEN_WIDTH - textWidth) / 2;
display->drawString(nameX, yPositions[line], uptimeFullStr); display->drawString(nameX, yPositions[line], uptimeStr);
} }
} }
} // namespace DebugRenderer } // namespace DebugRenderer