From 3173b5fffef63eb77f3f3cd2cc7be2835fec5e2d Mon Sep 17 00:00:00 2001 From: "DESKTOP-PUHFO60\\dsx2016" Date: Sat, 17 Oct 2026 16:38:14 +0800 Subject: [PATCH] Keep header uptime on a single row above the gauge panels. Previous second-line up text sat under the opaque panels and got covered. Co-authored-by: Cursor --- README.md | 1 + src/main.cpp | 35 +++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7deb70c..2abc519 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,4 @@ git reset --hard v1.1-case-snaps | 2026-10-17 | 外壳 v1.1:外圆角 R3.5、四侧悬臂卡扣、定位柱、卡扣试打样件 | | 2026-10-17 | 打标签 `v1.1-case-snaps`(及分支 `keep/v1.1-case-snaps`)作为可回滚稳定版 | | 2026-10-17 | UI 重排:修文字压图表;表盘/底栏分区;动画与短按/长按交互 | +| 2026-10-17 | 顶栏改单行,避免 up 文案被表盘面板盖住 | diff --git a/src/main.cpp b/src/main.cpp index f71cee1..a290179 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,12 +30,12 @@ /* Layout grid — every region has exclusive space, no overlaps */ #define UI_M 6 #define UI_G 6 -#define UI_HDR_H 28 -#define UI_GAUGE_H 120 +#define UI_HDR_H 22 /* single-row header; must clear before gauges */ +#define UI_GAUGE_H 124 #define UI_GAUGE_W 151 #define UI_ARC 90 -#define UI_BOT_Y (UI_HDR_H + UI_G + UI_GAUGE_H + UI_G) /* 160 */ -#define UI_BOT_H (SCREEN_HEIGHT - UI_BOT_Y - UI_M) /* 74 */ +#define UI_BOT_Y (UI_HDR_H + UI_G + UI_GAUGE_H + UI_G) /* 158 */ +#define UI_BOT_H (SCREEN_HEIGHT - UI_BOT_Y - UI_M) /* 76 */ #define UI_BOT_W (SCREEN_WIDTH - 2 * UI_M) /* 308 */ #define UI_INFO_W 124 #define UI_CHART_W (UI_BOT_W - 12 - UI_INFO_W - UI_G) /* ~160 */ @@ -156,6 +156,7 @@ static int comfort_score(float t, float h) { static void show_hint(const char *text, uint32_t ms) { lv_label_set_text(lbl_hint, text); lv_obj_remove_flag(lbl_hint, LV_OBJ_FLAG_HIDDEN); + lv_obj_move_foreground(lbl_hint); hint_until_ms = millis() + ms; } @@ -281,10 +282,10 @@ static void create_ui(void) { lv_obj_set_style_bg_opa(scr, LV_OPA_COVER, 0); lv_obj_clear_flag(scr, LV_OBJ_FLAG_SCROLLABLE); - /* ---- header (exclusive 0..28) ---- */ + /* ---- header single row (0 .. UI_HDR_H), never under panels ---- */ lv_obj_t *title = lv_label_create(scr); lv_label_set_text(title, "CLIMATE"); - lv_obj_set_style_text_font(title, &lv_font_montserrat_16, 0); + lv_obj_set_style_text_font(title, &lv_font_montserrat_14, 0); lv_obj_set_style_text_color(title, COL_TEXT, 0); lv_obj_set_pos(title, UI_M, 4); @@ -292,11 +293,11 @@ static void create_ui(void) { lv_label_set_text(lbl_uptime, "up 00:00"); lv_obj_set_style_text_font(lbl_uptime, &lv_font_montserrat_12, 0); lv_obj_set_style_text_color(lbl_uptime, COL_MUTED, 0); - lv_obj_set_pos(lbl_uptime, UI_M, 22); + lv_obj_align_to(lbl_uptime, title, LV_ALIGN_OUT_RIGHT_MID, 8, 1); led_status = lv_led_create(scr); lv_obj_set_size(led_status, 9, 9); - lv_obj_align(led_status, LV_ALIGN_TOP_RIGHT, -UI_M, 8); + lv_obj_align(led_status, LV_ALIGN_TOP_RIGHT, -UI_M, 6); lv_led_set_color(led_status, COL_WARN); lv_led_on(led_status); @@ -304,17 +305,20 @@ static void create_ui(void) { lv_label_set_text(lbl_status, "INIT"); lv_obj_set_style_text_font(lbl_status, &lv_font_montserrat_12, 0); lv_obj_set_style_text_color(lbl_status, COL_MUTED, 0); - lv_obj_align(lbl_status, LV_ALIGN_TOP_RIGHT, -(UI_M + 16), 6); + lv_obj_align(lbl_status, LV_ALIGN_TOP_RIGHT, -(UI_M + 16), 4); lbl_hint = lv_label_create(scr); lv_label_set_text(lbl_hint, ""); lv_obj_set_style_text_font(lbl_hint, &lv_font_montserrat_12, 0); lv_obj_set_style_text_color(lbl_hint, COL_TEMP_WARM, 0); - lv_obj_align(lbl_hint, LV_ALIGN_TOP_MID, 0, 6); + lv_obj_set_style_bg_color(lbl_hint, COL_BG, 0); + lv_obj_set_style_bg_opa(lbl_hint, LV_OPA_COVER, 0); + lv_obj_set_style_pad_hor(lbl_hint, 6, 0); + lv_obj_align(lbl_hint, LV_ALIGN_TOP_MID, 0, 4); lv_obj_add_flag(lbl_hint, LV_OBJ_FLAG_HIDDEN); - /* ---- gauge panels ---- */ - const int gy = UI_HDR_H + UI_G; /* 34 */ + /* ---- gauge panels (start strictly below header) ---- */ + const int gy = UI_HDR_H + UI_G; /* 28 */ lv_obj_t *p_temp = make_panel(scr, UI_M, gy, UI_GAUGE_W, UI_GAUGE_H); lv_obj_t *t_cap = lv_label_create(p_temp); @@ -435,6 +439,13 @@ static void create_ui(void) { lv_obj_set_style_line_opa(chart, LV_OPA_40, LV_PART_MAIN); ser_temp = lv_chart_add_series(chart, COL_TEMP_WARM, LV_CHART_AXIS_PRIMARY_Y); ser_hum = lv_chart_add_series(chart, COL_HUM, LV_CHART_AXIS_SECONDARY_Y); + + /* Keep header above any later siblings if layout drifts */ + lv_obj_move_foreground(title); + lv_obj_move_foreground(lbl_uptime); + lv_obj_move_foreground(lbl_status); + lv_obj_move_foreground(led_status); + lv_obj_move_foreground(lbl_hint); } static void refresh_meta(void) {