Просмотр исходного кода

修改部分UI,增加预加热页面UI

zhanghongyi 2 месяцев назад
Родитель
Сommit
1199628fb6

+ 24 - 0
LVGL8v3/logic/Logic_temperature.c

@@ -49,3 +49,27 @@ int8_t Logic_temperature_get_cpu(uint8_t ch)
 
     return (ch < LOGIC_TEMP_CPU_CH_COUNT) ? 0 : 1;
 }
+
+/**
+ * @brief  获取预加热传感器的温度值
+ * @note   占位假数据: 由序号生成固定偏移, 叠加与 Logic_temperature_get
+ *         一致的波动三角波模拟实时采集;
+ *         后续替换为真实传感器 (PLC/CPLD) 数据时删除波动部分即可。
+ * @param  idx : 序号 (0 ~ LOGIC_PREHEAT_TEMP_NUM-1); 0/1 = CPU0, 2/3 = CPU1
+ * @retval 温度值 (摄氏度), 越界返回 -127
+ */
+int8_t Logic_preheat_get(uint8_t idx)
+{
+    if (idx >= LOGIC_PREHEAT_TEMP_NUM)
+    {
+        return -127;
+    }
+
+    /* TODO: 接入真实预加热传感器数据 */
+    int16_t ph = (int16_t)((lv_tick_get() / 500) % 7);
+    if (ph > 3)
+    {
+        ph = 6 - ph;                       /* 0,1,2,3,2,1,0 往复 */
+    }
+    return (int8_t)(42 + idx * 5 + ph - 3);
+}

+ 11 - 0
LVGL8v3/logic/Logic_temperature.h

@@ -40,6 +40,17 @@ int8_t  Logic_temperature_get(uint8_t ch);
  */
 int8_t  Logic_temperature_get_cpu(uint8_t ch);
 
+/* 预加热温度 (占位假数据) */
+#define LOGIC_PREHEAT_TEMP_NUM   4       /* 预加热温度数量 */
+
+/**
+ * @brief  获取预加热传感器的温度值
+ * @note   占位假数据, 后续替换为真实传感器 (PLC/CPLD) 数据
+ * @param  idx : 序号 (0 ~ LOGIC_PREHEAT_TEMP_NUM-1); 0/1 = CPU0, 2/3 = CPU1
+ * @retval 温度值 (摄氏度), 越界返回 -127
+ */
+int8_t  Logic_preheat_get(uint8_t idx);
+
 #ifdef __cplusplus
 }
 #endif

+ 33 - 11
LVGL8v3/ui/Ui.c

@@ -14,6 +14,7 @@
 #include "Ui_temperature.h"
 #include "Ui_status.h"
 #include "Ui_temp_setting.h"
+#include "Ui_preheat.h"
 
 /*----------------------------- 布局尺寸 ------------------------------*/
 #define UI_STATUS_BAR_H     40          /* 顶部状态栏高度 */
@@ -37,19 +38,13 @@ typedef enum
 static lv_obj_t * s_status_dot   = NULL;   /* 状态指示灯 (圆点) */
 static lv_obj_t * s_status_label = NULL;   /* 状态文字 ("Ready"/"Not Ready") */
 static lv_obj_t * s_status_badge = NULL;   /* 就绪徽章 (圆角底) */
+static lv_obj_t * s_status_bar   = NULL;   /* 顶部状态栏容器 */
+static lv_obj_t * s_menu         = NULL;   /* 左侧菜单栏容器 */
 static lv_obj_t * s_content      = NULL;   /* 右侧内容区容器 */
 static lv_obj_t * s_page         = NULL;   /* 页面容器: 页面内容唯一父容器 */
 static ui_ready_state_t s_ready  = UI_READY_NOT;
 
 /*----------------------------- 菜单项 ------------------------------*/
-enum
-{
-    UI_MENU_TEMPERATURE = 0,
-    UI_MENU_STATUS,
-    UI_MENU_TEMP_SETTING,
-    UI_MENU_MAX
-};
-
 static const char * s_menu_text[UI_MENU_MAX] =
 {
     "Temperature",
@@ -74,6 +69,7 @@ static void ui_build_status_bar(lv_obj_t * scr)
     lv_obj_t * bar = lv_obj_create(scr);
     lv_obj_set_size(bar, lv_pct(100), UI_STATUS_BAR_H);
     lv_obj_set_pos(bar, 0, 0);
+    s_status_bar = bar;
     Ui_theme_clear_visuals(bar);
     lv_obj_set_style_radius(bar, 0, LV_STATE_DEFAULT);
     lv_obj_set_style_bg_color(bar, UI_CLR_STATUS_BAR, LV_STATE_DEFAULT);
@@ -164,7 +160,7 @@ static void ui_menu_refresh_active(void)
     }
 }
 
-static void ui_build_page(uint8_t menu_id)
+void Ui_build_page(uint8_t menu_id)
 {
     s_menu_active = menu_id;
     ui_menu_refresh_active();
@@ -172,7 +168,6 @@ static void ui_build_page(uint8_t menu_id)
     /* 防御: 清除输入设备对旧页面内容的按压引用, 避免删除后抬手产生悬空点击 */
     lv_indev_reset(NULL, NULL);
     lv_obj_clean(s_page);
-
     switch (menu_id)
     {
     case UI_MENU_TEMPERATURE:
@@ -194,7 +189,7 @@ static void ui_build_page(uint8_t menu_id)
 static void ui_menu_click_cb(lv_event_t * e)
 {
     uint32_t menu_id = (uint32_t)(uintptr_t)lv_event_get_user_data(e);
-    ui_build_page((uint8_t)menu_id);
+    Ui_build_page((uint8_t)menu_id);
 }
 
 static void ui_build_menu(lv_obj_t * scr)
@@ -205,6 +200,7 @@ static void ui_build_menu(lv_obj_t * scr)
     lv_obj_t * menu = lv_obj_create(scr);
     lv_obj_set_size(menu, UI_MENU_W, menu_h);
     lv_obj_set_pos(menu, 0, UI_STATUS_BAR_H);
+    s_menu = menu;
     Ui_theme_clear_visuals(menu);
     lv_obj_set_style_radius(menu, 0, LV_STATE_DEFAULT);
     lv_obj_set_style_bg_color(menu, UI_CLR_MENU, LV_STATE_DEFAULT);
@@ -296,3 +292,29 @@ void Ui_set_ready(bool ready)
     s_ready = ready ? UI_READY_READY : UI_READY_NOT;
     ui_refresh_ready();
 }
+
+void Ui_frame_set_visible(bool visible)
+{
+    lv_obj_t * frame[3];
+    frame[0] = s_status_bar;
+    frame[1] = s_menu;
+    frame[2] = s_content;
+
+    uint8_t i;
+    for (i = 0; i < 3; i++)
+    {
+        if (frame[i] == NULL)
+        {
+            continue;
+        }
+        if (visible)
+        {
+            lv_obj_clear_flag(frame[i], LV_OBJ_FLAG_HIDDEN);
+        }
+        else
+        {
+            lv_obj_add_flag(frame[i], LV_OBJ_FLAG_HIDDEN);
+        }
+    }
+    lv_obj_invalidate(lv_scr_act());
+}

+ 265 - 0
LVGL8v3/ui/Ui_preheat.c

@@ -0,0 +1,265 @@
+/**
+  ******************************************************************************
+  * @file    Ui_preheat.c
+  * @brief   预加热全屏页面 (UI 页面层)
+  *
+  * @note    点击"开始预热"确认框的 Yes 后进入: 全屏不透明覆盖, 隐藏状态栏/
+  *          菜单/内容区; 左 3/4 为 CPU0 / CPU1 两张温度卡片 (各 2 路),
+  *          右 1/4 为加热动画 + 已加热时长; 底部红色 cancel 返回温度设置页。
+  ******************************************************************************
+  */
+#include <stdio.h>
+#include "Ui.h"
+#include "Ui_preheat.h"
+#include "Ui_temp_setting.h"
+#include "Ui_theme.h"
+#include "Logic_temperature.h"
+
+/*-------------------------------- 布局 ---------------------------------*/
+#define UI_PRE_W               (LV_HOR_RES)                       /* 全屏宽 */
+#define UI_PRE_H               (LV_VER_RES)                       /* 全屏高 */
+#define UI_PRE_TEMPS_W         (LV_HOR_RES * 3 / 4)               /* 左 3/4 */
+
+/* 温度卡片 (上下两张: CPU0 / CPU1) */
+#define UI_PRE_CARD_X          16
+#define UI_PRE_CARD_Y0         56
+#define UI_PRE_CARD_GAP        12
+#define UI_PRE_CARD_W          (UI_PRE_TEMPS_W - 32)
+#define UI_PRE_CARD_H          150
+
+/* 卡片内行布局 */
+#define UI_PRE_ROW_Y0          46
+#define UI_PRE_ROW_GAP         52
+#define UI_PRE_ROW_LINE_Y      (UI_PRE_ROW_Y0 + UI_PRE_ROW_GAP - 18) /* 行间分隔线 */
+
+/* 右 1/4 加热动画面板 (与卡片同高) */
+#define UI_PRE_ANIM_X          (UI_PRE_TEMPS_W + 16)
+#define UI_PRE_ANIM_W          (LV_HOR_RES - UI_PRE_ANIM_X - 16)
+#define UI_PRE_ANIM_H          (UI_PRE_CARD_H * 2 + UI_PRE_CARD_GAP)
+
+/* 底部 cancel 按钮 */
+#define UI_PRE_CANCEL_W        200
+#define UI_PRE_CANCEL_H        48
+
+/* 顶部目标值 chip */
+#define UI_PRE_TARGET_W        180
+#define UI_PRE_TARGET_H        34
+
+/* 实时刷新周期 (ms) */
+#define UI_PRE_REFRESH_MS      500
+
+/*-------------------------------- 句柄 ---------------------------------*/
+static lv_obj_t    * s_pre_root = NULL;                  /* 全屏页面根 */
+static lv_timer_t  * s_pre_timer = NULL;                 /* 刷新定时器 */
+static lv_obj_t    * s_pre_value[LOGIC_PREHEAT_TEMP_NUM];/* 4 路温度值 */
+static char          s_pre_buf[LOGIC_PREHEAT_TEMP_NUM][12];
+
+/*----------------------------- 静态函数 ------------------------------*/
+
+/* 刷新 4 路温度数值 */
+static void ui_preheat_refresh(void)
+{
+    uint8_t i;
+    for (i = 0; i < LOGIC_PREHEAT_TEMP_NUM; i++)
+    {
+        int8_t t = Logic_preheat_get(i);
+        snprintf(s_pre_buf[i], sizeof(s_pre_buf[i]), "%d\xC2\xB0"
+                 "C", (int)t);
+        lv_label_set_text_static(s_pre_value[i], s_pre_buf[i]);
+    }
+}
+
+/* 刷新定时器回调 */
+static void ui_preheat_timer_cb(lv_timer_t * t)
+{
+    (void)t;
+    ui_preheat_refresh();
+}
+
+/* 页面销毁: 释放定时器, 防止悬挂指针 */
+static void ui_preheat_delete_cb(lv_event_t * e)
+{
+    (void)e;
+    if (s_pre_timer != NULL)
+    {
+        lv_timer_del(s_pre_timer);
+        s_pre_timer = NULL;
+    }
+    s_pre_root = NULL;
+}
+
+/* cancel 按钮: 必须在按钮范围内抬手才退出 (手指移出后抬起不生效) */
+static void ui_preheat_cancel_cb(lv_event_t * e)
+{
+    lv_obj_t * btn = lv_event_get_target(e);
+    lv_indev_t * indev = lv_indev_get_act();
+    if (indev != NULL)
+    {
+        lv_point_t pt;
+        lv_indev_get_point(indev, &pt);
+        if (!lv_obj_hit_test(btn, &pt))
+        {
+            return;                    /* 手指已移出按钮范围, 不触发 */
+        }
+    }
+    if (s_pre_root != NULL)
+    {
+        lv_obj_del(s_pre_root);
+        s_pre_root = NULL;
+    }
+    Ui_frame_set_visible(true);
+    Ui_build_page((uint8_t)UI_MENU_TEMP_SETTING);
+}
+
+/* 构建一张温度卡片 (CPU0/CPU1, 各含 2 行温度) */
+static void ui_preheat_build_card(lv_obj_t * root, const char * cpu_name,
+                                  uint8_t start_idx, lv_coord_t y)
+{
+    lv_obj_t * card = lv_obj_create(root);
+    lv_obj_set_pos(card, UI_PRE_CARD_X, y);
+    lv_obj_set_size(card, UI_PRE_CARD_W, UI_PRE_CARD_H);
+    Ui_theme_style_panel(card);
+
+    /* 卡片头: 强调色竖条 + CPU 名称 */
+    lv_obj_t * tick = lv_obj_create(card);
+    lv_obj_set_size(tick, 4, 22);
+    lv_obj_set_pos(tick, 14, 12);
+    Ui_theme_clear_visuals(tick);
+    lv_obj_set_style_radius(tick, 2, LV_STATE_DEFAULT);
+    lv_obj_set_style_bg_color(tick, UI_CLR_ACCENT, LV_STATE_DEFAULT);
+    lv_obj_set_style_bg_opa(tick, LV_OPA_COVER, LV_STATE_DEFAULT);
+
+    lv_obj_t * name = lv_label_create(card);
+    lv_label_set_text(name, cpu_name);
+    lv_obj_set_pos(name, 28, 10);
+    lv_obj_set_style_text_font(name, &lv_font_montserrat_20, LV_STATE_DEFAULT);
+    lv_obj_set_style_text_color(name, UI_CLR_TEXT, LV_STATE_DEFAULT);
+
+    /* 2 行温度 */
+    uint8_t r;
+    for (r = 0; r < 2; r++)
+    {
+        uint8_t   idx = (uint8_t)(start_idx + r);
+        lv_coord_t ry  = UI_PRE_ROW_Y0 + r * UI_PRE_ROW_GAP;
+
+        /* 行标签圆点 + "CHx" */
+        lv_obj_t * dot = lv_obj_create(card);
+        lv_obj_set_size(dot, 14, 14);
+        lv_obj_set_pos(dot, 14, ry + 7);
+        Ui_theme_clear_visuals(dot);
+        lv_obj_set_style_radius(dot, LV_RADIUS_CIRCLE, LV_STATE_DEFAULT);
+        lv_obj_set_style_bg_color(dot, UI_CLR_ACCENT, LV_STATE_DEFAULT);
+        lv_obj_set_style_bg_opa(dot, LV_OPA_COVER, LV_STATE_DEFAULT);
+
+        lv_obj_t * tag = lv_label_create(card);
+        char tag_txt[8];
+        snprintf(tag_txt, sizeof(tag_txt), "CH%d", (int)(r + 1));
+        lv_label_set_text(tag, tag_txt);
+        lv_obj_set_pos(tag, 38, ry);
+        lv_obj_set_style_text_font(tag, &lv_font_montserrat_16, LV_STATE_DEFAULT);
+        lv_obj_set_style_text_color(tag, UI_CLR_TEXT_DIM, LV_STATE_DEFAULT);
+
+        /* 温度值 (右对齐, 含单位) */
+        lv_obj_t * v = lv_label_create(card);
+        lv_obj_set_style_text_font(v, &lv_font_montserrat_24, LV_STATE_DEFAULT);
+        lv_obj_set_style_text_color(v, UI_CLR_ACCENT, LV_STATE_DEFAULT);
+        lv_obj_align(v, LV_ALIGN_TOP_RIGHT, -16, ry);
+        s_pre_value[idx] = v;
+    }
+
+    /* 行间分隔线 */
+    lv_obj_t * line = lv_obj_create(card);
+    lv_obj_set_pos(line, 16, UI_PRE_ROW_LINE_Y);
+    lv_obj_set_size(line, UI_PRE_CARD_W - 32, 1);
+    Ui_theme_clear_visuals(line);
+    lv_obj_set_style_bg_color(line, UI_CLR_LINE, LV_STATE_DEFAULT);
+    lv_obj_set_style_bg_opa(line, LV_OPA_COVER, LV_STATE_DEFAULT);
+}
+
+/*----------------------------- 全局函数 ------------------------------*/
+
+/**
+ * @brief  进入预加热页面 (全屏不透明覆盖主界面)
+ */
+void Ui_preheat_enter(void)
+{
+    if (s_pre_root != NULL)
+    {
+        return;                          /* 已存在, 防重复进入 */
+    }
+
+    lv_obj_t * root = lv_obj_create(lv_scr_act());
+    lv_obj_set_size(root, UI_PRE_W, UI_PRE_H);
+    lv_obj_set_pos(root, 0, 0);
+    Ui_theme_clear_visuals(root);
+    lv_obj_set_style_bg_color(root, UI_CLR_BG, LV_STATE_DEFAULT);
+    lv_obj_set_style_bg_opa(root, LV_OPA_COVER, LV_STATE_DEFAULT);
+    lv_obj_add_event_cb(root, ui_preheat_delete_cb, LV_EVENT_DELETE, NULL);
+    s_pre_root = root;
+
+    /* 隐藏主框架: 预加热打开期间仅预加热参与渲染 */
+    Ui_frame_set_visible(false);
+
+    /* 左上标题 */
+    Ui_theme_add_title(root, "Preheating", 10);
+
+    /* 右上: 目标温度 chip */
+    int16_t target = Ui_temp_setting_get_target();
+    lv_obj_t * target_chip = lv_obj_create(root);
+    lv_obj_set_size(target_chip, UI_PRE_TARGET_W, UI_PRE_TARGET_H);
+    lv_obj_align(target_chip, LV_ALIGN_TOP_RIGHT, -16, 10);
+    Ui_theme_style_chip(target_chip);
+    lv_obj_t * target_key = lv_label_create(target_chip);
+    lv_label_set_text(target_key, "Target");
+    lv_obj_set_style_text_font(target_key, &lv_font_montserrat_16, LV_STATE_DEFAULT);
+    lv_obj_set_style_text_color(target_key, UI_CLR_TEXT_DIM, LV_STATE_DEFAULT);
+    lv_obj_align(target_key, LV_ALIGN_LEFT_MID, 14, 0);
+    lv_obj_t * target_val = lv_label_create(target_chip);
+    lv_label_set_text_fmt(target_val, "%d\xC2\xB0"
+                          "C", (int)target);
+    lv_obj_set_style_text_font(target_val, &lv_font_montserrat_20, LV_STATE_DEFAULT);
+    lv_obj_set_style_text_color(target_val, UI_CLR_ACCENT, LV_STATE_DEFAULT);
+    lv_obj_align_to(target_val, target_key, LV_ALIGN_OUT_RIGHT_MID, 8, 0);
+
+    /* 左 3/4: 两张温度卡片 */
+    ui_preheat_build_card(root, "CPU0", 0, UI_PRE_CARD_Y0);
+    ui_preheat_build_card(root, "CPU1", 2, UI_PRE_CARD_Y0 + UI_PRE_CARD_H + UI_PRE_CARD_GAP);
+
+    /* 底部红色 cancel 按钮 (整屏水平居中) */
+    lv_obj_t * cancel = lv_btn_create(root);
+    lv_obj_set_size(cancel, UI_PRE_CANCEL_W, UI_PRE_CANCEL_H);
+    lv_obj_align(cancel, LV_ALIGN_BOTTOM_MID, 0, -16);
+    Ui_theme_style_btn_danger(cancel);
+    lv_obj_add_event_cb(cancel, ui_preheat_cancel_cb, LV_EVENT_RELEASED, NULL);
+    lv_obj_t * cl = lv_label_create(cancel);
+    lv_label_set_text(cl, "cancel");
+    lv_obj_set_style_text_font(cl, &lv_font_montserrat_20, LV_STATE_DEFAULT);
+    lv_obj_set_style_text_color(cl, UI_CLR_ERR, LV_STATE_DEFAULT);
+    lv_obj_center(cl);
+
+    /* 右 1/4: 加热动画面板 (标题 + spinner) */
+    lv_obj_t * panel = lv_obj_create(root);
+    lv_obj_set_pos(panel, UI_PRE_ANIM_X, UI_PRE_CARD_Y0);
+    lv_obj_set_size(panel, UI_PRE_ANIM_W, UI_PRE_ANIM_H);
+    Ui_theme_style_panel(panel);
+
+    lv_obj_t * head = lv_label_create(panel);
+    lv_label_set_text(head, "Heating...");
+    lv_obj_set_style_text_font(head, &lv_font_montserrat_20, LV_STATE_DEFAULT);
+    lv_obj_set_style_text_color(head, UI_CLR_TEXT, LV_STATE_DEFAULT);
+    lv_obj_align(head, LV_ALIGN_TOP_MID, 0, 24);
+
+    lv_obj_t * spin = lv_spinner_create(panel, 1000, 70);
+    lv_obj_set_size(spin, 120, 120);
+    lv_obj_set_style_arc_width(spin, 8, LV_PART_MAIN | LV_STATE_DEFAULT);
+    lv_obj_set_style_arc_color(spin, UI_CLR_PANEL_HI, LV_PART_MAIN | LV_STATE_DEFAULT);
+    lv_obj_set_style_arc_width(spin, 8, LV_PART_INDICATOR | LV_STATE_DEFAULT);
+    lv_obj_set_style_arc_color(spin, UI_CLR_ACCENT, LV_PART_INDICATOR | LV_STATE_DEFAULT);
+    lv_obj_align(spin, LV_ALIGN_CENTER, 0, 0);
+
+    ui_preheat_refresh();
+
+    /* 启动实时刷新定时器 */
+    s_pre_timer = lv_timer_create(ui_preheat_timer_cb, UI_PRE_REFRESH_MS, NULL);
+    lv_timer_set_repeat_count(s_pre_timer, -1);
+}

+ 25 - 0
LVGL8v3/ui/Ui_preheat.h

@@ -0,0 +1,25 @@
+/**
+  ******************************************************************************
+  * @file    Ui_preheat.h
+  * @brief   预加热全屏页面 (UI 页面层)
+  ******************************************************************************
+  */
+#ifndef __UI_PREHEAT_H
+#define __UI_PREHEAT_H
+
+#include "lvgl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief  进入预加热页面 (全屏覆盖, 左 3/4 温度 + 右 1/4 加热动画)
+ */
+void Ui_preheat_enter(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UI_PREHEAT_H */

+ 16 - 2
LVGL8v3/ui/Ui_temp_setting.c

@@ -7,13 +7,14 @@
   *          1. 数值输入框点击弹出数字键盘直接输入;
   *          2. "-"/"+" 按钮步进调节 (长按自动加速重复, 每次新按下周期复位)。
   *          Apply 应用设置并弹出"保存成功"弹窗 (点击 OK 或弹窗外区域关闭);
-  *          Start preheating 弹窗确认预热 (Yes/No 都关闭返回, 后期接入控制逻辑)。
+  *          Start preheating 弹窗确认预热 (Yes 进入预加热页面, No 关闭返回)。
   ******************************************************************************
   */
 #include <stdio.h>
 #include <stdlib.h>
 #include "Ui_temp_setting.h"
 #include "Ui.h"
+#include "Ui_preheat.h"
 #include "Ui_theme.h"
 
 /* 目标温度范围 */
@@ -295,7 +296,11 @@ static void ui_tset_msgbox_cb(lv_event_t * e)
     lv_obj_t * mbox = lv_event_get_current_target(e);
     if (lv_msgbox_get_active_btn(mbox) == 0)
     {
-        /* Yes: 启动预热 (TODO: 接入逻辑层/控制层) */
+        /* Yes: 进入预加热页面 */
+        lv_msgbox_close(mbox);
+        s_msgbox = NULL;
+        Ui_preheat_enter();
+        return;
     }
     lv_msgbox_close(mbox);
     s_msgbox = NULL;
@@ -493,3 +498,12 @@ void Ui_temp_setting_create(lv_obj_t * parent)
 
     ui_tset_refresh();
 }
+
+/**
+ * @brief  获取当前目标温度设定值
+ * @retval 目标温度 (摄氏度, 整数)
+ */
+int16_t Ui_temp_setting_get_target(void)
+{
+    return s_target;
+}

+ 6 - 0
LVGL8v3/ui/Ui_temp_setting.h

@@ -14,6 +14,12 @@ extern "C" {
  */
 void Ui_temp_setting_create(lv_obj_t * parent);
 
+/**
+ * @brief  获取当前目标温度设定值
+ * @retval 目标温度 (摄氏度, 整数)
+ */
+int16_t Ui_temp_setting_get_target(void);
+
 #ifdef __cplusplus
 }
 #endif

+ 5 - 4
LVGL8v3/ui/Ui_temperature.c

@@ -39,7 +39,7 @@
 
 /* 数据区行列位置 (相对数据卡片) */
 #define UI_TEMP_SW_X1           18
-#define UI_TEMP_SW_X2           248
+#define UI_TEMP_SW_X2           220
 #define UI_TEMP_SW_Y_BASE       50
 #define UI_TEMP_SW_H            100
 
@@ -63,7 +63,7 @@ static lv_obj_t * s_temp_box    = NULL;            /* 通道面板容器 */
 static void ui_temp_build_panel(lv_obj_t * box, uint8_t start);
 
 /* 数值标签的静态缓冲区 (lv_label_set_text_static 不重新分配内存) */
-static char s_value_buf[UI_TEMP_PAGE_NUM][8];
+static char s_value_buf[UI_TEMP_PAGE_NUM][12];
 
 #define UI_TEMP_PAGE_STEP       6       /* 翻页步长: 每页 6 个通道 */
 #define UI_TEMP_PAGE_MAX        (LOGIC_TEMP_TOTAL_CH - UI_TEMP_PAGE_NUM)   /* 18 = 末页起始通道 */
@@ -84,7 +84,8 @@ static void ui_temp_refresh(void)
         uint8_t ch = s_page_start + i;
         int8_t  t  = Logic_temperature_get(ch);
 
-        snprintf(s_value_buf[i], sizeof(s_value_buf[i]), "%d", (int)t);
+        snprintf(s_value_buf[i], sizeof(s_value_buf[i]), "%d\xC2\xB0"
+                 "C", (int)t);
         lv_label_set_text_static(s_temp_value[i], s_value_buf[i]);
         lv_obj_set_style_bg_color(s_temp_swatch[i], ui_temp_ch_color(ch), LV_STATE_DEFAULT);
     }
@@ -213,7 +214,7 @@ static void ui_temp_build_panel(lv_obj_t * box, uint8_t start)
 
             /* 动态数值 (实时刷新) */
             lv_obj_t * v = lv_label_create(box);
-            lv_obj_set_style_text_font(v, &lv_font_montserrat_24, LV_STATE_DEFAULT);
+            lv_obj_set_style_text_font(v, &lv_font_montserrat_20, LV_STATE_DEFAULT);
             lv_obj_set_style_text_color(v, UI_CLR_ACCENT, LV_STATE_DEFAULT);
             lv_obj_align_to(v, d, LV_ALIGN_OUT_RIGHT_MID, 8, 0);
             s_temp_value[i] = v;

+ 23 - 0
LVGL8v3/ui/Ui_theme.h

@@ -115,6 +115,29 @@ static inline void Ui_theme_style_btn_accent(lv_obj_t * btn)
     lv_obj_set_scrollbar_mode(btn, LV_SCROLLBAR_MODE_OFF);
 }
 
+/**
+ * @brief  危险按钮: 深红染底 + 细描边, 按下变纯红实心
+ * @note   与就绪徽章的"错误"配色同语言, 适合取消/停止等危险操作
+ * @param  btn : 按钮对象
+ */
+static inline void Ui_theme_style_btn_danger(lv_obj_t * btn)
+{
+    lv_obj_set_style_radius(btn, 8, LV_STATE_DEFAULT);
+    lv_obj_set_style_bg_color(btn, lv_color_hex(0x24110F), LV_STATE_DEFAULT);
+    lv_obj_set_style_bg_opa(btn, LV_OPA_COVER, LV_STATE_DEFAULT);
+    lv_obj_set_style_border_width(btn, 1, LV_STATE_DEFAULT);
+    lv_obj_set_style_border_color(btn, lv_color_hex(0x6E2C2C), LV_STATE_DEFAULT);
+    lv_obj_set_style_shadow_width(btn, 0, LV_STATE_DEFAULT);
+    lv_obj_set_style_shadow_opa(btn, LV_OPA_TRANSP, LV_STATE_DEFAULT);
+    lv_obj_set_style_outline_width(btn, 0, LV_STATE_DEFAULT);
+    lv_obj_set_style_pad_all(btn, 0, LV_STATE_DEFAULT);
+    /* 按下: 纯红实心 + 深红文字 */
+    lv_obj_set_style_bg_color(btn, UI_CLR_ERR, LV_STATE_PRESSED);
+    lv_obj_set_style_border_color(btn, UI_CLR_ERR, LV_STATE_PRESSED);
+    lv_obj_clear_flag(btn, LV_OBJ_FLAG_SCROLLABLE);
+    lv_obj_set_scrollbar_mode(btn, LV_SCROLLBAR_MODE_OFF);
+}
+
 /**
  * @brief  数字键盘: 纯黑底 + 深色按键, 按下/选中变强调色
  * @note   lv_keyboard 是 lv_btnmatrix 子类, 用 LV_PART_ITEMS 统一按键样式

+ 21 - 0
LVGL8v3/ui/ui.h

@@ -13,17 +13,38 @@
 extern "C" {
 #endif
 
+/* 主界面菜单 (页面) 编号 */
+typedef enum
+{
+    UI_MENU_TEMPERATURE = 0,    /* 实时温度 */
+    UI_MENU_STATUS,             /* 设备状态 */
+    UI_MENU_TEMP_SETTING,       /* 温度设置 */
+    UI_MENU_MAX
+} ui_menu_id_t;
+
 /**
  * @brief  初始化并创建工业设备主页 (需先完成 lv_init 与 lv_port_disp_init)
  */
 void Ui_init(void);
 
+/**
+ * @brief  重建右侧内容区指定菜单页面
+ * @param  menu_id : 页面编号 (ui_menu_id_t)
+ */
+void Ui_build_page(uint8_t menu_id);
+
 /**
  * @brief  设置顶部状态栏的就绪状态
  * @param  ready : true=就绪 (绿), false=未就绪 (红)
  */
 void Ui_set_ready(bool ready);
 
+/**
+ * @brief  隐藏/显示主框架 (状态栏/菜单/内容区), 供全屏覆盖页使用
+ * @param  visible : true=显示, false=隐藏 (隐藏后不参与任何重绘)
+ */
+void Ui_frame_set_visible(bool visible);
+
 #ifdef __cplusplus
 }
 #endif

+ 5 - 0
MDK-ARM/STMH7_temperature_control_board.uvprojx

@@ -2549,6 +2549,11 @@
               <FileType>1</FileType>
               <FilePath>..\LVGL8v3\ui\Ui_temp_setting.c</FilePath>
             </File>
+            <File>
+              <FileName>Ui_preheat.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\LVGL8v3\ui\Ui_preheat.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>