Quellcode durchsuchen

1. 新增 Ui_cfg.h 集中定义 UI_LOCAL_CTRL_ENABLE (1=屏端可控, 0=只显示)。所有 UI 文件都从这里
取判断依据, 不在别处另写开关;
2. 宏=0 时: 菜单只剩"实时温度""设备状态"(UI_MENU_MAX 自动变 2); 温度设置页整个不参与编译;
预加热页的"取消/跳过"按钮与 BMC 未就绪弹窗一并裁掉。目标温度、启动/中止/跳过预热
全部交给上位机 PC 协议
3. 预加热页按宏分两套布局: 宏开保持"左 3/4 卡片 + 右 1/4 动画窄柱"; 宏关时卡片加宽到全宽、
动画面板改成底部横带(原 cancel 的位置), 否则底部空出 112px、右侧 128 宽的窄柱也显空。
横带只放 spinner + 加热中...(居中)
4. 修: 上位机 0x08 控温结束时, 屏若停在预热页会退不出来 —— 该处理函数只发了 END_CONTROL
和应答, 漏了 Ui_preheat_abort_exit() (0x05 那条有)。已补, 队列满失败时不关页
5. 删除温度设置页的两个死接口: Ui_temp_setting_get_target()/notify_ext() 全工程零调用,
连同其依赖的 static ui_tset_ext_reload() 与 s_ext_dirty 脏标志一并移除; .h 声明同步删除

zhanghongyi vor 1 Monat
Ursprung
Commit
9e6cd3e446

+ 8 - 0
App/App/Src/App_pc.c

@@ -600,6 +600,14 @@ static void App_Pc_HandleEndControl(void)
 
     status = (App_preheat_send_cmd(&cmd) == pdPASS) ? COM_PC_STATUS_OK : COM_PC_STATUS_FAIL;
 
+    /* 控温结束会连带停预热: 屏若正停在预热页, 必须一并关回实时温度页。
+     * 预热状态机已停而页面还留着, 用户就只能等上位机再发 0x05 才退得出去。
+     * abort_exit 内部已判 s_pre_root, 不在预热页时是空操作 */
+    if (status == COM_PC_STATUS_OK)
+    {
+        Ui_preheat_abort_exit();
+    }
+
     LOG_PRINTF("[INFO] PC: end temp control status=%d\r\n", (int)status);
     App_Pc_SendCtrlAck(COM_PC_ACK_END_CONTROL, status);
 }

+ 6 - 0
App/LVGL8v3/ui/Ui.c

@@ -13,7 +13,9 @@
 #include "Ui_theme.h"
 #include "Ui_temperature.h"
 #include "Ui_status.h"
+#if UI_LOCAL_CTRL_ENABLE
 #include "Ui_temp_setting.h"
+#endif
 #include "Ui_preheat.h"
 #include "App_cpld.h"
 #include "App_preheat.h"
@@ -60,7 +62,9 @@ static const char * s_menu_text[UI_MENU_MAX] =
 {
     "实时温度",
     "设备状态",
+#if UI_LOCAL_CTRL_ENABLE
     "温度设置",
+#endif
 };
 
 static lv_obj_t * s_menu_btns[UI_MENU_MAX]   = { NULL };  /* 菜单按钮句柄 */
@@ -333,9 +337,11 @@ void Ui_build_page(uint8_t menu_id)
     case UI_MENU_STATUS:
         Ui_status_create(s_page);
         break;
+#if UI_LOCAL_CTRL_ENABLE
     case UI_MENU_TEMP_SETTING:
         Ui_temp_setting_create(s_page);
         break;
+#endif
     default:
         break;
     }

+ 18 - 0
App/LVGL8v3/ui/Ui_cfg.h

@@ -0,0 +1,18 @@
+/**
+  ******************************************************************************
+  * @file    Ui_cfg.h
+  * @brief   UI 能力开关 (编译期裁剪)
+  ******************************************************************************
+  */
+#ifndef __UI_CFG_H
+#define __UI_CFG_H
+
+/* 屏端是否允许本地控制
+ *   1 = 屏端可控制: 菜单含"温度设置"; 预加热页带"取消 / 跳过"按钮
+ *   0 = 屏端只显示: 菜单只有"实时温度""设备状态"; 温度设置页与预加热页按钮都不参与编译,
+ *       目标温度、启动/中止/跳过预热全部由上位机 (PC 协议) 负责
+ * 注意!所有 UI 文件都从这里取判断依据, 不要在别处另写一份开关。
+ *       改完这个数字重新编译即可, 不需要动其它文件。 */
+#define UI_LOCAL_CTRL_ENABLE   0
+
+#endif /* __UI_CFG_H */

+ 59 - 8
App/LVGL8v3/ui/Ui_preheat.c

@@ -6,7 +6,8 @@
   * @note    点击"开始预热"确认框的 Yes 后进入: 全屏不透明覆盖, 隐藏状态栏/
   *          菜单/内容区; 左 3/4 为 CPU0 / CPU1 两张温度卡片 (各 2 个腔体,
   *          每腔体显示其 2 路 CT7428 sensor 的均温, 不是单路 sensor 值);
-  *          右 1/4 为加热动画 + 已加热时长; 底部红色 cancel 返回温度设置页。
+  *          宏开(屏端可控制): 左 3/4 卡片 + 右 1/4 动画窄柱, 底部红色 cancel 回实时温度页;
+ *          宏关(只显示): 卡片占满全宽, 动画改为底部一条横带 (spinner + 加热中..., 居中)。
   ******************************************************************************
   */
 #include <stdio.h>
@@ -27,19 +28,34 @@
 #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
 
+#if UI_LOCAL_CTRL_ENABLE
+/* 宏开: 左 3/4 放卡片, 右 1/4 是动画窄柱 (与卡片同高) */
+#define UI_PRE_CARD_W          (UI_PRE_TEMPS_W - 32)
+#define UI_PRE_ANIM_X          (UI_PRE_TEMPS_W + 16)
+#define UI_PRE_ANIM_Y          UI_PRE_CARD_Y0
+#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)
+#define UI_PRE_SPIN_D          120
+#else
+/* 宏关: 卡片占满全宽; 动画改成底部一条横带 (原 cancel 的位置),
+ * 否则底部会空出 112px、右侧 128 宽的窄柱也会显得空 */
+#define UI_PRE_CARD_W          (UI_PRE_W - 32)
+#define UI_PRE_ANIM_X          16
+#define UI_PRE_ANIM_Y          (UI_PRE_CARD_Y0 + UI_PRE_CARD_H * 2 + UI_PRE_CARD_GAP + 8)
+#define UI_PRE_ANIM_W          (UI_PRE_W - 32)
+#define UI_PRE_ANIM_H          88
+#define UI_PRE_SPIN_D          60
+#endif
+
 /* 卡片内行布局 */
 #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)
 
+#if UI_LOCAL_CTRL_ENABLE
 /* 底部 cancel 按钮 */
 #define UI_PRE_CANCEL_W        200
 #define UI_PRE_CANCEL_H        48
@@ -47,6 +63,7 @@
 /* 右侧面板底部 skip 按钮 (跳过预热, 直接 PID 控温) */
 #define UI_PRE_SKIP_W          140
 #define UI_PRE_SKIP_H          48
+#endif
 
 /* BMC 未就绪提示弹窗宽度 (与其它页弹窗同宽) */
 #define UI_PRE_MBOX_W          420
@@ -61,13 +78,16 @@
 /*-------------------------------- 句柄 ---------------------------------*/
 static lv_obj_t    * s_pre_root = NULL;                  /* 全屏页面根 */
 static lv_timer_t  * s_pre_timer = NULL;                 /* 刷新定时器 */
+#if UI_LOCAL_CTRL_ENABLE
 static lv_obj_t    * s_nr_mbox  = NULL;                  /* BMC 未就绪提示弹窗 */
+#endif
 static uint8_t       s_page_closed = 0;                  /* 已由 UI 指定目标页并关闭 */
 static lv_obj_t    * s_pre_value[LOGIC_PREHEAT_TEMP_NUM];/* 4 路温度值 */
 static char          s_pre_buf[LOGIC_PREHEAT_TEMP_NUM][12];
 static int8_t        s_pre_last[LOGIC_PREHEAT_TEMP_NUM]; /* 上周期已显示的值 */
 static uint8_t       s_pre_valid = 0;                    /* 缓存是否已初始化 */
 
+
 /*----------------------------- 静态函数 ------------------------------*/
 
 /* 刷新 4 路温度数值 */
@@ -99,6 +119,7 @@ static void ui_preheat_refresh(void)
         }
         lv_label_set_text_static(s_pre_value[i], s_pre_buf[i]);
     }
+
     s_pre_valid = 1;
 }
 
@@ -118,14 +139,17 @@ static void ui_preheat_delete_cb(lv_event_t * e)
         lv_timer_del(s_pre_timer);
         s_pre_timer = NULL;
     }
+#if UI_LOCAL_CTRL_ENABLE
     if (s_nr_mbox != NULL)
     {
         lv_msgbox_close(s_nr_mbox);       /* 自动删除全屏遮罩 */
         s_nr_mbox = NULL;
     }
+#endif
     s_pre_root = NULL;
 }
 
+#if UI_LOCAL_CTRL_ENABLE
 /* cancel 按钮: 必须在按钮范围内抬手才退出 (手指移出后抬起不生效) */
 static void ui_preheat_cancel_cb(lv_event_t * e)
 {
@@ -212,6 +236,7 @@ static void ui_preheat_skip_cb(lv_event_t * e)
     cmd.target = (int16_t)Com_parameter_get_target();
     App_preheat_send_cmd(&cmd);
 }
+#endif /* UI_LOCAL_CTRL_ENABLE */
 
 /* 构建一张温度卡片 (CPU0/CPU1, 各含 2 个腔体温度, 每腔体 = 2 路 sensor 均温) */
 static void ui_preheat_build_card(lv_obj_t * root, const char * cpu_name,
@@ -406,6 +431,7 @@ void Ui_preheat_enter(void)
     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);
 
+#if UI_LOCAL_CTRL_ENABLE
     /* 底部红色 cancel 按钮 (整屏水平居中) */
     lv_obj_t * cancel = lv_btn_create(root);
     lv_obj_set_size(cancel, UI_PRE_CANCEL_W, UI_PRE_CANCEL_H);
@@ -417,13 +443,16 @@ void Ui_preheat_enter(void)
     lv_obj_set_style_text_font(cl, UI_FONT_TITLE, LV_STATE_DEFAULT);
     lv_obj_set_style_text_color(cl, UI_CLR_ERR, LV_STATE_DEFAULT);
     lv_obj_center(cl);
+#endif /* UI_LOCAL_CTRL_ENABLE */
 
     /* 右 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_pos(panel, UI_PRE_ANIM_X, UI_PRE_ANIM_Y);
     lv_obj_set_size(panel, UI_PRE_ANIM_W, UI_PRE_ANIM_H);
     Ui_theme_style_panel(panel);
 
+#if UI_LOCAL_CTRL_ENABLE
+    /* 窄柱: 标题在上, 大 spinner 居中 */
     lv_obj_t * head = lv_label_create(panel);
     lv_label_set_text(head, "加热中...");
     lv_obj_set_style_text_font(head, UI_FONT_TITLE, LV_STATE_DEFAULT);
@@ -431,13 +460,34 @@ void Ui_preheat_enter(void)
     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_size(spin, UI_PRE_SPIN_D, UI_PRE_SPIN_D);
     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);
+#else
+    /* 横带: spinner 靠左, 右侧两行文字, 目标温度贴右缘 */
+    lv_obj_set_style_pad_all(panel, 0, LV_STATE_DEFAULT);
+
+    lv_obj_t * spin = lv_spinner_create(panel, 1000, 70);
+    lv_obj_set_size(spin, UI_PRE_SPIN_D, UI_PRE_SPIN_D);
+    lv_obj_set_style_arc_width(spin, 6, 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, 6, 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, -70, 0);
+
+    /* 只放"加热中..." —— 中文字库是子集(my_font_cn_16/20 只含用到的字),
+     * 新加的字(如"最高腔温")不在字库里会显示成空白, 所以横带不再放其它文字 */
+    lv_obj_t * head = lv_label_create(panel);
+    lv_label_set_text(head, "加热中...");
+    lv_obj_set_style_text_font(head, UI_FONT_TITLE, LV_STATE_DEFAULT);
+    lv_obj_set_style_text_color(head, UI_CLR_TEXT, LV_STATE_DEFAULT);
+    lv_obj_align(head, LV_ALIGN_CENTER, 50, 0);
+#endif
 
+#if UI_LOCAL_CTRL_ENABLE
     /* Skip 按钮: 跳过预热, 直接进入 PID 控温 */
     lv_obj_t * skip = lv_btn_create(panel);
     lv_obj_set_size(skip, UI_PRE_SKIP_W, UI_PRE_SKIP_H);
@@ -449,6 +499,7 @@ void Ui_preheat_enter(void)
     lv_obj_set_style_text_font(sl, UI_FONT_TITLE, LV_STATE_DEFAULT);
     lv_obj_set_style_text_color(sl, UI_CLR_ACCENT_DARK, LV_STATE_DEFAULT);
     lv_obj_center(sl);
+#endif /* UI_LOCAL_CTRL_ENABLE */
 
     s_pre_valid = 0;         /* 新建页面: 标签是全新的, 必须强制刷一次 */
     ui_preheat_refresh();

+ 5 - 48
App/LVGL8v3/ui/Ui_temp_setting.c

@@ -17,6 +17,10 @@
  *          用户正在编辑时 (键盘打开/长按步进中) 暂停同步, 避免覆盖输入。
   ******************************************************************************
   */
+#include "Ui_cfg.h"
+
+#if UI_LOCAL_CTRL_ENABLE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "Ui_temp_setting.h"
@@ -88,7 +92,6 @@ static lv_obj_t * s_saved  = NULL;  /* 保存成功弹窗 (弹出时有效) */
 static lv_timer_t * s_repeat_timer = NULL;  /* 长按重复定时器 */
 static uint8_t    s_active = 0xFF;  /* 当前激活按键: 0xFF=无, 0=递减, 1=递增 */
 static uint8_t    s_repeat = 0;     /* 已重复次数 */
-static uint8_t    s_ext_dirty = 0;  /* 外部(上位机)修改标志: 置位后本页刷新一次 */
 
 /* 刷新目标温度数值显示 */
 static void ui_tset_refresh(void)
@@ -102,36 +105,6 @@ static void ui_tset_refresh(void)
     lv_textarea_set_text(s_ta, buf);
 }
 
-/* 外部修改通知 (事件驱动): 上位机 App_pc 成功写入目标温度后调用。
- * 本页打开时立即刷新一次显示 (经 lv_async_call 投递到 LVGL 任务);
- * 页面未打开则仅置脏标志, 进入页面时取最新值。
- * 不再使用周期定时器轮询, 用户手动编辑期间不会被覆盖 */
-static void ui_tset_ext_reload(void * data)
-{
-    (void)data;
-
-    if (s_ta == NULL)
-    {
-        s_ext_dirty = 1;                  /* 页面未打开: 进页时刷新 */
-        return;
-    }
-    if (s_kb != NULL || s_active != 0xFF)
-    {
-        s_ext_dirty = 1;                  /* 编辑中: 延迟到编辑结束 */
-        return;
-    }
-
-    s_target = (int16_t)Com_parameter_get_target();
-    ui_tset_refresh();
-    s_ext_dirty = 0;
-}
-
-/* 上位机修改目标温度后的对外通知入口 (任意任务上下文可调) */
-void Ui_temp_setting_notify_ext(void)
-{
-    lv_async_call(ui_tset_ext_reload, NULL);
-}
-
 /* 应用键盘输入: 解析并限制范围 */
 static void ui_tset_apply_kb_input(void)
 {
@@ -698,22 +671,6 @@ void Ui_temp_setting_create(lv_obj_t * parent)
     lv_obj_center(stl);
 
     ui_tset_refresh();
-
-    /* 目标温度显示从 Com_parameter 副本加载; 上位机修改走事件通知
-     * (Ui_temp_setting_notify_ext), 不再周期轮询 */
-    if (s_ext_dirty)
-    {
-        s_target = (int16_t)Com_parameter_get_target();
-        s_ext_dirty = 0;
-    }
-    ui_tset_refresh();
 }
 
-/**
- * @brief  获取当前目标温度设定值
- * @retval 目标温度 (摄氏度, 整数)
- */
-int16_t Ui_temp_setting_get_target(void)
-{
-    return s_target;
-}
+#endif /* UI_LOCAL_CTRL_ENABLE */

+ 5 - 14
App/LVGL8v3/ui/Ui_temp_setting.h

@@ -2,6 +2,9 @@
 #define __UI_TEMP_SETTING_H
 
 #include "lvgl.h"
+#include "Ui_cfg.h"
+
+#if UI_LOCAL_CTRL_ENABLE
 
 #ifdef __cplusplus
 extern "C" {
@@ -14,22 +17,10 @@ extern "C" {
  */
 void Ui_temp_setting_create(lv_obj_t * parent);
 
-/**
- * @brief  获取当前目标温度设定值
- * @retval 目标温度 (摄氏度, 整数)
- */
-int16_t Ui_temp_setting_get_target(void);
-
-/**
- * @brief  通知目标温度已被外部修改 (事件驱动刷新, 替代周期轮询)
- * @note   任意任务上下文可调 (如 App_pc 上位机任务): 内部经 lv_async_call
- *         投递到 LVGL 任务; 设置页打开时立即刷新一次显示, 未打开则
- *         置脏标志 (进页时取最新值)。用户编辑中不覆盖, 延迟到编辑结束。
- */
-void Ui_temp_setting_notify_ext(void);
-
 #ifdef __cplusplus
 }
 #endif
 
+#endif /* UI_LOCAL_CTRL_ENABLE */
+
 #endif /* __UI_TEMP_SETTING_H */

+ 4 - 1
App/LVGL8v3/ui/ui.h

@@ -8,6 +8,7 @@
 #define __UI_H
 
 #include "lvgl.h"
+#include "Ui_cfg.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -18,7 +19,9 @@ typedef enum
 {
     UI_MENU_TEMPERATURE = 0,    /* 实时温度 */
     UI_MENU_STATUS,             /* 设备状态 */
-    UI_MENU_TEMP_SETTING,       /* 温度设置 */
+#if UI_LOCAL_CTRL_ENABLE
+    UI_MENU_TEMP_SETTING,       /* 温度设置 (屏端可控制时才存在) */
+#endif
     UI_MENU_MAX
 } ui_menu_id_t;
 

+ 5 - 0
App/MDK-ARM/App_6400_FrontAndBack.uvprojx

@@ -2595,6 +2595,11 @@
         <Group>
           <GroupName>LVGL/ui</GroupName>
           <Files>
+            <File>
+              <FileName>Ui_cfg.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>..\LVGL8v3\ui\Ui_cfg.h</FilePath>
+            </File>
             <File>
               <FileName>Ui.c</FileName>
               <FileType>1</FileType>