🎨 Add MKS UI goto_previous_ui

This commit is contained in:
Scott Lahteine 2021-10-17 22:10:08 -05:00 committed by Scott Lahteine
parent af08f16efc
commit de77dfcbbd
19 changed files with 35 additions and 57 deletions

View file

@ -39,8 +39,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_A_RETURN: case ID_A_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -107,8 +107,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
TERN_(EEPROM_SETTINGS, (void)settings.save()); TERN_(EEPROM_SETTINGS, (void)settings.save());
has_adjust_z = 0; has_adjust_z = 0;
} }
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -110,8 +110,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
disp_speed_step(); disp_speed_step();
break; break;
case ID_C_RETURN: case ID_C_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -49,8 +49,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_CLOUD_BIND_RETURN: case ID_CLOUD_BIND_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
case ID_CLOUD_RELEASE_BIND: case ID_CLOUD_RELEASE_BIND:
if (cloud_para.state == 0x12) { if (cloud_para.state == 0x12) {

View file

@ -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)) else if (DIALOG_IS(PAUSE_MESSAGE_OPTION))
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) { else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
#endif #endif
else if (DIALOG_IS(STORE_EEPROM_TIPS)) { else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
TERN_(EEPROM_SETTINGS, (void)settings.save()); TERN_(EEPROM_SETTINGS, (void)settings.save());
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
else if (DIALOG_IS(READ_EEPROM_TIPS)) { else if (DIALOG_IS(READ_EEPROM_TIPS)) {
TERN_(EEPROM_SETTINGS, (void)settings.load()); TERN_(EEPROM_SETTINGS, (void)settings.load());
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
else if (DIALOG_IS(REVERT_EEPROM_TIPS)) { else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
TERN_(EEPROM_SETTINGS, (void)settings.reset()); 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)) { else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
uiCfg.configWifi = true; uiCfg.configWifi = true;
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED)) else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED))
uiCfg.filament_heat_completed_load = true; uiCfg.filament_heat_completed_load = true;
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED))
uiCfg.filament_heat_completed_unload = true; uiCfg.filament_heat_completed_unload = true;
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) { else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
else if (DIALOG_IS(TYPE_UNBIND)) { else if (DIALOG_IS(TYPE_UNBIND)) {
cloud_unbind(); cloud_unbind();
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
#endif #endif
else { else {
clear_cur_ui(); goto_previous_ui();
draw_return_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)) { 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); thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) { else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
queue.enqueue_one(F("M410")); 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_flg = false;
uiCfg.filament_unloading_time_cnt = 0; uiCfg.filament_unloading_time_cnt = 0;
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
else { else {
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
} }
} }

View file

@ -106,8 +106,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
disp_ext_speed(); disp_ext_speed();
break; break;
case ID_E_RETURN: case ID_E_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -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_HIGH: fanPercent = 100; break;
case ID_F_MID: fanPercent = 50; break; case ID_F_MID: fanPercent = 50; break;
case ID_F_OFF: fanPercent = 0; 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)); thermalManager.set_fan_speed(0, map(fanPercent, 0, 100, 0, 255));
if (obj->mks_obj_id != ID_F_RETURN) disp_fan_value(); if (obj->mks_obj_id != ID_F_RETURN) disp_fan_value();

View file

@ -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)); planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -67,8 +67,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
queue.inject(F("M84XY")); queue.inject(F("M84XY"));
break; break;
case ID_H_RETURN: case ID_H_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -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) { else if (strcmp_P(txt, PSTR(LV_SYMBOL_CLOSE)) == 0) {
if (kb->event_cb != lv_kb_def_event_cb) { if (kb->event_cb != lv_kb_def_event_cb) {
lv_clear_keyboard(); goto_previous_ui();
draw_return_ui();
} }
else { else {
lv_kb_set_ta(kb, nullptr); // De-assign the text area to hide its cursor if needed 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) #if ENABLED(MKS_WIFI_MODULE)
case wifiName: case wifiName:
memcpy(uiCfg.wifi_name, ret_ta_txt, sizeof(uiCfg.wifi_name)); memcpy(uiCfg.wifi_name, ret_ta_txt, sizeof(uiCfg.wifi_name));
lv_clear_keyboard(); goto_previous_ui();
draw_return_ui();
break; break;
case wifiPassWord: case wifiPassWord:
memcpy(uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_name)); memcpy(uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_name));
lv_clear_keyboard(); goto_previous_ui();
draw_return_ui();
break; break;
case wifiConfig: case wifiConfig:
ZERO(uiCfg.wifi_name); 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]; uint8_t buf[100];
strncpy((char *)buf, ret_ta_txt, sizeof(buf)); strncpy((char *)buf, ret_ta_txt, sizeof(buf));
update_gcode_command(AUTO_LEVELING_COMMAND_ADDR, buf); update_gcode_command(AUTO_LEVELING_COMMAND_ADDR, buf);
lv_clear_keyboard(); goto_previous_ui();
draw_return_ui();
break; break;
case GCodeCommand: case GCodeCommand:
if (ret_ta_txt[0] && !queue.ring_buffer.full(3)) { if (ret_ta_txt[0] && !queue.ring_buffer.full(3)) {

View file

@ -83,8 +83,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
disp_move_dist(); disp_move_dist();
break; break;
case ID_M_RETURN: case ID_M_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
return; return;
} }
disp_cur_pos(); disp_cur_pos();

View file

@ -453,8 +453,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
case ID_NUM_CONFIRM: case ID_NUM_CONFIRM:
last_disp_state = NUMBER_KEY_UI; last_disp_state = NUMBER_KEY_UI;
if (strlen(key_value) != 0) set_value_confirm(); if (strlen(key_value) != 0) set_value_confirm();
lv_clear_number_key(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -90,8 +90,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
lv_draw_change_speed(); lv_draw_change_speed();
break; break;
case ID_O_RETURN: case ID_O_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
case ID_O_POWER_OFF: case ID_O_POWER_OFF:
if (gCfgItems.finish_power_off) { if (gCfgItems.finish_power_off) {

View file

@ -159,8 +159,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
disp_desire_temp(); disp_desire_temp();
break; break;
case ID_P_RETURN: case ID_P_RETURN:
clear_cur_ui(); goto_previous_ui();
draw_return_ui();
break; break;
case ID_P_ABS: case ID_P_ABS:
if (uiCfg.curTempType == 0) { if (uiCfg.curTempType == 0) {

View file

@ -99,8 +99,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_TC_RETURN: case ID_TC_RETURN:
TERN_(MKS_TEST, current_disp_ui = 1); TERN_(MKS_TEST, current_disp_ui = 1);
lv_clear_touch_calibration_screen(); goto_previous_ui();
draw_return_ui();
break; break;
} }
} }

View file

@ -54,8 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_MANUAL_POS_RETURN: case ID_MANUAL_POS_RETURN:
uiCfg.para_ui_page = false; uiCfg.para_ui_page = false;
lv_clear_tramming_pos_settings(); goto_previous_ui();
draw_return_ui();
return; return;
case ID_MANUAL_POS_X1: case ID_MANUAL_POS_X1:
value = level_pos_x1; value = level_pos_x1;

View file

@ -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 // Set the same image for both Released and Pressed
void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src) { void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src) {
lv_imgbtn_set_src(imgbtn, LV_BTN_STATE_REL, src); lv_imgbtn_set_src(imgbtn, LV_BTN_STATE_REL, src);

View file

@ -467,6 +467,7 @@ void lv_eom_hook(void *);
void GUI_RefreshPage(); void GUI_RefreshPage();
void clear_cur_ui(); void clear_cur_ui();
void draw_return_ui(); void draw_return_ui();
void goto_previous_ui();
void sd_detection(); void sd_detection();
void gCfg_to_spiFlah(); void gCfg_to_spiFlah();
void print_time_count(); void print_time_count();

View file

@ -47,8 +47,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_WIFI_RETURN: case ID_WIFI_RETURN:
lv_clear_wifi_settings(); goto_previous_ui();
draw_return_ui();
break; break;
case ID_WIFI_MODEL: case ID_WIFI_MODEL:
if (gCfgItems.wifi_mode_sel == AP_MODEL) { if (gCfgItems.wifi_mode_sel == AP_MODEL) {