From 69868c1b31521c4abefd5ab3f2c1546de9015e09 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 11 Nov 2025 22:44:50 +0000 Subject: [PATCH] Added a way to lock execution if the main screen fails to initialize --- src/UIScreen.cpp | 10 ++++++++-- src/UIScreen.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/UIScreen.cpp b/src/UIScreen.cpp index a5489ff..02365a8 100644 --- a/src/UIScreen.cpp +++ b/src/UIScreen.cpp @@ -4,12 +4,18 @@ #include "UIDimensions.h" Curses::Screen::Screen(Arduino_GFX *d, UIDimensions dims, UIDecorations decor) - : display(d), dims(dims), decor(decor) { + : display(d), dims(dims), decor(decor) {} + +void Curses::Screen::Setup() { // This should always return the first available component this->mainWindowID = WindowPool::Allocate(); if (this->mainWindowID != 0) { // Something wrong happened Serial2.print("Unexpected ID for main window: "); Serial2.println(this->mainWindowID); + for (;;) { + delay(1000); + Serial2.println("Program interrupted due to setup failure"); + } } -}; +} diff --git a/src/UIScreen.h b/src/UIScreen.h index 9734d2e..9f072af 100644 --- a/src/UIScreen.h +++ b/src/UIScreen.h @@ -16,6 +16,7 @@ public: int16_t mainWindowID; Screen(Arduino_GFX *d, UIDimensions dims, UIDecorations decor); + void Setup(); }; }; // namespace Curses