From cb3a20feb80bc8edbd4d0e115d5424f7ff510cf3 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 2 Jun 2025 15:03:22 -0500 Subject: [PATCH] Add screen->isOverlayBannerShowing() --- src/graphics/Screen.h | 7 ++++++- src/graphics/draw/NotificationRenderer.cpp | 2 +- src/modules/CannedMessageModule.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 0175b7721..fee1dad9f 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -221,7 +221,7 @@ class Screen : public concurrency::OSThread OLEDDISPLAY_GEOMETRY geometry; 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 // 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); + bool isOverlayBannerShowing() + { + return strlen(alertBannerMessage) > 0 && (alertBannerUntil == 0 || millis() <= alertBannerUntil); + } + void startFirmwareUpdateScreen() { ScreenCmd cmd; diff --git a/src/graphics/draw/NotificationRenderer.cpp b/src/graphics/draw/NotificationRenderer.cpp index 1c5157abe..1b55008eb 100644 --- a/src/graphics/draw/NotificationRenderer.cpp +++ b/src/graphics/draw/NotificationRenderer.cpp @@ -78,7 +78,7 @@ void NotificationRenderer::drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUi void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) { // 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; // === Layout Configuration === diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 753967aff..b325fe617 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -720,7 +720,7 @@ bool CannedMessageModule::handleSystemCommandInput(const InputEvent *event) return false; // 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; }