diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp index e0ef10a728a6..5e5b5f36a0f0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp @@ -66,8 +66,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { queue.inject_P(PSTR("M84 X Y")); break; case ID_H_RETURN: - lv_clear_home(); - lv_draw_tool(); + clear_cur_ui(); + draw_return_ui(); break; } } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp index 6a0aec8e2f72..7cac52bdaf22 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp @@ -27,12 +27,18 @@ #include #include "../../../../gcode/queue.h" +#include "../../../../module/motion.h" #include "../../../../inc/MarlinConfig.h" extern lv_group_t *g; static lv_obj_t *scr; -static lv_obj_t *labelV, *buttonV; +static lv_obj_t *labelV, *buttonV, *labelP; +static lv_task_t *updatePosTask; +static char cur_label = 'Z'; +static float cur_pos = 0; + +void disp_cur_pos(); enum { ID_M_X_P = 1, @@ -54,6 +60,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed); queue.enqueue_one_now(public_buf_l); queue.enqueue_one_P(PSTR("G90")); + cur_label = 'X'; } break; case ID_M_X_N: @@ -62,6 +69,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G90")); + cur_label = 'X'; } break; case ID_M_Y_P: @@ -70,6 +78,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G90")); + cur_label = 'Y'; } break; case ID_M_Y_N: @@ -78,6 +87,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G90")); + cur_label = 'Y'; } break; case ID_M_Z_P: @@ -86,6 +96,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G90")); + cur_label = 'Z'; } break; case ID_M_Z_N: @@ -94,6 +105,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G90")); + cur_label = 'Z'; } break; case ID_M_STEP: @@ -106,10 +118,21 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_M_RETURN: clear_cur_ui(); draw_return_ui(); - break; + return; } + disp_cur_pos(); } +void refresh_pos(lv_task_t *) +{ + switch(cur_label) { + case 'X': cur_pos = current_position.x; break; + case 'Y': cur_pos = current_position.y; break; + case 'Z': cur_pos = current_position.z; break; + default: return; + } + disp_cur_pos(); +} void lv_draw_move_motor(void) { scr = lv_screen_create(MOVE_MOTOR_UI); lv_obj_t *buttonXI = lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_M_X_P); @@ -129,9 +152,26 @@ void lv_draw_move_motor(void) { } #endif + lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN); + // We need to patch the title to leave some space on the right for displaying the status + lv_obj_t * title = lv_obj_get_child_back(scr, NULL); + if (title != NULL) lv_obj_set_width(title, TFT_WIDTH - 101); + labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm"); + if (labelP != NULL) { + updatePosTask = lv_task_create(refresh_pos, 300, LV_TASK_PRIO_LOWEST, 0); + } + + disp_move_dist(); + disp_cur_pos(); +} + + +void disp_cur_pos() { + sprintf_P(public_buf_l, PSTR("%c:%3.1fmm"), cur_label, cur_pos); + if (labelP) lv_label_set_text(labelP, public_buf_l); } void disp_move_dist() { @@ -162,6 +202,7 @@ void lv_clear_move_motor() { #if HAS_ROTARY_ENCODER if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); #endif + lv_task_del(updatePosTask); lv_obj_del(scr); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp index c5047616e6c8..c48d275e0142 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -50,7 +50,12 @@ enum { static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; - lv_clear_tool(); + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + bool clear = (obj->mks_obj_id != ID_T_LEVELING); + #else + constexpr bool clear = true; + #endif + if (clear) lv_clear_tool(); switch (obj->mks_obj_id) { case ID_T_PRE_HEAT: lv_draw_preHeat(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp index b9cf00801720..fca0aacb34cb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -585,15 +585,16 @@ char *creat_title_text() { index++; } - if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI - ) { + if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI) { titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)":"); titleText_cat(public_buf_m, sizeof(public_buf_m), tmpCurFileStr); } if (strlen(public_buf_m) > MAX_TITLE_LEN) { ZERO(public_buf_m); - tmpText = getDispText(0); + tmpText = 0; + for (index = 0; index <= disp_state_stack._disp_index && (!tmpText || *tmpText == 0); index++) + tmpText = getDispText(index); if (*tmpText != 0) { titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText); titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">...>");