Add screen->isOverlayBannerShowing()

This commit is contained in:
Jonathan Bennett 2025-06-02 15:03:22 -05:00
parent 0f5413d113
commit cb3a20feb8
3 changed files with 8 additions and 3 deletions

View File

@ -221,7 +221,7 @@ class Screen : public concurrency::OSThread
OLEDDISPLAY_GEOMETRY geometry; OLEDDISPLAY_GEOMETRY geometry;
char alertBannerMessage[256] = {0}; char alertBannerMessage[256] = {0};
uint32_t alertBannerUntil = 0; uint32_t alertBannerUntil = 0; // 0 is a special case meaning forever
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier // Stores the last 4 of our hardware ID, to make finding the device for pairing easier
// FIXME: Needs refactoring and getMacAddr needs to be moved to a utility class // FIXME: Needs refactoring and getMacAddr needs to be moved to a utility class
@ -288,6 +288,11 @@ class Screen : public concurrency::OSThread
void showOverlayBanner(const char *message, uint32_t durationMs = 3000); void showOverlayBanner(const char *message, uint32_t durationMs = 3000);
bool isOverlayBannerShowing()
{
return strlen(alertBannerMessage) > 0 && (alertBannerUntil == 0 || millis() <= alertBannerUntil);
}
void startFirmwareUpdateScreen() void startFirmwareUpdateScreen()
{ {
ScreenCmd cmd; ScreenCmd cmd;

View File

@ -78,7 +78,7 @@ void NotificationRenderer::drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUi
void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
{ {
// Exit if no message is active or duration has passed // Exit if no message is active or duration has passed
if (strlen(screen->alertBannerMessage) == 0 || (screen->alertBannerUntil != 0 && millis() > screen->alertBannerUntil)) if (screen->isOverlayBannerShowing())
return; return;
// === Layout Configuration === // === Layout Configuration ===

View File

@ -720,7 +720,7 @@ bool CannedMessageModule::handleSystemCommandInput(const InputEvent *event)
return false; return false;
// Block ALL input if an alert banner is active // TODO: Make an accessor function // Block ALL input if an alert banner is active // TODO: Make an accessor function
if (strlen(screen->alertBannerMessage) > 0 && (screen->alertBannerUntil == 0 || millis() <= screen->alertBannerUntil)) { if (screen && screen->isOverlayBannerShowing()) {
return true; return true;
} }