From b586a30e7b0c22b962014a6fcc6041582a6d17ed Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sat, 24 Oct 2020 19:28:31 -0300 Subject: [PATCH] More LVGL UI code reduction (#19879) --- .../lcd/extui/lib/mks_ui/SPIFlashStorage.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_about.cpp | 12 +---------- .../lib/mks_ui/draw_acceleration_settings.cpp | 11 +--------- .../lib/mks_ui/draw_advance_settings.cpp | 13 ++---------- .../draw_auto_level_offset_settings.cpp | 12 +---------- .../extui/lib/mks_ui/draw_baby_stepping.cpp | 13 +----------- .../extui/lib/mks_ui/draw_change_speed.cpp | 13 +----------- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 13 +----------- .../extui/lib/mks_ui/draw_eeprom_settings.cpp | 12 +---------- .../lib/mks_ui/draw_encoder_settings.cpp | 12 +---------- .../extui/lib/mks_ui/draw_error_message.cpp | 9 +-------- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 13 +----------- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp | 12 +---------- .../extui/lib/mks_ui/draw_filament_change.cpp | 13 +----------- .../lib/mks_ui/draw_filament_settings.cpp | 12 +---------- Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp | 13 +----------- .../draw_homing_sensitivity_settings.cpp | 10 +--------- .../extui/lib/mks_ui/draw_jerk_settings.cpp | 10 +--------- .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 19 +++++------------- .../lcd/extui/lib/mks_ui/draw_language.cpp | 15 +------------- .../extui/lib/mks_ui/draw_level_settings.cpp | 12 ++--------- .../extui/lib/mks_ui/draw_machine_para.cpp | 12 +---------- .../lib/mks_ui/draw_machine_settings.cpp | 13 +----------- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 11 +--------- .../mks_ui/draw_manual_level_pos_settings.cpp | 9 +-------- .../lib/mks_ui/draw_max_feedrate_settings.cpp | 10 +--------- .../extui/lib/mks_ui/draw_motor_settings.cpp | 14 ++----------- .../lcd/extui/lib/mks_ui/draw_move_motor.cpp | 13 +----------- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 12 +---------- .../lcd/extui/lib/mks_ui/draw_operation.cpp | 12 +---------- .../extui/lib/mks_ui/draw_pause_position.cpp | 10 +--------- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 12 +---------- .../lcd/extui/lib/mks_ui/draw_print_file.cpp | 5 +---- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 10 +--------- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 7 +------ Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp | 13 +----------- .../extui/lib/mks_ui/draw_step_settings.cpp | 10 +--------- .../lib/mks_ui/draw_tmc_current_settings.cpp | 10 +--------- .../mks_ui/draw_tmc_step_mode_settings.cpp | 10 +--------- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 15 +------------- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 20 ++++++++++++++++++- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp | 12 +---------- .../lcd/extui/lib/mks_ui/draw_wifi_list.cpp | 12 +---------- .../extui/lib/mks_ui/draw_wifi_settings.cpp | 12 +---------- .../lcd/extui/lib/mks_ui/draw_wifi_tips.cpp | 9 +-------- .../src/lcd/extui/lib/mks_ui/wifiSerial.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/wifi_upload.cpp | 8 ++------ 48 files changed, 74 insertions(+), 462 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp index e028b3e6ec..11c5f816b0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp @@ -185,7 +185,7 @@ void SPIFlashStorage::loadPage(uint8_t* buffer) { // char fname[256]; // snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage); // FILE *fp = fopen(fname, "rb"); - // if (fp != nullptr) { + // if (fp) { // fread(buffer, 1, SPI_FLASH_PageSize, fp); // fclose(fp); // } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp index b5e59692fd..34168574ec 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp @@ -49,17 +49,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_about(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ABOUT_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = ABOUT_UI; - } - disp_state = ABOUT_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(ABOUT_UI); // Create an Image button lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_A_RETURN); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp index 9b86929bca..ffb6f01579 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp @@ -108,16 +108,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_acceleration_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ACCELERATION_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = ACCELERATION_UI; - } - disp_state = ACCELERATION_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AccelerationConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(ACCELERATION_UI, machine_menu.AccelerationConfTitle); if (uiCfg.para_ui_page != 1) { sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.acceleration); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp index 5c3b067682..dd6e484921 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp @@ -40,6 +40,7 @@ enum { }; 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_ADVANCE_RETURN: lv_clear_advance_settings(); @@ -69,17 +70,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_advance_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI; - } - disp_state = ADVANCED_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AdvancedConfTitle); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(ADVANCED_UI, machine_menu.AdvancedConfTitle); int index = 0; lv_screen_menu_item(scr, machine_menu.PausePosition, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_POS, index++); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp index 8e40956c0f..3b39debe57 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp @@ -65,17 +65,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_auto_level_offset_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI; - } - disp_state = NOZZLE_PROBE_OFFSET_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.OffsetConfTitle); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(NOZZLE_PROBE_OFFSET_UI, machine_menu.OffsetConfTitle); sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0)); lv_screen_menu_item_1_edit(scr, machine_menu.Xoffset, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_OFFSET_X, 0, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp index b0a004ed9e..5f489162b0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp @@ -112,18 +112,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_baby_stepping(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != BABY_STEP_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = BABY_STEP_UI; - } - disp_state = BABY_STEP_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(BABY_STEP_UI); lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_BABY_STEP_X_P); lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_X_N); lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_BABY_STEP_Y_P); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp index 05158b181c..a5100776ac 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp @@ -126,18 +126,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_change_speed(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != CHANGE_SPEED_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = CHANGE_SPEED_UI; - } - disp_state = CHANGE_SPEED_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(CHANGE_SPEED_UI); // Create an Image button lv_big_button_create(scr, "F:/bmp_Add.bin", speed_menu.add, INTERVAL_V, titleHeight, event_handler, ID_C_ADD); lv_big_button_create(scr, "F:/bmp_Dec.bin", speed_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_C_DEC); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index a18964919a..67ed24d8c0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -211,19 +211,8 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { void lv_draw_dialog(uint8_t type) { lv_obj_t *btnOk = nullptr, *btnCancel = nullptr; - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI; - } - disp_state = DIALOG_UI; - uiCfg.dialogType = type; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(DIALOG_UI); lv_obj_t *labelDialog = lv_label_create_empty(scr); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp index 5e5c6b4907..924c69536a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp @@ -66,17 +66,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_eeprom_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI; - } - disp_state = EEPROM_SETTINGS_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(EEPROM_SETTINGS_UI); lv_screen_menu_item(scr, eeprom_menu.revert, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_EEPROM_REVERT, 0); lv_screen_menu_item(scr, eeprom_menu.store, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_EEPROM_STORE, 1); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_EEPROM_RETURN, true); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp index 35bbc6f061..c9c2d4f28d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp @@ -55,18 +55,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_encoder_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI; - } - disp_state = ENCODER_SETTINGS_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.EncoderConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(ENCODER_SETTINGS_UI, machine_menu.EncoderConfTitle); buttonEncoderState = lv_screen_menu_item_onoff(scr, machine_menu.EncoderConfText, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ENCODER_STATE, 0, gCfgItems.encoder_enable); - lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ENCODER_RETURN, true); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp index e82229c909..a484f14087 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp @@ -41,15 +41,8 @@ static lv_obj_t *scr; void lv_draw_error_message(PGM_P const msg) { #if 0 static lv_obj_t *message = nullptr, *kill_message = nullptr, *reset_tips = nullptr; - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ERROR_MESSAGE_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = ERROR_MESSAGE_UI; - } - disp_state = ERROR_MESSAGE_UI; - scr = lv_screen_create(); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(ERROR_MESSAGE_UI, ""); if (msg) { message = lv_label_create(scr, msg); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 9f803afea9..6a1c0c4fb3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -122,18 +122,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_extrusion(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EXTRUSION_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = EXTRUSION_UI; - } - disp_state = EXTRUSION_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(EXTRUSION_UI); // Create image buttons lv_obj_t *buttonAdd = lv_big_button_create(scr, "F:/bmp_in.bin", extrude_menu.in, INTERVAL_V, titleHeight, event_handler, ID_E_ADD); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp index 5306ab3a89..5453bbf86b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp @@ -89,18 +89,8 @@ void lv_draw_fan(void) { #if HAS_FAN fanSpeed = thermalManager.fan_speed[0]; #endif - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FAN_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = FAN_UI; - } - disp_state = FAN_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(FAN_UI); // Create an Image button buttonAdd = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index a3f18cf9cb..1db11a20e6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -112,18 +112,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_filament_change(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI; - } - disp_state = FILAMENTCHANGE_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(FILAMENTCHANGE_UI); // Create an Image button lv_obj_t *buttonIn = lv_big_button_create(scr, "F:/bmp_in.bin", filament_menu.in, INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN); lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp index ecaeefee56..2c9c3882f0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp @@ -89,17 +89,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_filament_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI; - } - disp_state = FILAMENT_SETTINGS_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.FilamentConfTitle); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(FILAMENT_SETTINGS_UI, machine_menu.FilamentConfTitle); if (uiCfg.para_ui_page != 1) { sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length); 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 92510cbc8e..646091bd8b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp @@ -77,18 +77,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_home(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ZERO_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = ZERO_UI; - } - disp_state = ZERO_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(ZERO_UI); lv_big_button_create(scr, "F:/bmp_zeroAll.bin", home_menu.home_all, INTERVAL_V, titleHeight, event_handler, ID_H_ALL); lv_big_button_create(scr, "F:/bmp_zeroX.bin", home_menu.home_x, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_H_X); lv_big_button_create(scr, "F:/bmp_zeroY.bin", home_menu.home_y, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_H_Y); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp index e01208605f..cbd028b60a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp @@ -75,15 +75,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_homing_sensitivity_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI; - } - disp_state = HOMING_SENSITIVITY_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.HomingSensitivityConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(HOMING_SENSITIVITY_UI, machine_menu.HomingSensitivityConfTitle); sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); lv_screen_menu_item_1_edit(scr, machine_menu.X_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_SENSITIVITY_X, 0, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp index 5b8f7b45fd..f07c2761b6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp @@ -71,15 +71,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_jerk_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = JERK_UI; - } - disp_state = JERK_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.JerkConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(JERK_UI, machine_menu.JerkConfTitle); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]); lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp index 0debf8fa8f..7313ed531f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp @@ -84,7 +84,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return; const char * txt = lv_btnm_get_active_btn_text(kb); - if (txt == nullptr) return; + if (!txt) return; // Do the corresponding action according to the text of the button if (strcmp(txt, "abc") == 0) { @@ -169,14 +169,13 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { default: break; } } - else { - lv_kb_set_ta(kb, nullptr); /*De-assign the text area to hide it cursor if needed*/ - } + else + lv_kb_set_ta(kb, nullptr); // De-assign the text area to hide it cursor if needed return; } /*Add the characters to the text area if set*/ - if (ext->ta == nullptr) return; + if (!ext->ta) return; if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) lv_ta_add_char(ext->ta, '\n'); @@ -213,15 +212,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { } void lv_draw_keyboard() { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != KEY_BOARD_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = KEY_BOARD_UI; - } - disp_state = KEY_BOARD_UI; - - scr = lv_screen_create(); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(KEY_BOARD_UI, ""); /*Create styles for the keyboard*/ static lv_style_t rel_style, pr_style; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp index 1ff60d9b9b..8f7279f5dd 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp @@ -188,19 +188,7 @@ static void disp_language(uint8_t language, uint8_t state) { } void lv_draw_language(void) { - - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LANGUAGE_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = LANGUAGE_UI; - } - disp_state = LANGUAGE_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(LANGUAGE_UI); // Create image buttons buttonCN = lv_big_button_create(scr, "F:/bmp_simplified_cn.bin", language_menu.chinese_s, INTERVAL_V, titleHeight, event_handler, ID_CN); lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW); @@ -211,7 +199,6 @@ void lv_draw_language(void) { buttonFR = lv_big_button_create(scr, "F:/bmp_french.bin", language_menu.french, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FR); buttonIT = lv_big_button_create(scr, "F:/bmp_italy.bin", language_menu.italy, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_IT); 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_L_RETURN); - disp_language(gCfgItems.language, SELECTED); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp index 7bd2b83ace..b1ce90f266 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp @@ -39,6 +39,7 @@ enum { }; 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_LEVEL_RETURN: lv_clear_level_settings(); @@ -63,16 +64,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_level_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI; - } - disp_state = LEVELING_PARA_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(LEVELING_PARA_UI, machine_menu.LevelingParaConfTitle); lv_screen_menu_item(scr, machine_menu.LevelingManuPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0); lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1); #if HAS_BED_PROBE diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp index 45aabae079..5f81d7b369 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp @@ -66,17 +66,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_machine_para(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI; - } - disp_state = MACHINE_PARA_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(MACHINE_PARA_UI); lv_screen_menu_item(scr, MachinePara_menu.MachineSetting, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PARA_MACHINE, 0); lv_screen_menu_item(scr, MachinePara_menu.MotorSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PARA_MOTOR, 1); lv_screen_menu_item(scr, MachinePara_menu.leveling, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PARA_LEVEL, 2); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp index 000b122b34..deeb51ab0f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp @@ -63,18 +63,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_machine_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_SETTINGS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_SETTINGS_UI; - } - disp_state = MACHINE_SETTINGS_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MachineConfigTitle); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(MACHINE_SETTINGS_UI, machine_menu.MachineConfigTitle); lv_screen_menu_item(scr, machine_menu.AccelerationConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MACHINE_ACCELERATION, 0); lv_screen_menu_item(scr, machine_menu.MaxFeedRateConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MACHINE_FEEDRATE, 1); #if HAS_CLASSIC_JERK diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp index 0513437353..3c8d562913 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -118,16 +118,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_manualLevel(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_UI; - } - disp_state = LEVELING_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(LEVELING_UI); // Create an Image button lv_obj_t *buttonPoint1 = lv_big_button_create(scr, "F:/bmp_leveling1.bin", leveling_menu.position1, INTERVAL_V, titleHeight, event_handler, ID_M_POINT1); lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp index 8dedcd4c7b..6f64badf8b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp @@ -121,15 +121,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_manual_level_pos_settings(void) { char buf2[50]; - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI; - } - disp_state = MANUAL_LEVELING_POSIGION_UI; - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(MANUAL_LEVELING_POSIGION_UI, machine_menu.LevelingParaConfTitle); if (uiCfg.para_ui_page != 1) { sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp index 5088e859c0..60efda8b27 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp @@ -90,15 +90,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_max_feedrate_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = MAXFEEDRATE_UI; - } - disp_state = MAXFEEDRATE_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MaxFeedRateConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(MAXFEEDRATE_UI, machine_menu.MaxFeedRateConfTitle); if (uiCfg.para_ui_page != 1) { sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp index 697b7de345..61cefd7615 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp @@ -73,19 +73,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_motor_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI; - } - disp_state = MOTOR_SETTINGS_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MotorConfTitle); - - lv_refr_now(lv_refr_get_disp_refreshing()); - int index = 0; + + scr = lv_screen_create(MOTOR_SETTINGS_UI, machine_menu.MotorConfTitle); lv_screen_menu_item(scr, machine_menu.StepsConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MOTOR_STEPS, index++); #if USE_SENSORLESS lv_screen_menu_item(scr, machine_menu.HomingSensitivityConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_HOME_SENSE, index); 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 0718ffd86e..30f2a00422 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 @@ -115,18 +115,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_move_motor(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOVE_MOTOR_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = MOVE_MOTOR_UI; - } - disp_state = MOVE_MOTOR_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + 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); lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW); lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_X_N); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp index 9ed4d60139..0989b95f82 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp @@ -662,17 +662,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_number_key(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NUMBER_KEY_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = NUMBER_KEY_UI; - } - disp_state = NUMBER_KEY_UI; - - scr = lv_screen_create(); - - //(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(NUMBER_KEY_UI, ""); buttonValue = lv_btn_create(scr, 92, 40, 296, 40, event_handler, ID_NUM_KEY1, &style_num_text); labelValue = lv_label_create_empty(buttonValue); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp index 16f50c16c5..07df598d8f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp @@ -129,17 +129,7 @@ void lv_draw_operation(void) { *buttonBabyStep = nullptr, *label_BabyStep = nullptr, *label_Filament = nullptr; - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = OPERATE_UI; - } - disp_state = OPERATE_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(OPERATE_UI); // Create image buttons lv_obj_t *buttonPreHeat = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp index 930773b129..a324aef793 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp @@ -65,15 +65,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_pause_position(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = PAUSE_POS_UI; - } - disp_state = PAUSE_POS_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.PausePosText); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(PAUSE_POS_UI, machine_menu.PausePosText); sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX); lv_screen_menu_item_1_edit(scr, machine_menu.xPos, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_X, 0, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index a222c7adbf..0e869e67c4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -158,17 +158,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_preHeat(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PRE_HEAT_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = PRE_HEAT_UI; - } - disp_state = PRE_HEAT_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(PRE_HEAT_UI); // Create image buttons lv_big_button_create(scr, "F:/bmp_Add.bin", preheat_menu.add, INTERVAL_V, titleHeight, event_handler, ID_P_ADD); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp index 141ea4cd6f..cfd06cf09f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp @@ -252,10 +252,7 @@ static char test_public_buf_l[40]; void disp_gcode_icon(uint8_t file_num) { uint8_t i; - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(MAIN_UI, ""); // Create image buttons buttonPageUp = lv_imgbtn_create(scr, "F:/bmp_pageUp.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_UP); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 8191d5fb65..7614f1e99d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -121,15 +121,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_printing(void) { disp_state_stack._disp_index = 0; ZERO(disp_state_stack._disp_state); - disp_state_stack._disp_state[disp_state_stack._disp_index] = PRINTING_UI; - - disp_state = PRINTING_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(PRINTING_UI); // Create image buttons lv_obj_t *buttonExt1 = lv_img_create(scr, nullptr); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 3e8a9aad5b..cee02cc47a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -122,13 +122,8 @@ void lv_draw_ready_print(void) { disp_state_stack._disp_index = 0; ZERO(disp_state_stack._disp_state); - disp_state_stack._disp_state[disp_state_stack._disp_index] = PRINT_READY_UI; - - disp_state = PRINT_READY_UI; - - scr = lv_screen_create(); + scr = lv_screen_create(PRINT_READY_UI, ""); //lv_obj_set_hidden(scr, true); - lv_refr_now(lv_refr_get_disp_refreshing()); if (mks_test_flag == 0x1E) { //(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp index 46ea04deaf..b2211e5631 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp @@ -126,18 +126,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_set(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = SET_UI; - } - disp_state = SET_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(SET_UI); lv_big_button_create(scr, "F:/bmp_eeprom_settings.bin", set_menu.eepromSet, INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET); lv_big_button_create(scr, "F:/bmp_fan.bin", set_menu.fan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN); lv_big_button_create(scr, "F:/bmp_about.bin", set_menu.about, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp index b2b1b00c3b..022c4d30f9 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp @@ -90,15 +90,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_step_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != STEPS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = STEPS_UI; - } - disp_state = STEPS_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.StepsConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(STEPS_UI, machine_menu.StepsConfTitle); if (uiCfg.para_ui_page != 1) { sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp index 777b93d1f5..aaf3073e3d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp @@ -103,15 +103,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_tmc_current_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_CURRENT_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = TMC_CURRENT_UI; - } - disp_state = TMC_CURRENT_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcCurrentConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(TMC_CURRENT_UI, machine_menu.TmcCurrentConfTitle); float milliamps; if (uiCfg.para_ui_page != 1) { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp index 3814dacfe1..53d7e35382 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp @@ -112,15 +112,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_tmc_step_mode_settings(void) { buttonXState = buttonYState = buttonZState = buttonE0State = buttonE1State = nullptr; - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = TMC_MODE_UI; - } - disp_state = TMC_MODE_UI; - - scr = lv_screen_create(); - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcStepModeConfTitle); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(TMC_MODE_UI, machine_menu.TmcStepModeConfTitle); bool stealth_X = false, stealth_Y = false, stealth_Z = false, stealth_E0 = false, stealth_E1 = false; #if AXIS_HAS_STEALTHCHOP(X) 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 2bbd544cc8..3a9d78741a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -99,24 +99,11 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_tool(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = TOOL_UI; - } - disp_state = TOOL_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); - + scr = lv_screen_create(TOOL_UI); lv_big_button_create(scr, "F:/bmp_preHeat.bin", tool_menu.preheat, INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT); lv_big_button_create(scr, "F:/bmp_extruct.bin", tool_menu.extrude, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT); - lv_big_button_create(scr, "F:/bmp_mov.bin", tool_menu.move, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV); lv_big_button_create(scr, "F:/bmp_zero.bin", tool_menu.home, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME); - lv_big_button_create(scr, "F:/bmp_leveling.bin", tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling), INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING); lv_big_button_create(scr, "F:/bmp_filamentchange.bin", tool_menu.filament, BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT); 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_T_RETURN); 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 2de5bf25e1..50c49999af 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -1628,11 +1628,29 @@ void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style) { } // Create a screen -lv_obj_t* lv_screen_create() { +lv_obj_t* lv_screen_create(DISP_STATE newScreenType, const char* title) { lv_obj_t *scr = lv_obj_create(nullptr, nullptr); lv_obj_set_style(scr, &tft_style_scr); lv_scr_load(scr); lv_obj_clean(scr); + + // breadcrumbs + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != newScreenType) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = newScreenType; + } + disp_state = newScreenType; + lv_refr_now(lv_refr_get_disp_refreshing()); + + // title + lv_obj_t *titleLabel = nullptr; + if (!title) + titleLabel = lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); + else if (title[0] != '\0') + titleLabel = lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, title); + if (titleLabel) + lv_obj_set_style(titleLabel, &tft_style_label_rel); + return scr; } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h index 479166cd8f..3e3a4073d3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -468,7 +468,7 @@ void lv_btn_use_label_style(lv_obj_t *btn); void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style); // Create a screen -lv_obj_t* lv_screen_create(); +lv_obj_t* lv_screen_create(DISP_STATE newScreenType, const char* title = nullptr); // Create an empty label lv_obj_t* lv_label_create_empty(lv_obj_t *par); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp index e8214cad3a..313abd4545 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp @@ -58,17 +58,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_wifi(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI; - } - disp_state = WIFI_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(WIFI_UI); // Create an Image button lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp index cb72469bd4..c826e36d42 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp @@ -89,17 +89,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_wifi_list(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI; - } - disp_state = WIFI_LIST_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(WIFI_LIST_UI); lv_obj_t *buttonDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_WL_DOWN); lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + (OTHER_BTN_YPIEL + INTERVAL_H) * 2, event_handler, ID_WL_RETURN); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp index 0c4fe61132..441720df82 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp @@ -94,17 +94,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_wifi_settings(void) { - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI; - } - disp_state = WIFI_SETTINGS_UI; - - scr = lv_screen_create(); - - (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.WifiConfTitle); - - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(WIFI_SETTINGS_UI, machine_menu.WifiConfTitle); lv_obj_t *labelModelText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.wifiMode); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp index 57f2584fa3..a9e5624996 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp @@ -39,14 +39,7 @@ tips_menu_def tips_menu; void lv_draw_wifi_tips(void) { static lv_obj_t *text_tips,*wifi_name; - if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) { - disp_state_stack._disp_index++; - disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_TIPS_UI; - } - disp_state = WIFI_TIPS_UI; - - scr = lv_screen_create(); - lv_refr_now(lv_refr_get_disp_refreshing()); + scr = lv_screen_create(WIFI_TIPS_UI, ""); wifi_name = lv_label_create(scr, (const char *)wifi_list.wifiName[wifi_list.nameIndex]); lv_obj_align(wifi_name, nullptr, LV_ALIGN_CENTER, 0, -20); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp index 6e15deffae..16b65c7ea3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp @@ -53,7 +53,7 @@ WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) { /* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict * on this GPIO bit. */ static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { - if (dev != nullptr) timer_set_mode(dev, ch, TIMER_DISABLED); + if (dev) timer_set_mode(dev, ch, TIMER_DISABLED); } #elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4 #define disable_timer_if_necessary(dev, ch) ((void)0) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp index 1ab186a6be..097263a655 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp @@ -533,12 +533,8 @@ EspUploadResult flashFinish(signed char reboot) { // Compute the checksum of a block of data uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) { - if (data != nullptr) { - while (dataLen--) { - cksum ^= (uint16_t)*data++; - } - } - return(cksum); + if (data) while (dataLen--) cksum ^= (uint16_t)*data++; + return cksum; } EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {