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:
Lago
2026-04-03 15:41:26 +02:00
parent 6062083b5e
commit 44b6a89b57
3 changed files with 28 additions and 11 deletions
+5 -2
View File
@@ -36,8 +36,11 @@ build_flags =
-Wl,--wrap=esp_ota_mark_app_valid_cancel_rollback -Wl,--wrap=esp_ota_mark_app_valid_cancel_rollback
; Enable LVGL simple include ; Enable LVGL simple include
-DLV_CONF_INCLUDE_SIMPLE -DLV_CONF_INCLUDE_SIMPLE
; FTP server storage type: SD_MMC ; FTP server: must define BOTH network + storage with numeric values
-DDEFAULT_STORAGE_TYPE_ESP32=STORAGE_SD_MMC ; to prevent FtpServerKey.h from defaulting to FFAT
; NETWORK_ESP32=6, STORAGE_SD_MMC=10
-DDEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32=6
-DDEFAULT_STORAGE_TYPE_ESP32=10
; Suppress deprecation warnings ; Suppress deprecation warnings
-Wno-deprecated-declarations -Wno-deprecated-declarations
; Allow #warning without failing build ; Allow #warning without failing build
+1 -1
View File
@@ -16,7 +16,7 @@
*=========================*/ *=========================*/
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN #define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
#define LV_USE_STDLIB_STRING 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) #define LV_MEM_SIZE (48U * 1024U)
+22 -8
View File
@@ -187,11 +187,21 @@ void ui_init()
/* ────────────────────────────────────────────────────────────── */ /* ────────────────────────────────────────────────────────────── */
/* CLOCK AREA (y = 385 … 490) */ /* CLOCK AREA (y = 385 … 490) */
/* ────────────────────────────────────────────────────────────── */ /* ────────────────────────────────────────────────────────────── */
lbl_time = make_label(scr, &lv_font_montserrat_40, CLR_WHITE, lbl_time = lv_label_create(scr);
LV_ALIGN_TOP_MID, 0, 398, "--:--"); 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, lbl_date = lv_label_create(scr);
LV_ALIGN_TOP_MID, 0, 456, "--- --, ----"); 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) */ /* 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); lv_bar_set_value(bar_sd, pct, LV_ANIM_OFF);
float used_gb = used_mb / 1024.0f; /* Format with one decimal using integer math (LVGL builtin sprintf
float total_gb = total_mb / 1024.0f; may lack %f support) */
lv_label_set_text_fmt(lbl_sd_info, "%.1f / %.1f GB", uint32_t used_gb_i = (uint32_t)(used_mb / 1024);
(double)used_gb, (double)total_gb); 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); lv_label_set_text_fmt(lbl_sd_pct, "%d%%", pct);
/* bar turns red when storage > 90% */ /* bar turns red when storage > 90% */