Skip to content

Commit

Permalink
🎨 Add MKS UI goto_previous_ui
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 25, 2021
1 parent af08f16 commit de77dfc
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 57 deletions.
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
30 changes: 10 additions & 20 deletions Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
}
}

Expand All @@ -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"));
Expand All @@ -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();
}
}

Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/mks_ui/draw_fan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_home.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
12 changes: 4 additions & 8 deletions Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/lcd/extui/mks_ui/draw_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/extui/mks_ui/draw_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_wifi_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit de77dfc

Please sign in to comment.