loader info

This commit is contained in:
2026-08-02 20:22:50 +02:00
parent a88e50bf8b
commit 3e16e3dd34
4 changed files with 39 additions and 6 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ void display_init() {
lv_init();
lv_display_gfx = lv_display_create(Theme::SCREEN_W, Theme::SCREEN_H);
lv_display_set_color_format(lv_display_gfx, LV_COLOR_FORMAT_RGB565_SWAPPED);
lv_display_set_color_format(lv_display_gfx, LV_COLOR_FORMAT_RGB565);
lv_display_set_buffers(lv_display_gfx, lvgl_buf1, lvgl_buf2,
sizeof(lv_color_t) * LVGL_BUF_PIXELS,
LV_DISPLAY_RENDER_MODE_PARTIAL);
+5 -1
View File
@@ -152,10 +152,14 @@ void homeScreen_refresh(Screen &) {
updateWidgets();
}
void homeScreen_tick(Screen &) {
void homeScreen_tick(Screen &s) {
if (lastFetchMs == 0 || millis() - lastFetchMs >= REFRESH_INTERVAL_MS) {
s.showLoading(true);
lv_timer_handler();
doFetch();
updateWidgets();
s.showLoading(false);
lv_timer_handler();
}
}
+5 -1
View File
@@ -95,10 +95,14 @@ void mvgScreen_refresh(Screen &) {
buildList();
}
void mvgScreen_tick(Screen &) {
void mvgScreen_tick(Screen &s) {
if (lastFetchMs == 0 || millis() - lastFetchMs >= REFRESH_INTERVAL_MS) {
s.showLoading(true);
lv_timer_handler();
doFetch();
buildList();
s.showLoading(false);
lv_timer_handler();
}
}
+28 -3
View File
@@ -1,5 +1,6 @@
#pragma once
#include <lvgl.h>
#include <theme.h>
enum class ScreenId {
HOME,
@@ -14,13 +15,11 @@ enum class ScreenId {
// every loop iteration for periodic refresh checks.
struct Screen {
lv_obj_t *root = nullptr;
lv_obj_t *loadingLabel = nullptr;
bool created = false;
// Build the screen object tree (hidden). Called once at startup.
void (*create_fn)(Screen &) = nullptr;
// Re-fetch data and update widgets.
void (*refresh_fn)(Screen &) = nullptr;
// Per-loop tick: check refresh timers / inactivity.
void (*tick_fn)(Screen &) = nullptr;
void create() {
@@ -32,14 +31,40 @@ struct Screen {
lv_obj_set_style_pad_all(root, 0, 0);
lv_obj_clear_flag(root, LV_OBJ_FLAG_SCROLLABLE);
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;
}
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() {
if (!created) create();
lv_screen_load(root);
lv_indev_reset(NULL, root);
showLoading(true);
lv_timer_handler();
refresh();
showLoading(false);
lv_timer_handler();
}
void hide() {}