From def6c2063ac5dc172498cc11b002b6c77cedc8bf Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 19 Mar 2026 11:20:07 +0100 Subject: [PATCH] Dont freeze UI on calculation --- .../settings/SystemInformationActivity.cpp | 20 +- .../settings/SystemInformationActivity.h | 6 + src/network/html/HomePage.html | 293 +++++++++--------- 3 files changed, 179 insertions(+), 140 deletions(-) diff --git a/src/activities/settings/SystemInformationActivity.cpp b/src/activities/settings/SystemInformationActivity.cpp index 09aaa4e7..68d167f0 100644 --- a/src/activities/settings/SystemInformationActivity.cpp +++ b/src/activities/settings/SystemInformationActivity.cpp @@ -24,6 +24,7 @@ static std::string formatBytes(uint64_t bytes) { void SystemInformationActivity::onEnter() { Activity::onEnter(); + status_.reset(); requestUpdate(); } @@ -32,6 +33,13 @@ void SystemInformationActivity::onExit() { Activity::onExit(); } void SystemInformationActivity::loop() { if (mappedInput.wasPressed(MappedInputManager::Button::Back)) { finish(); + return; + } + // Collect status (includes the potentially slow SD FAT walk) outside of render() + // so the screen is shown with a "Reading..." placeholder first. + if (!status_.has_value()) { + status_ = SystemStatus::collect(); + requestUpdate(); } } @@ -45,8 +53,6 @@ void SystemInformationActivity::render(RenderLock&&) { GUI.drawHeader(renderer, Rect{0, metrics.topPadding, pageWidth, metrics.headerHeight}, tr(STR_SYSTEM_INFO), CROSSPOINT_VERSION); - const auto status = SystemStatus::collect(); - // Layout: label on the left, value right of the midpoint const int leftX = metrics.verticalSpacing * 3; const int valueX = pageWidth / 2; @@ -59,6 +65,16 @@ void SystemInformationActivity::render(RenderLock&&) { renderer.drawText(UI_10_FONT_ID, valueX, y, value.c_str()); }; + if (!status_.has_value()) { + // Stats not yet collected — show a placeholder so the screen updates immediately + drawRow(0, "Version", CROSSPOINT_VERSION); + drawRow(3, "SD card", "Reading..."); + renderer.displayBuffer(); + return; + } + + const auto& status = *status_; + // Device drawRow(0, "Version", status.version); drawRow(1, "Free heap", std::to_string(status.freeHeapBytes / 1024) + " KB"); diff --git a/src/activities/settings/SystemInformationActivity.h b/src/activities/settings/SystemInformationActivity.h index 4beab5af..d135dab5 100644 --- a/src/activities/settings/SystemInformationActivity.h +++ b/src/activities/settings/SystemInformationActivity.h @@ -1,5 +1,8 @@ #pragma once +#include + +#include "SystemStatus.h" #include "activities/Activity.h" class SystemInformationActivity final : public Activity { @@ -11,4 +14,7 @@ class SystemInformationActivity final : public Activity { void onExit() override; void loop() override; void render(RenderLock&&) override; + + private: + std::optional status_; }; diff --git a/src/network/html/HomePage.html b/src/network/html/HomePage.html index 79412c0f..27e7175c 100644 --- a/src/network/html/HomePage.html +++ b/src/network/html/HomePage.html @@ -1,148 +1,164 @@ - - - - CrossPoint Reader - - - -

📚 CrossPoint Reader

+ } - + body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, + Oxygen, Ubuntu, sans-serif; + max-width: 800px; + margin: 0 auto; + padding: 20px; + background-color: var(--bg); + color: var(--font-color); + } -
-

Device Status

-
- Version - -
-
- WiFi Status - Connected -
-
- IP Address - -
-
- Free Memory - -
-
- SD Card - -
-
+ h1 { + color: var(--title-color); + border-bottom: 2px solid var(--accent-color); + padding-bottom: 10px; + } -
-

- CrossPoint E-Reader • Open Source -

+ h2 { + color: var(--title-color); + margin-top: 0; + } + + .card { + background: var(--card-bg); + border-radius: 8px; + padding: 20px; + margin: 15px 0; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + } + + .info-row { + display: flex; + justify-content: space-between; + align-items: center; + padding: 8px 0; + border-bottom: 1px solid var(--border-color); + } + + .info-row:last-child { + border-bottom: none; + } + + .label { + font-weight: 600; + color: var(--label-color); + } + + .value { + color: var(--title-color); + } + + .status { + display: inline-block; + padding: 4px 12px; + border-radius: 12px; + background-color: #27ae60; + color: white; + font-size: 0.9em; + } + + .nav-links { + margin: 20px 0; + display: flex; + gap: 10px; + } + + .nav-links a { + padding: 10px 20px; + color: var(--font-color); + text-decoration: none; + border-radius: 4px; + } + + .nav-links a.active { + background-color: var(--accent-color); + color: white; + } + + .nav-links a:not(.active):hover { + background-color: var(--accent-hover-color); + color: white; + } + + + + +

📚 CrossPoint Reader

+ + + +
+

Device Status

+
+ Version + Loading...
+
+ WiFi Status + Connected +
+
+ IP Address + Loading... +
+
+ Free Memory + Loading... +
+
+ SD Card + Loading... +
+
+ +
+

+ CrossPoint E-Reader • Open Source +

+
- - + + + \ No newline at end of file