mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-06 23:09:56 +00:00
Moar
This commit is contained in:
parent
6e376aeea6
commit
3770e43d86
@ -102,8 +102,6 @@ static uint32_t alertBannerUntil = 0;
|
||||
|
||||
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
|
||||
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
||||
|
||||
@ -779,7 +777,7 @@ void Screen::getTimeAgoStr(uint32_t agoSecs, char *timeStr, uint8_t maxLength)
|
||||
else if (agoSecs < 120 * 60) // last 2 hrs
|
||||
snprintf(timeStr, maxLength, "%u minutes ago", agoSecs / 60);
|
||||
// Only show hours ago if it's been less than 6 months. Otherwise, we may have bad data.
|
||||
else if ((agoSecs / 60 / 60) < (hours_in_month * 6))
|
||||
else if ((agoSecs / 60 / 60) < (HOURS_IN_MONTH * 6))
|
||||
snprintf(timeStr, maxLength, "%u hours ago", agoSecs / 60 / 60);
|
||||
else
|
||||
snprintf(timeStr, maxLength, "unknown age");
|
||||
@ -1641,23 +1639,6 @@ void Screen::removeFunctionSymbol(std::string sym)
|
||||
setFastFramerate();
|
||||
}
|
||||
|
||||
std::string Screen::drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds)
|
||||
{
|
||||
std::string uptime;
|
||||
|
||||
if (days > (hours_in_month * 6))
|
||||
uptime = "?";
|
||||
else if (days >= 2)
|
||||
uptime = std::to_string(days) + "d";
|
||||
else if (hours >= 2)
|
||||
uptime = std::to_string(hours) + "h";
|
||||
else if (minutes >= 1)
|
||||
uptime = std::to_string(minutes) + "m";
|
||||
else
|
||||
uptime = std::to_string(seconds) + "s";
|
||||
return uptime;
|
||||
}
|
||||
|
||||
void Screen::handlePrint(const char *text)
|
||||
{
|
||||
// the string passed into us probably has a newline, but that would confuse the logging system
|
||||
|
@ -321,9 +321,6 @@ class Screen : public concurrency::OSThread
|
||||
}
|
||||
}
|
||||
|
||||
/// generates a very brief time delta display
|
||||
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
|
||||
static char customFontTableLookup(const uint8_t ch)
|
||||
{
|
||||
|
@ -296,7 +296,7 @@ void drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
||||
// hours %= 24;
|
||||
|
||||
// Show uptime as days, hours, minutes OR seconds
|
||||
std::string uptime = screen->drawTimeDelta(days, hours, minutes, seconds);
|
||||
std::string uptime = UIRenderer::drawTimeDelta(days, hours, minutes, seconds);
|
||||
|
||||
// Line 1 (Still)
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(uptime.c_str()), y, uptime.c_str());
|
||||
|
@ -124,26 +124,6 @@ bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int
|
||||
return validCached;
|
||||
}
|
||||
|
||||
// Forward declaration for drawTimeDelta - we need access to this Screen method
|
||||
// For now, we'll implement a local version
|
||||
std::string drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds)
|
||||
{
|
||||
const uint32_t hours_in_month = 730;
|
||||
std::string uptime;
|
||||
|
||||
if (days > (hours_in_month * 6))
|
||||
uptime = "?";
|
||||
else if (days >= 2)
|
||||
uptime = std::to_string(days) + "d";
|
||||
else if (hours >= 2)
|
||||
uptime = std::to_string(hours) + "h";
|
||||
else if (minutes >= 1)
|
||||
uptime = std::to_string(minutes) + "m";
|
||||
else
|
||||
uptime = std::to_string(seconds) + "s";
|
||||
return uptime;
|
||||
}
|
||||
|
||||
void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string &line, const Emote *emotes, int emoteCount)
|
||||
{
|
||||
int cursorX = x;
|
||||
@ -294,7 +274,8 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
sender);
|
||||
}
|
||||
} else {
|
||||
snprintf(headerStr, sizeof(headerStr), "%s ago from %s", drawTimeDelta(days, hours, minutes, seconds).c_str(), sender);
|
||||
snprintf(headerStr, sizeof(headerStr), "%s ago from %s", UIRenderer::drawTimeDelta(days, hours, minutes, seconds).c_str(),
|
||||
sender);
|
||||
}
|
||||
|
||||
#ifndef EXCLUDE_EMOJI
|
||||
|
@ -1223,6 +1223,23 @@ void drawNavigationBar(OLEDDisplay *display, OLEDDisplayUiState *state)
|
||||
display->setColor(WHITE);
|
||||
}
|
||||
|
||||
std::string drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds)
|
||||
{
|
||||
std::string uptime;
|
||||
|
||||
if (days > (HOURS_IN_MONTH * 6))
|
||||
uptime = "?";
|
||||
else if (days >= 2)
|
||||
uptime = std::to_string(days) + "d";
|
||||
else if (hours >= 2)
|
||||
uptime = std::to_string(hours) + "h";
|
||||
else if (minutes >= 1)
|
||||
uptime = std::to_string(minutes) + "m";
|
||||
else
|
||||
uptime = std::to_string(seconds) + "s";
|
||||
return uptime;
|
||||
}
|
||||
|
||||
} // namespace UIRenderer
|
||||
} // namespace graphics
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <OLEDDisplayUi.h>
|
||||
#include <string>
|
||||
|
||||
#define HOURS_IN_MONTH 730
|
||||
|
||||
// Forward declarations for status types
|
||||
namespace meshtastic
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user