|
|
@@ -54,13 +54,15 @@
|
|
|
#define UI_TSET_VAL_H 56 /* 高度与加减号按钮一致 */
|
|
|
#define UI_TSET_BTN_PLUS_X 355
|
|
|
|
|
|
-/* 底部按钮行 (水平居中) */
|
|
|
-#define UI_TSET_APPLY_X 132
|
|
|
-#define UI_TSET_APPLY_Y 240
|
|
|
-#define UI_TSET_APPLY_W 140
|
|
|
-#define UI_TSET_PREHEAT_X 288
|
|
|
-#define UI_TSET_PREHEAT_W 210
|
|
|
-#define UI_TSET_BTN_H 44
|
|
|
+/* 底部按钮区: 四个按钮同一大小 270x48, 2x2 网格, 整体水平居中于 315
|
|
|
+ * 网格总宽 = 270*2 + 20(列间距) = 560, 起始 x=35; 上下行间距 16 (y: 240 / 304)
|
|
|
+ * 左列 x=35: Apply / Start Temp Control 右列 x=325: Start preheating / Stop Temp Control */
|
|
|
+#define UI_TSET_BTN_W 270
|
|
|
+#define UI_TSET_BTN_H 48
|
|
|
+#define UI_TSET_BTN_X0 35 /* 左列 */
|
|
|
+#define UI_TSET_BTN_X1 325 /* 右列 */
|
|
|
+#define UI_TSET_ROW1_Y 240
|
|
|
+#define UI_TSET_ROW2_Y 304
|
|
|
|
|
|
/* 弹窗宽度 (预热确认框与保存成功弹窗同尺寸, 适配 4.3 寸 800x480) */
|
|
|
#define UI_TSET_MBOX_W 420
|
|
|
@@ -73,7 +75,7 @@
|
|
|
static int16_t s_target = 60; /* 目标温度 (打开页面时从 EEPROM 加载) */
|
|
|
static lv_obj_t * s_ta = NULL; /* 目标温度数值输入框 */
|
|
|
static lv_obj_t * s_kb = NULL; /* 数字键盘 (弹出时有效) */
|
|
|
-static lv_obj_t * s_msgbox = NULL; /* 预热确认弹窗 (弹出时有效) */
|
|
|
+static lv_obj_t * s_msgbox = NULL; /* 确认弹窗 (预热/Start/Stop 共用, 同一时刻至多一个) */
|
|
|
static lv_obj_t * s_saved = NULL; /* 保存成功弹窗 (弹出时有效) */
|
|
|
static lv_timer_t * s_repeat_timer = NULL; /* 长按重复定时器 */
|
|
|
static uint8_t s_active = 0xFF; /* 当前激活按键: 0xFF=无, 0=递减, 1=递增 */
|
|
|
@@ -316,6 +318,85 @@ static void ui_tset_msgbox_cb(lv_event_t * e)
|
|
|
s_msgbox = NULL;
|
|
|
}
|
|
|
|
|
|
+/* 静态缓冲: 弹窗文本需保持有效直到弹窗关闭 (lv_msgbox 内部按静态文本使用) */
|
|
|
+static char s_ctl_start_txt[64];
|
|
|
+
|
|
|
+/* Start Temp Control 确认回调: Yes 直接启动 PID 控温 */
|
|
|
+static void ui_tset_startpid_confirm_cb(lv_event_t * e)
|
|
|
+{
|
|
|
+ lv_obj_t * mbox = lv_event_get_current_target(e);
|
|
|
+ if (lv_msgbox_get_active_btn(mbox) == 0)
|
|
|
+ {
|
|
|
+ app_preheat_cmd_t cmd;
|
|
|
+ cmd.type = APP_PREHEAT_CMD_START_PID;
|
|
|
+ cmd.src = APP_PREHEAT_SRC_UI;
|
|
|
+ cmd.target = (int16_t)Com_parameter_get_target();
|
|
|
+ App_preheat_send_cmd(&cmd);
|
|
|
+
|
|
|
+ lv_msgbox_close(mbox);
|
|
|
+ s_msgbox = NULL;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lv_msgbox_close(mbox);
|
|
|
+ s_msgbox = NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/* Start Temp Control 按钮: 弹出确认框 (目标温度 = Apply 保存值) */
|
|
|
+static void ui_tset_start_ctrl_cb(lv_event_t * e)
|
|
|
+{
|
|
|
+ (void)e;
|
|
|
+ if (s_msgbox != NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ static const char * btns[] = { "Yes", "No", "" };
|
|
|
+ snprintf(s_ctl_start_txt, sizeof(s_ctl_start_txt),
|
|
|
+ "Start temperature control with target %d\xC2\xB0"
|
|
|
+ "C?", (int)Com_parameter_get_target());
|
|
|
+ s_msgbox = lv_msgbox_create(NULL, "Start Temp Control", s_ctl_start_txt, btns, false);
|
|
|
+ ui_tset_style_msgbox(s_msgbox);
|
|
|
+
|
|
|
+ lv_obj_add_event_cb(s_msgbox, ui_tset_startpid_confirm_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
|
|
+ ui_tset_center_msgbox(s_msgbox);
|
|
|
+}
|
|
|
+
|
|
|
+/* Stop Temp Control 确认回调: Yes 停止 PID 控温 */
|
|
|
+static void ui_tset_stoppid_confirm_cb(lv_event_t * e)
|
|
|
+{
|
|
|
+ lv_obj_t * mbox = lv_event_get_current_target(e);
|
|
|
+ if (lv_msgbox_get_active_btn(mbox) == 0)
|
|
|
+ {
|
|
|
+ app_preheat_cmd_t cmd;
|
|
|
+ cmd.type = APP_PREHEAT_CMD_STOP;
|
|
|
+ cmd.src = APP_PREHEAT_SRC_UI;
|
|
|
+ cmd.target = 0;
|
|
|
+ App_preheat_send_cmd(&cmd);
|
|
|
+
|
|
|
+ lv_msgbox_close(mbox);
|
|
|
+ s_msgbox = NULL;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lv_msgbox_close(mbox);
|
|
|
+ s_msgbox = NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/* Stop Temp Control 按钮: 弹出确认框 */
|
|
|
+static void ui_tset_stop_ctrl_cb(lv_event_t * e)
|
|
|
+{
|
|
|
+ (void)e;
|
|
|
+ if (s_msgbox != NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ static const char * btns[] = { "Yes", "No", "" };
|
|
|
+ s_msgbox = lv_msgbox_create(NULL, "Stop Temp Control",
|
|
|
+ "Stop temperature control?", btns, false);
|
|
|
+ ui_tset_style_msgbox(s_msgbox);
|
|
|
+
|
|
|
+ lv_obj_add_event_cb(s_msgbox, ui_tset_stoppid_confirm_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
|
|
+ ui_tset_center_msgbox(s_msgbox);
|
|
|
+}
|
|
|
+
|
|
|
/* Start preheating 按钮: 弹出确认框 (与保存成功弹窗同尺寸同风格) */
|
|
|
static void ui_tset_preheat_cb(lv_event_t * e)
|
|
|
{
|
|
|
@@ -519,10 +600,12 @@ void Ui_temp_setting_create(lv_obj_t * parent)
|
|
|
/* 递增按钮 "+" (长按自动加) */
|
|
|
ui_tset_add_step_btn(card, LV_SYMBOL_PLUS, UI_TSET_BTN_PLUS_X, ui_tset_plus_cb);
|
|
|
|
|
|
- /* 底部按钮行 (居中): Apply + Start preheating */
|
|
|
+ /* 底部按钮区: 四个按钮同一大小, 2x2 网格 (居中) */
|
|
|
+
|
|
|
+ /* 左上: Apply —— 校验并保存目标温度到 EEPROM, 按结果弹成功/失败提示 */
|
|
|
lv_obj_t * apply = lv_btn_create(parent);
|
|
|
- lv_obj_set_size(apply, UI_TSET_APPLY_W, UI_TSET_BTN_H);
|
|
|
- lv_obj_set_pos(apply, UI_TSET_APPLY_X, UI_TSET_APPLY_Y);
|
|
|
+ lv_obj_set_size(apply, UI_TSET_BTN_W, UI_TSET_BTN_H);
|
|
|
+ lv_obj_set_pos(apply, UI_TSET_BTN_X0, UI_TSET_ROW1_Y);
|
|
|
lv_obj_add_event_cb(apply, ui_tset_apply_cb, LV_EVENT_CLICKED, NULL);
|
|
|
Ui_theme_style_btn_accent(apply);
|
|
|
lv_obj_t * al = lv_label_create(apply);
|
|
|
@@ -531,9 +614,10 @@ void Ui_temp_setting_create(lv_obj_t * parent)
|
|
|
lv_obj_set_style_text_color(al, UI_CLR_ACCENT_DARK, LV_STATE_DEFAULT);
|
|
|
lv_obj_center(al);
|
|
|
|
|
|
+ /* 右上: Start preheating —— 确认后进入预加热流程 */
|
|
|
lv_obj_t * ph = lv_btn_create(parent);
|
|
|
- lv_obj_set_size(ph, UI_TSET_PREHEAT_W, UI_TSET_BTN_H);
|
|
|
- lv_obj_set_pos(ph, UI_TSET_PREHEAT_X, UI_TSET_APPLY_Y);
|
|
|
+ lv_obj_set_size(ph, UI_TSET_BTN_W, UI_TSET_BTN_H);
|
|
|
+ lv_obj_set_pos(ph, UI_TSET_BTN_X1, UI_TSET_ROW1_Y);
|
|
|
lv_obj_add_event_cb(ph, ui_tset_preheat_cb, LV_EVENT_CLICKED, NULL);
|
|
|
Ui_theme_style_btn_accent(ph);
|
|
|
lv_obj_t * pl = lv_label_create(ph);
|
|
|
@@ -542,6 +626,30 @@ void Ui_temp_setting_create(lv_obj_t * parent)
|
|
|
lv_obj_set_style_text_color(pl, UI_CLR_ACCENT_DARK, LV_STATE_DEFAULT);
|
|
|
lv_obj_center(pl);
|
|
|
|
|
|
+ /* 左下: Start Temp Control —— 确认后以已保存温度直接启动 PID 控温 */
|
|
|
+ lv_obj_t * starttc = lv_btn_create(parent);
|
|
|
+ lv_obj_set_size(starttc, UI_TSET_BTN_W, UI_TSET_BTN_H);
|
|
|
+ lv_obj_set_pos(starttc, UI_TSET_BTN_X0, UI_TSET_ROW2_Y);
|
|
|
+ lv_obj_add_event_cb(starttc, ui_tset_start_ctrl_cb, LV_EVENT_CLICKED, NULL);
|
|
|
+ Ui_theme_style_btn_accent(starttc);
|
|
|
+ lv_obj_t * spl = lv_label_create(starttc);
|
|
|
+ lv_label_set_text(spl, "Start Temp Control");
|
|
|
+ lv_obj_set_style_text_font(spl, &lv_font_montserrat_16, LV_STATE_DEFAULT);
|
|
|
+ lv_obj_set_style_text_color(spl, UI_CLR_ACCENT_DARK, LV_STATE_DEFAULT);
|
|
|
+ lv_obj_center(spl);
|
|
|
+
|
|
|
+ /* 右下: Stop Temp Control —— 确认后停止 PID 控温; 红色 danger 区分停止操作 */
|
|
|
+ lv_obj_t * stoptc = lv_btn_create(parent);
|
|
|
+ lv_obj_set_size(stoptc, UI_TSET_BTN_W, UI_TSET_BTN_H);
|
|
|
+ lv_obj_set_pos(stoptc, UI_TSET_BTN_X1, UI_TSET_ROW2_Y);
|
|
|
+ lv_obj_add_event_cb(stoptc, ui_tset_stop_ctrl_cb, LV_EVENT_CLICKED, NULL);
|
|
|
+ Ui_theme_style_btn_danger(stoptc);
|
|
|
+ lv_obj_t * stl = lv_label_create(stoptc);
|
|
|
+ lv_label_set_text(stl, "Stop Temp Control");
|
|
|
+ lv_obj_set_style_text_font(stl, &lv_font_montserrat_16, LV_STATE_DEFAULT);
|
|
|
+ lv_obj_set_style_text_color(stl, UI_CLR_ERR, LV_STATE_DEFAULT);
|
|
|
+ lv_obj_center(stl);
|
|
|
+
|
|
|
ui_tset_refresh();
|
|
|
}
|
|
|
|