Merge branch 'master' into rsyslog-client

This commit is contained in:
Thomas Göttgens 2023-02-07 01:08:24 +01:00 committed by GitHub
commit 4ede8ab9de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 16 deletions

View File

@ -70,6 +70,8 @@ static char btPIN[16] = "888888";
uint32_t logo_timeout = 5000; // 4 seconds for EACH logo uint32_t logo_timeout = 5000; // 4 seconds for EACH logo
uint32_t hours_in_month = 730;
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function // This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C}; uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
@ -386,10 +388,11 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
uint32_t days = hours / 24; uint32_t days = hours / 24;
if (config.display.heading_bold) { if (config.display.heading_bold) {
display->drawStringf(1 + x, 0 + y, tempBuf, "%s ago from %s", screen->drawTimeDelta(days, hours, minutes, seconds), display->drawStringf(1 + x, 0 + y, tempBuf, "%s ago from %s",
screen->drawTimeDelta(days, hours, minutes, seconds).c_str(),
(node && node->has_user) ? node->user.short_name : "???"); (node && node->has_user) ? node->user.short_name : "???");
} }
display->drawStringf(0 + x, 0 + y, tempBuf, "%s ago from %s", screen->drawTimeDelta(days, hours, minutes, seconds), display->drawStringf(0 + x, 0 + y, tempBuf, "%s ago from %s", screen->drawTimeDelta(days, hours, minutes, seconds).c_str(),
(node && node->has_user) ? node->user.short_name : "???"); (node && node->has_user) ? node->user.short_name : "???");
display->setColor(WHITE); display->setColor(WHITE);
@ -794,9 +797,6 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
else if (agoSecs < 120 * 60) // last 2 hrs else if (agoSecs < 120 * 60) // last 2 hrs
snprintf(lastStr, sizeof(lastStr), "%u minutes ago", agoSecs / 60); snprintf(lastStr, sizeof(lastStr), "%u minutes ago", agoSecs / 60);
else { else {
uint32_t hours_in_month = 730;
// Only show hours ago if it's been less than 6 months. Otherwise, we may have bad // Only show hours ago if it's been less than 6 months. Otherwise, we may have bad
// data. // data.
if ((agoSecs / 60 / 60) < (hours_in_month * 6)) { if ((agoSecs / 60 / 60) < (hours_in_month * 6)) {
@ -1336,17 +1336,20 @@ void Screen::blink()
dispdev.setBrightness(brightness); dispdev.setBrightness(brightness);
} }
String Screen::drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds) std::string Screen::drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds)
{ {
String uptime; std::string uptime;
if (days >= 2)
uptime = String(days) + "d"; if (days > (hours_in_month * 6))
uptime = "?";
else if (days >= 2)
uptime = std::to_string(days) + "d";
else if (hours >= 2) else if (hours >= 2)
uptime = String(hours) + "h"; uptime = std::to_string(hours) + "h";
else if (minutes >= 1) else if (minutes >= 1)
uptime = String(minutes) + "m"; uptime = std::to_string(minutes) + "m";
else else
uptime = String(seconds) + "s"; uptime = std::to_string(seconds) + "s";
return uptime; return uptime;
} }
@ -1714,7 +1717,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
display->setColor(WHITE); display->setColor(WHITE);
// Show uptime as days, hours, minutes OR seconds // Show uptime as days, hours, minutes OR seconds
String uptime = screen->drawTimeDelta(days, hours, minutes, seconds); std::string uptime = screen->drawTimeDelta(days, hours, minutes, seconds);
uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice); uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice);
if (rtc_sec > 0) { if (rtc_sec > 0) {
@ -1729,12 +1732,12 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
int min = (hms % SEC_PER_HOUR) / SEC_PER_MIN; int min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
int sec = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN int sec = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
char timebuf[9]; char timebuf[10];
snprintf(timebuf, sizeof(timebuf), " %02d:%02d:%02d", hour, min, sec); snprintf(timebuf, sizeof(timebuf), " %02d:%02d:%02d", hour, min, sec);
uptime += timebuf; uptime += timebuf;
} }
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, uptime); display->drawString(x, y + FONT_HEIGHT_SMALL * 1, uptime.c_str());
// Display Channel Utilization // Display Channel Utilization
char chUtil[13]; char chUtil[13];

View File

@ -207,7 +207,7 @@ class Screen : public concurrency::OSThread
} }
/// generates a very brief time delta display /// generates a very brief time delta display
String drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds); std::string drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
/// Overrides the default utf8 character conversion, to replace empty space with question marks /// Overrides the default utf8 character conversion, to replace empty space with question marks
static char customFontTableLookup(const uint8_t ch) static char customFontTableLookup(const uint8_t ch)