From d418948a764a20c7c860bae337b555f2f56f7a05 Mon Sep 17 00:00:00 2001 From: Arthur Tazhitdinov Date: Thu, 22 Jan 2026 18:35:28 +0500 Subject: [PATCH] refactor: Update popup dimensions and styles; add sleep entry message --- lib/GfxRenderer/GfxRenderer.h | 2 ++ platformio.ini | 6 ++++- src/ScreenComponents.cpp | 25 +++++++++++---------- src/ScreenComponents.h | 6 ++--- src/activities/boot_sleep/SleepActivity.cpp | 3 +++ src/main.cpp | 3 +++ 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/GfxRenderer/GfxRenderer.h b/lib/GfxRenderer/GfxRenderer.h index 009309eb..dc0dfa03 100644 --- a/lib/GfxRenderer/GfxRenderer.h +++ b/lib/GfxRenderer/GfxRenderer.h @@ -55,6 +55,8 @@ class GfxRenderer { int getScreenWidth() const; int getScreenHeight() const; void displayBuffer(EInkDisplay::RefreshMode refreshMode = EInkDisplay::FAST_REFRESH) const; + // EXPERIMENTAL: Windowed update - display only a rectangular region -- not implemented + // void displayWindow(int x, int y, int width, int height) const; void invertScreen() const; void clearScreen(uint8_t color = 0xFF) const; diff --git a/platformio.ini b/platformio.ini index 7f42637d..faf4fd9a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,7 +27,11 @@ build_flags = # https://libexpat.github.io/doc/api/latest/#XML_GE -DXML_GE=0 -DXML_CONTEXT_BYTES=1024 - -std=c++2a + ; -std=c++2a + -std=gnu++2a + +build_unflags = -std=gnu++11 + # Enable UTF-8 long file names in SdFat -DUSE_UTF8_LONG_NAMES=1 diff --git a/src/ScreenComponents.cpp b/src/ScreenComponents.cpp index 083b77ee..042ff735 100644 --- a/src/ScreenComponents.cpp +++ b/src/ScreenComponents.cpp @@ -44,27 +44,29 @@ void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left, ScreenComponents::PopupLayout ScreenComponents::drawPopup(const GfxRenderer& renderer, const char* message, const int y, const int minWidth, const int minHeight) { + constexpr int margin = 15; const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD); - constexpr int margin = 16; - const int contentWidth = textWidth > minWidth ? textWidth : minWidth; - const int x = (renderer.getScreenWidth() - contentWidth - margin * 2) / 2; - const int w = contentWidth + margin * 2; + const int contentWidth = std::max(textWidth, minWidth); const int contentHeight = renderer.getLineHeight(UI_12_FONT_ID) + margin * 2; - const int h = contentHeight >= minHeight ? contentHeight : minHeight; + const int w = contentWidth + margin * 2 + 50; + // const int x = (renderer.getScreenWidth() - w) / 2; + const int x = renderer.getScreenWidth() - w - margin; + const int h = std::max(contentHeight, minHeight); renderer.fillRect(x - 2, y - 2, w + 4, h + 4, true); renderer.fillRect(x + 2, y + 2, w - 4, h - 4, false); const int textX = x + margin + (contentWidth - textWidth) / 2; - renderer.drawText(UI_12_FONT_ID, textX, y + margin, message, true, EpdFontFamily::BOLD); + // renderer.drawText(UI_12_FONT_ID, textX, y + margin + 4, message, true, EpdFontFamily::BOLD); + renderer.drawText(NOTOSANS_18_FONT_ID, textX, y + margin + 4, message, true, EpdFontFamily::BOLD); renderer.displayBuffer(); return {x, y, w, h}; } void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, const int progress) { - const int barWidth = POPUP_DEFAULT_MIN_WIDTH; - const int barHeight = POPUP_DEFAULT_BAR_HEIGHT; + constexpr int barWidth = POPUP_DEFAULT_MIN_WIDTH; + constexpr int barHeight = POPUP_DEFAULT_BAR_HEIGHT; const int barX = layout.x + (layout.width - barWidth) / 2; - const int barY = layout.y + layout.height - 16; // 16 pixels above bottom of popup + const int barY = layout.y + layout.height - 15; int fillWidth = barWidth * progress / 100; if (fillWidth < 0) { @@ -73,9 +75,8 @@ void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const Popu fillWidth = barWidth; } - if (fillWidth > 2) { - renderer.fillRect(barX + 1, barY + 1, fillWidth - 2, barHeight - 2, true); - } + renderer.fillRect(barX, barY, fillWidth, barHeight, true); + renderer.displayBuffer(EInkDisplay::FAST_REFRESH); } diff --git a/src/ScreenComponents.h b/src/ScreenComponents.h index 89299f56..fba62251 100644 --- a/src/ScreenComponents.h +++ b/src/ScreenComponents.h @@ -13,9 +13,9 @@ struct TabInfo { class ScreenComponents { public: - static constexpr int POPUP_DEFAULT_MIN_HEIGHT = 72; - static constexpr int POPUP_DEFAULT_BAR_HEIGHT = 6; static constexpr int POPUP_DEFAULT_MIN_WIDTH = 200; + static constexpr int POPUP_DEFAULT_MIN_HEIGHT = 72; + static constexpr int POPUP_DEFAULT_BAR_HEIGHT = 4; struct PopupLayout { int x; @@ -26,7 +26,7 @@ class ScreenComponents { static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true); - static PopupLayout drawPopup(const GfxRenderer& renderer, const char* message, int y = 117, + static PopupLayout drawPopup(const GfxRenderer& renderer, const char* message, int y = 125, int minWidth = POPUP_DEFAULT_MIN_WIDTH, int minHeight = POPUP_DEFAULT_MIN_HEIGHT); static void fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, int progress); diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index 69de73fd..7da55d8d 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -11,10 +11,13 @@ #include "fontIds.h" #include "images/CrossLarge.h" #include "util/StringUtils.h" +#include "ScreenComponents.h" void SleepActivity::onEnter() { Activity::onEnter(); + ScreenComponents::drawPopup(renderer, "Entering Sleep..."); + if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) { return renderBlankSleepScreen(); } diff --git a/src/main.cpp b/src/main.cpp index 3ccd9432..c0222e0d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -332,6 +332,9 @@ void setup() { setupDisplayAndFonts(); + exitActivity(); + enterNewActivity(new BootActivity(renderer, mappedInputManager)); + APP_STATE.loadFromFile(); RECENT_BOOKS.loadFromFile();