fix: FTP storage backend, SD info display, time label alignment
- Fix FTP using FFAT instead of SD_MMC: define both NETWORK_TYPE (6) and STORAGE_TYPE (10) with numeric values to bypass FtpServerKey.h guard - Fix SD capacity showing 'f/f GB': use integer math instead of floats (LVGL builtin sprintf lacks %f support) - Fix time/date labels tilting 45°: set fixed width + LV_TEXT_ALIGN_CENTER - Switch LVGL sprintf to C stdlib for future float compatibility
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@
|
||||
*=========================*/
|
||||
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB
|
||||
|
||||
#define LV_MEM_SIZE (48U * 1024U)
|
||||
|
||||
|
||||
+22
-8
@@ -187,11 +187,21 @@ void ui_init()
|
||||
/* ────────────────────────────────────────────────────────────── */
|
||||
/* CLOCK AREA (y = 385 … 490) */
|
||||
/* ────────────────────────────────────────────────────────────── */
|
||||
lbl_time = make_label(scr, &lv_font_montserrat_40, CLR_WHITE,
|
||||
LV_ALIGN_TOP_MID, 0, 398, "--:--");
|
||||
lbl_time = lv_label_create(scr);
|
||||
lv_label_set_text(lbl_time, "--:--:--");
|
||||
lv_obj_set_style_text_font(lbl_time, &lv_font_montserrat_40, 0);
|
||||
lv_obj_set_style_text_color(lbl_time, lv_color_hex(CLR_WHITE), 0);
|
||||
lv_obj_set_width(lbl_time, SCR_W);
|
||||
lv_obj_set_style_text_align(lbl_time, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(lbl_time, LV_ALIGN_TOP_MID, 0, 398);
|
||||
|
||||
lbl_date = make_label(scr, &lv_font_montserrat_18, CLR_GRAY,
|
||||
LV_ALIGN_TOP_MID, 0, 456, "--- --, ----");
|
||||
lbl_date = lv_label_create(scr);
|
||||
lv_label_set_text(lbl_date, "--- --, ----");
|
||||
lv_obj_set_style_text_font(lbl_date, &lv_font_montserrat_18, 0);
|
||||
lv_obj_set_style_text_color(lbl_date, lv_color_hex(CLR_GRAY), 0);
|
||||
lv_obj_set_width(lbl_date, SCR_W);
|
||||
lv_obj_set_style_text_align(lbl_date, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(lbl_date, LV_ALIGN_TOP_MID, 0, 456);
|
||||
|
||||
/* ────────────────────────────────────────────────────────────── */
|
||||
/* ERROR OVERLAY (hidden by default) */
|
||||
@@ -281,10 +291,14 @@ void ui_set_sd(uint64_t used_mb, uint64_t total_mb)
|
||||
}
|
||||
lv_bar_set_value(bar_sd, pct, LV_ANIM_OFF);
|
||||
|
||||
float used_gb = used_mb / 1024.0f;
|
||||
float total_gb = total_mb / 1024.0f;
|
||||
lv_label_set_text_fmt(lbl_sd_info, "%.1f / %.1f GB",
|
||||
(double)used_gb, (double)total_gb);
|
||||
/* Format with one decimal using integer math (LVGL builtin sprintf
|
||||
may lack %f support) */
|
||||
uint32_t used_gb_i = (uint32_t)(used_mb / 1024);
|
||||
uint32_t used_gb_f = (uint32_t)((used_mb % 1024) * 10 / 1024);
|
||||
uint32_t total_gb_i = (uint32_t)(total_mb / 1024);
|
||||
uint32_t total_gb_f = (uint32_t)((total_mb % 1024) * 10 / 1024);
|
||||
lv_label_set_text_fmt(lbl_sd_info, "%lu.%lu / %lu.%lu GB",
|
||||
used_gb_i, used_gb_f, total_gb_i, total_gb_f);
|
||||
lv_label_set_text_fmt(lbl_sd_pct, "%d%%", pct);
|
||||
|
||||
/* bar turns red when storage > 90% */
|
||||
|
||||
Reference in New Issue
Block a user