mirror of
https://github.com/skoelle/wt32sc01-dashboard.git
synced 2026-09-18 01:40:24 +00:00
loading remove
This commit is contained in:
@@ -152,14 +152,10 @@ void homeScreen_refresh(Screen &) {
|
|||||||
updateWidgets();
|
updateWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void homeScreen_tick(Screen &s) {
|
void homeScreen_tick(Screen &) {
|
||||||
if (lastFetchMs == 0 || millis() - lastFetchMs >= REFRESH_INTERVAL_MS) {
|
if (lastFetchMs == 0 || millis() - lastFetchMs >= REFRESH_INTERVAL_MS) {
|
||||||
s.showLoading(true);
|
|
||||||
lv_timer_handler();
|
|
||||||
doFetch();
|
doFetch();
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
s.showLoading(false);
|
|
||||||
lv_timer_handler();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,14 +95,10 @@ void mvgScreen_refresh(Screen &) {
|
|||||||
buildList();
|
buildList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mvgScreen_tick(Screen &s) {
|
void mvgScreen_tick(Screen &) {
|
||||||
if (lastFetchMs == 0 || millis() - lastFetchMs >= REFRESH_INTERVAL_MS) {
|
if (lastFetchMs == 0 || millis() - lastFetchMs >= REFRESH_INTERVAL_MS) {
|
||||||
s.showLoading(true);
|
|
||||||
lv_timer_handler();
|
|
||||||
doFetch();
|
doFetch();
|
||||||
buildList();
|
buildList();
|
||||||
s.showLoading(false);
|
|
||||||
lv_timer_handler();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-28
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#include <theme.h>
|
|
||||||
|
|
||||||
enum class ScreenId {
|
enum class ScreenId {
|
||||||
HOME,
|
HOME,
|
||||||
@@ -15,11 +14,13 @@ enum class ScreenId {
|
|||||||
// every loop iteration for periodic refresh checks.
|
// every loop iteration for periodic refresh checks.
|
||||||
struct Screen {
|
struct Screen {
|
||||||
lv_obj_t *root = nullptr;
|
lv_obj_t *root = nullptr;
|
||||||
lv_obj_t *loadingLabel = nullptr;
|
|
||||||
bool created = false;
|
bool created = false;
|
||||||
|
|
||||||
|
// Build the screen object tree (hidden). Called once at startup.
|
||||||
void (*create_fn)(Screen &) = nullptr;
|
void (*create_fn)(Screen &) = nullptr;
|
||||||
|
// Re-fetch data and update widgets.
|
||||||
void (*refresh_fn)(Screen &) = nullptr;
|
void (*refresh_fn)(Screen &) = nullptr;
|
||||||
|
// Per-loop tick: check refresh timers / inactivity.
|
||||||
void (*tick_fn)(Screen &) = nullptr;
|
void (*tick_fn)(Screen &) = nullptr;
|
||||||
|
|
||||||
void create() {
|
void create() {
|
||||||
@@ -31,40 +32,14 @@ struct Screen {
|
|||||||
lv_obj_set_style_pad_all(root, 0, 0);
|
lv_obj_set_style_pad_all(root, 0, 0);
|
||||||
lv_obj_clear_flag(root, LV_OBJ_FLAG_SCROLLABLE);
|
lv_obj_clear_flag(root, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
create_fn(*this);
|
create_fn(*this);
|
||||||
|
|
||||||
loadingLabel = lv_label_create(root);
|
|
||||||
lv_label_set_text(loadingLabel, LV_SYMBOL_REFRESH " Lädt...");
|
|
||||||
lv_obj_set_style_text_color(loadingLabel, Theme::text(), 0);
|
|
||||||
lv_obj_set_style_bg_color(loadingLabel, Theme::bg(), 0);
|
|
||||||
lv_obj_set_style_bg_opa(loadingLabel, LV_OPA_COVER, 0);
|
|
||||||
lv_obj_set_style_radius(loadingLabel, 8, 0);
|
|
||||||
lv_obj_set_style_pad_all(loadingLabel, 8, 0);
|
|
||||||
lv_obj_set_align(loadingLabel, LV_ALIGN_BOTTOM_RIGHT);
|
|
||||||
lv_obj_align(loadingLabel, LV_ALIGN_BOTTOM_RIGHT, -12, -12);
|
|
||||||
lv_obj_add_flag(loadingLabel, LV_OBJ_FLAG_HIDDEN);
|
|
||||||
|
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showLoading(bool visible) {
|
|
||||||
if (!loadingLabel) return;
|
|
||||||
if (visible) {
|
|
||||||
lv_obj_clear_flag(loadingLabel, LV_OBJ_FLAG_HIDDEN);
|
|
||||||
lv_obj_move_foreground(loadingLabel);
|
|
||||||
} else {
|
|
||||||
lv_obj_add_flag(loadingLabel, LV_OBJ_FLAG_HIDDEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void show() {
|
void show() {
|
||||||
if (!created) create();
|
if (!created) create();
|
||||||
lv_screen_load(root);
|
lv_screen_load(root);
|
||||||
lv_indev_reset(NULL, root);
|
lv_indev_reset(NULL, root);
|
||||||
showLoading(true);
|
|
||||||
lv_timer_handler();
|
|
||||||
refresh();
|
refresh();
|
||||||
showLoading(false);
|
|
||||||
lv_timer_handler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hide() {}
|
void hide() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user