From de77dfcbbd392c47ed8ec1f711abefe6c10b30f0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 17 Oct 2021 22:10:08 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=20MKS=20UI=20goto=5Fprevious?= =?UTF-8?q?=5Fui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/mks_ui/draw_about.cpp | 3 +- .../lcd/extui/mks_ui/draw_baby_stepping.cpp | 3 +- .../lcd/extui/mks_ui/draw_change_speed.cpp | 3 +- .../src/lcd/extui/mks_ui/draw_cloud_bind.cpp | 3 +- Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp | 30 +++++++------------ .../src/lcd/extui/mks_ui/draw_extrusion.cpp | 3 +- Marlin/src/lcd/extui/mks_ui/draw_fan.cpp | 2 +- .../lcd/extui/mks_ui/draw_filament_change.cpp | 3 +- Marlin/src/lcd/extui/mks_ui/draw_home.cpp | 3 +- Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp | 12 +++----- .../src/lcd/extui/mks_ui/draw_move_motor.cpp | 3 +- .../src/lcd/extui/mks_ui/draw_number_key.cpp | 3 +- .../src/lcd/extui/mks_ui/draw_operation.cpp | 3 +- Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp | 3 +- .../extui/mks_ui/draw_touch_calibration.cpp | 3 +- .../mks_ui/draw_tramming_pos_settings.cpp | 3 +- Marlin/src/lcd/extui/mks_ui/draw_ui.cpp | 5 ++++ Marlin/src/lcd/extui/mks_ui/draw_ui.h | 1 + .../lcd/extui/mks_ui/draw_wifi_settings.cpp | 3 +- 19 files changed, 35 insertions(+), 57 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_about.cpp b/Marlin/src/lcd/extui/mks_ui/draw_about.cpp index 3424bf7a0e..49ee6eee73 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_about.cpp @@ -39,8 +39,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { case ID_A_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp index bcc075ae64..1a6767dcc1 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp @@ -107,8 +107,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { TERN_(EEPROM_SETTINGS, (void)settings.save()); has_adjust_z = 0; } - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp b/Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp index 5248816f54..6b07d4b719 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp @@ -110,8 +110,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { disp_speed_step(); break; case ID_C_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp b/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp index 1d0ae7775b..1dae0ebe22 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp @@ -49,8 +49,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { case ID_CLOUD_BIND_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; case ID_CLOUD_RELEASE_BIND: if (cloud_para.state == 0x12) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index 3cdb07b608..a69c54bcff 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -136,19 +136,16 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { else if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) { - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } #endif else if (DIALOG_IS(STORE_EEPROM_TIPS)) { TERN_(EEPROM_SETTINGS, (void)settings.save()); - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } else if (DIALOG_IS(READ_EEPROM_TIPS)) { TERN_(EEPROM_SETTINGS, (void)settings.load()); - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } else if (DIALOG_IS(REVERT_EEPROM_TIPS)) { TERN_(EEPROM_SETTINGS, (void)settings.reset()); @@ -166,27 +163,23 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { } else if (DIALOG_IS(WIFI_CONFIG_TIPS)) { uiCfg.configWifi = true; - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED)) uiCfg.filament_heat_completed_load = true; else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) uiCfg.filament_heat_completed_unload = true; else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) { - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } #if ENABLED(MKS_WIFI_MODULE) else if (DIALOG_IS(TYPE_UNBIND)) { cloud_unbind(); - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } #endif else { - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } } @@ -197,8 +190,7 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { } else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT, TYPE_FILAMENT_HEAT_LOAD_COMPLETED, TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) { thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) { queue.enqueue_one(F("M410")); @@ -210,12 +202,10 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { uiCfg.filament_unloading_time_flg = false; uiCfg.filament_unloading_time_cnt = 0; thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } else { - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp index f3204eb962..85894a5e92 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp @@ -106,8 +106,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { disp_ext_speed(); break; case ID_E_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_fan.cpp b/Marlin/src/lcd/extui/mks_ui/draw_fan.cpp index b2107709a4..12b47d9e94 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_fan.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_fan.cpp @@ -55,7 +55,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_F_HIGH: fanPercent = 100; break; case ID_F_MID: fanPercent = 50; break; case ID_F_OFF: fanPercent = 0; break; - case ID_F_RETURN: clear_cur_ui(); draw_return_ui(); return; + case ID_F_RETURN: goto_previous_ui(); return; } thermalManager.set_fan_speed(0, map(fanPercent, 0, 100, 0, 255)); if (obj->mks_obj_id != ID_F_RETURN) disp_fan_value(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp index 61d212303b..be70fa9b4e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp @@ -101,8 +101,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak)); thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_home.cpp b/Marlin/src/lcd/extui/mks_ui/draw_home.cpp index 04ebd95a09..a819fffacd 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_home.cpp @@ -67,8 +67,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { queue.inject(F("M84XY")); break; case ID_H_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp index 6d7bdc2aa7..90b181d6b5 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp @@ -105,8 +105,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { } else if (strcmp_P(txt, PSTR(LV_SYMBOL_CLOSE)) == 0) { if (kb->event_cb != lv_kb_def_event_cb) { - lv_clear_keyboard(); - draw_return_ui(); + goto_previous_ui(); } else { lv_kb_set_ta(kb, nullptr); // De-assign the text area to hide its cursor if needed @@ -122,13 +121,11 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { #if ENABLED(MKS_WIFI_MODULE) case wifiName: memcpy(uiCfg.wifi_name, ret_ta_txt, sizeof(uiCfg.wifi_name)); - lv_clear_keyboard(); - draw_return_ui(); + goto_previous_ui(); break; case wifiPassWord: memcpy(uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_name)); - lv_clear_keyboard(); - draw_return_ui(); + goto_previous_ui(); break; case wifiConfig: ZERO(uiCfg.wifi_name); @@ -160,8 +157,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { uint8_t buf[100]; strncpy((char *)buf, ret_ta_txt, sizeof(buf)); update_gcode_command(AUTO_LEVELING_COMMAND_ADDR, buf); - lv_clear_keyboard(); - draw_return_ui(); + goto_previous_ui(); break; case GCodeCommand: if (ret_ta_txt[0] && !queue.ring_buffer.full(3)) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp index baa8d48da3..635421b4c3 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp @@ -83,8 +83,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { disp_move_dist(); break; case ID_M_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); return; } disp_cur_pos(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index 630bb4efef..deed037248 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -453,8 +453,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_NUM_CONFIRM: last_disp_state = NUMBER_KEY_UI; if (strlen(key_value) != 0) set_value_confirm(); - lv_clear_number_key(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_operation.cpp b/Marlin/src/lcd/extui/mks_ui/draw_operation.cpp index 8be74c6b9a..ffe714fca9 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_operation.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_operation.cpp @@ -90,8 +90,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { lv_draw_change_speed(); break; case ID_O_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; case ID_O_POWER_OFF: if (gCfgItems.finish_power_off) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp index fe651133c3..fe289d8cad 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp @@ -159,8 +159,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { disp_desire_temp(); break; case ID_P_RETURN: - clear_cur_ui(); - draw_return_ui(); + goto_previous_ui(); break; case ID_P_ABS: if (uiCfg.curTempType == 0) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp index c7e2d5bc31..e0c663e282 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp @@ -99,8 +99,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_TC_RETURN: TERN_(MKS_TEST, current_disp_ui = 1); - lv_clear_touch_calibration_screen(); - draw_return_ui(); + goto_previous_ui(); break; } } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp index d5501a3a45..845ef1d807 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp @@ -54,8 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_MANUAL_POS_RETURN: uiCfg.para_ui_page = false; - lv_clear_tramming_pos_settings(); - draw_return_ui(); + goto_previous_ui(); return; case ID_MANUAL_POS_X1: value = level_pos_x1; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 37b06356e0..66b2deda66 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -1082,6 +1082,11 @@ void draw_return_ui() { } } +void goto_previous_ui() { + clear_cur_ui(); + draw_return_ui(); +} + // Set the same image for both Released and Pressed void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src) { lv_imgbtn_set_src(imgbtn, LV_BTN_STATE_REL, src); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index a74d7e1ae2..55ea6220e0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -467,6 +467,7 @@ void lv_eom_hook(void *); void GUI_RefreshPage(); void clear_cur_ui(); void draw_return_ui(); +void goto_previous_ui(); void sd_detection(); void gCfg_to_spiFlah(); void print_time_count(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.cpp index fb9fb4f9eb..cf086b45b1 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.cpp @@ -47,8 +47,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { case ID_WIFI_RETURN: - lv_clear_wifi_settings(); - draw_return_ui(); + goto_previous_ui(); break; case ID_WIFI_MODEL: if (gCfgItems.wifi_mode_sel == AP_MODEL) {