From 072f996af70b5ac635893eca2d4bd4bbb4f00acc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Oct 2020 12:45:27 -0500 Subject: [PATCH] General cleanup, mostly MKS UI (#19825) --- .gitignore | 1 - Marlin/src/inc/Conditionals_LCD.h | 10 +- .../src/lcd/extui/lib/mks_ui/draw_about.cpp | 7 +- .../lib/mks_ui/draw_acceleration_settings.cpp | 6 +- .../lib/mks_ui/draw_advance_settings.cpp | 6 +- .../draw_auto_level_offset_settings.cpp | 7 +- .../extui/lib/mks_ui/draw_baby_stepping.cpp | 10 +- .../extui/lib/mks_ui/draw_change_speed.cpp | 11 +- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 12 +- .../extui/lib/mks_ui/draw_eeprom_settings.cpp | 6 +- .../lib/mks_ui/draw_encoder_settings.cpp | 48 +- .../extui/lib/mks_ui/draw_error_message.cpp | 10 +- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 14 +- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp | 10 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 11 +- .../lib/mks_ui/draw_filament_settings.cpp | 7 +- Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp | 9 +- .../draw_homing_sensitivity_settings.cpp | 13 +- .../extui/lib/mks_ui/draw_jerk_settings.cpp | 6 +- .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 5 +- .../lcd/extui/lib/mks_ui/draw_language.cpp | 6 +- .../extui/lib/mks_ui/draw_level_settings.cpp | 6 +- .../extui/lib/mks_ui/draw_machine_para.cpp | 6 +- .../lib/mks_ui/draw_machine_settings.cpp | 6 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 9 +- .../mks_ui/draw_manual_level_pos_settings.cpp | 6 +- .../lib/mks_ui/draw_max_feedrate_settings.cpp | 6 +- .../extui/lib/mks_ui/draw_motor_settings.cpp | 6 +- .../lcd/extui/lib/mks_ui/draw_move_motor.cpp | 11 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 14 +- .../lcd/extui/lib/mks_ui/draw_operation.cpp | 25 +- .../extui/lib/mks_ui/draw_pause_message.cpp | 4 +- .../extui/lib/mks_ui/draw_pause_position.cpp | 6 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 14 +- .../lcd/extui/lib/mks_ui/draw_print_file.cpp | 9 +- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 30 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 8 +- Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp | 12 +- .../extui/lib/mks_ui/draw_step_settings.cpp | 6 +- .../lib/mks_ui/draw_tmc_current_settings.cpp | 7 +- .../mks_ui/draw_tmc_step_mode_settings.cpp | 9 +- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 6 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 58 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 8 +- Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp | 9 +- .../lcd/extui/lib/mks_ui/draw_wifi_list.cpp | 7 +- .../extui/lib/mks_ui/draw_wifi_settings.cpp | 54 +- .../lcd/extui/lib/mks_ui/draw_wifi_tips.cpp | 7 +- .../src/lcd/extui/lib/mks_ui/irq_overrid.cpp | 3 +- .../src/lcd/extui/lib/mks_ui/pic_manager.cpp | 4 +- .../extui/lib/mks_ui/printer_operation.cpp | 28 +- .../lib/mks_ui/tft_lvgl_configuration.cpp | 63 +- .../src/lcd/extui/lib/mks_ui/wifiSerial.cpp | 6 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 698 ++++++++---------- Marlin/src/pins/esp32/pins_E4D.h | 30 +- Marlin/src/pins/pins.h | 1 + platformio.ini | 2 - 57 files changed, 616 insertions(+), 783 deletions(-) diff --git a/.gitignore b/.gitignore index c163d339df..1ac1abbe15 100755 --- a/.gitignore +++ b/.gitignore @@ -77,7 +77,6 @@ tags *.out *.app - # # C # diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b22c608658..6f632aa569 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -341,7 +341,7 @@ #define DOGLCD #define IS_ULTIPANEL 1 #define DELAYED_BACKLIGHT_INIT -#elif ENABLED(TFT_LVGL_UI) +#elif HAS_TFT_LVGL_UI #define DELAYED_BACKLIGHT_INIT #endif @@ -957,16 +957,16 @@ // FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h #if ENABLED(TFT_INTERFACE_FSMC) #define HAS_FSMC_TFT 1 - #if ENABLED(TFT_CLASSIC_UI) + #if TFT_SCALED_DOGLCD #define HAS_FSMC_GRAPHICAL_TFT 1 - #elif ENABLED(TFT_LVGL_UI) + #elif HAS_TFT_LVGL_UI #define HAS_TFT_LVGL_UI_FSMC 1 #endif #elif ENABLED(TFT_INTERFACE_SPI) #define HAS_SPI_TFT 1 - #if ENABLED(TFT_CLASSIC_UI) + #if TFT_SCALED_DOGLCD #define HAS_SPI_GRAPHICAL_TFT 1 - #elif ENABLED(TFT_LVGL_UI) + #elif HAS_TFT_LVGL_UI #define HAS_TFT_LVGL_UI_SPI 1 #endif #endif 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 34b7427860..68d1993b6f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp @@ -23,15 +23,14 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" -#include "../../../../module/temperature.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -94,7 +93,7 @@ void lv_draw_about(void) { // Create a label on the image button label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } 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 a30c99dba0..e362e5bff1 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 @@ -23,11 +23,11 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -383,7 +383,7 @@ void lv_draw_acceleration_settings(void) { //lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); //lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { lv_label_set_text(labelTurnPage, machine_menu.next); 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 5b1b241716..f81fe6c728 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 @@ -23,10 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -302,7 +302,7 @@ void lv_draw_advance_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); 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 bb6b45aebe..be2015ed9e 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 @@ -23,12 +23,11 @@ #if BOTH(HAS_TFT_LVGL_UI, HAS_BED_PROBE) -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" -#include "../../../../module/planner.h" #include "../../../../module/probe.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -172,7 +171,7 @@ void lv_draw_auto_level_offset_settings(void) { } #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0)); lv_label_set_text(labelXValue, 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 70564c036c..6891060274 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 @@ -23,12 +23,12 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../gcode/queue.h" #include "../../../../gcode/gcode.h" +#include "../../../../inc/MarlinConfig.h" #if HAS_BED_PROBE #include "../../../../module/probe.h" @@ -52,7 +52,7 @@ static float babystep_dist=0.01; static uint8_t has_adjust_z = 0; static void event_handler(lv_obj_t * obj, lv_event_t event) { - char baby_buf[30]={0}; + char baby_buf[30] = { 0 }; switch (obj->mks_obj_id) { case ID_BABY_STEP_X_P: if (event == LV_EVENT_CLICKED) { @@ -259,7 +259,7 @@ void lv_draw_baby_stepping(void) { labelV = lv_label_create(buttonV, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelXI, move_menu.x_add); lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -318,7 +318,7 @@ void disp_baby_step_dist() { lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_1.bin"); lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_1.bin"); } - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if ((int)(100 * babystep_dist) == 1) { lv_label_set_text(labelV, move_menu.step_001mm); lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 c60000afae..f9399b8a45 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 @@ -23,16 +23,15 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" -#include "../../../../module/temperature.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -239,7 +238,7 @@ void lv_draw_change_speed(void) { labelStep = lv_label_create(buttonStep, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelAdd, speed_menu.add); lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -281,7 +280,7 @@ void disp_speed_step() { lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_percent.bin"); lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_percent.bin"); } - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.stepPrintSpeed == 1) { lv_label_set_text(labelStep, speed_menu.step_1percent); lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -337,7 +336,7 @@ void disp_speed_type() { lv_obj_refresh_ext_draw_pad(buttonExt); lv_obj_refresh_ext_draw_pad(buttonMov); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelMov, speed_menu.move); lv_obj_align(labelMov, buttonMov, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 c848323010..489d8466ce 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -28,20 +28,20 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" #include "../../../../sd/cardreader.h" #include "../../../../gcode/queue.h" #include "../../../../module/temperature.h" #include "../../../../module/planner.h" #include "../../../../gcode/gcode.h" +#include "../../../../inc/MarlinConfig.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" @@ -50,7 +50,6 @@ #if ENABLED(PARK_HEAD_ON_PAUSE) #include "../../../../feature/pause.h" #endif -#include "../../../../gcode/gcode.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -58,8 +57,7 @@ static lv_obj_t * tempText1; static lv_obj_t * filament_bar; extern uint8_t sel_id; -extern uint8_t once_flag; -extern uint8_t gcode_preview_over; +extern bool once_flag, gcode_preview_over; extern int upload_result ; extern uint32_t upload_time; extern uint32_t upload_size; @@ -82,7 +80,7 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { lv_draw_printing(); #if ENABLED(SDSUPPORT) - if (gcode_preview_over != 1) { + if (!gcode_preview_over) { char *cur_name; cur_name = strrchr(list_file.file_name[sel_id], '/'); @@ -109,7 +107,7 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { #if ENABLED(POWER_LOSS_RECOVERY) recovery.prepare(); #endif - once_flag = 0; + once_flag = false; } } #endif 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 ca7d2d1e31..08fdb007fc 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 @@ -23,10 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -191,7 +191,7 @@ void lv_draw_eeprom_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); 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 0ad2bb5f1d..1476fe0a74 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 @@ -23,15 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" -#include "../../../../module/planner.h" -#include "../../../../module/stepper/indirection.h" -#include "../../../../feature/tmc_util.h" -#include "../../../../gcode/gcode.h" -#include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" #if BUTTONS_EXIST(EN1, EN2) @@ -59,20 +54,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - if (gCfgItems.encoder_enable) { - gCfgItems.encoder_enable = false; - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); - lv_label_set_text(labelEncoderState, machine_menu.disable); - update_spi_flash(); - } - else { - gCfgItems.encoder_enable = true; - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); - lv_label_set_text(labelEncoderState, machine_menu.enable); - update_spi_flash(); - } + gCfgItems.encoder_enable ^= true; + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin"); + lv_label_set_text(labelEncoderState, machine_menu.enable); + update_spi_flash(); } break; } @@ -110,14 +96,8 @@ void lv_draw_encoder_settings(void) { buttonEncoderState = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonEncoderState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V); - if (gCfgItems.encoder_enable) { - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); - } - else { - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); - lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); - } + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin"); lv_obj_set_event_cb_mks(buttonEncoderState, event_handler, ID_ENCODER_STATE, NULL, 0); @@ -140,14 +120,8 @@ void lv_draw_encoder_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.encoder_enable) { - lv_label_set_text(labelEncoderState, machine_menu.enable); - lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); - } - else { - lv_label_set_text(labelEncoderState, machine_menu.disable); - lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); - } + lv_label_set_text(labelEncoderState, gCfgItems.encoder_enable ? machine_menu.enable : machine_menu.disable); + lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); 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 c21ee3612c..2a20fe39f4 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 @@ -23,18 +23,18 @@ #if HAS_TFT_LVGL_UI -#include "SPI_TFT.h" - -#include "lv_conf.h" #include "draw_ui.h" +#include + #include "tft_lvgl_configuration.h" -#include "mks_hardware_test.h" //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" +#include "SPI_TFT.h" +#include "mks_hardware_test.h" +#include "../../../../inc/MarlinConfig.h" static lv_obj_t * scr; 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 543202067f..4bd320b640 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -23,16 +23,16 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" #include "../../../../gcode/queue.h" +#include "../../../../inc/MarlinConfig.h" static lv_obj_t * scr; extern lv_group_t* g; @@ -235,7 +235,7 @@ void lv_draw_extrusion(void) { labelSpeed = lv_label_create(buttonSpeed, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelAdd, extrude_menu.in); lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -274,7 +274,7 @@ void disp_ext_type() { if (uiCfg.curSprayerChoose == 1) { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, extrude_menu.ext2); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } @@ -282,7 +282,7 @@ void disp_ext_type() { else { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, extrude_menu.ext1); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } @@ -303,7 +303,7 @@ void disp_ext_speed() { lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_normal.bin"); } - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.extruSpeed == 20) { lv_label_set_text(labelSpeed, extrude_menu.high); lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -377,7 +377,7 @@ void disp_ext_step() { lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_mm.bin"); } - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.extruStep == 1) { lv_label_set_text(labelStep, extrude_menu.step_1mm); lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 8cdc14964f..5d7bb335dc 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp @@ -23,17 +23,17 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../../Configuration.h" -#include "draw_ui.h" + #include "../../../../module/temperature.h" #include "../../../../gcode/queue.h" #include "../../../../gcode/gcode.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -209,7 +209,7 @@ void lv_draw_fan(void) { lv_obj_t *labelOff = lv_label_create(buttonOff, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelAdd, fan_menu.add); lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 83f9e53677..4c9060c6a2 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 @@ -23,15 +23,14 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" -#include "../../../../gcode/queue.h" #include "../../../../gcode/gcode.h" #include "../../../../module/motion.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -197,7 +196,7 @@ void lv_draw_filament_change(void) { labelType = lv_label_create(buttoType, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelIn, filament_menu.in); lv_obj_align(labelIn, buttonIn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -228,7 +227,7 @@ void disp_filament_type() { if (uiCfg.curSprayerChoose == 1) { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.ext2); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } @@ -236,7 +235,7 @@ void disp_filament_type() { else { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.ext1); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } 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 06ab35f3f0..377c44edb7 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 @@ -23,11 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" -#include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -279,7 +278,7 @@ void lv_draw_filament_settings(void) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { ZERO(public_buf_l); 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 22e05f0e00..c7264f2765 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp @@ -23,16 +23,17 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" #include "draw_ready_print.h" #include "draw_set.h" -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "draw_ui.h" + #include "../../../../gcode/queue.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -206,7 +207,7 @@ void lv_draw_home(void) { lv_obj_t *labelOffXY = lv_label_create(buttonOffXY, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelHomeAll, home_menu.home_all); lv_obj_align(labelHomeAll, buttonHomeAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 d22eeb157e..d819aa01f6 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 @@ -19,18 +19,15 @@ * along with this program. If not, see . * */ -#include "../../../../inc/MarlinConfigPre.h" +#include "../../../../inc/MarlinConfig.h" -#if HAS_TFT_LVGL_UI +#if HAS_TFT_LVGL_UI && USE_SENSORLESS -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" #include "../../../../module/probe.h" - -#if USE_SENSORLESS #include "../../../../module/stepper/indirection.h" #include "../../../../feature/tmc_util.h" @@ -222,7 +219,7 @@ void lv_draw_homing_sensitivity_settings(void) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); lv_label_set_text(labelXValue, public_buf_l); @@ -257,6 +254,4 @@ void lv_clear_homing_sensitivity_settings() { lv_obj_del(scr); } -#endif // USE_SENSORLESS - #endif // HAS_TFT_LVGL_UI && USE_SENSORLESS 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 8c359233e6..65649b793e 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 @@ -23,11 +23,11 @@ #if BOTH(HAS_TFT_LVGL_UI, HAS_CLASSIC_JERK) -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -201,7 +201,7 @@ void lv_draw_jerk_settings(void) { } #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]); lv_label_set_text(labelXValue, 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 902472b884..35ad439c6e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp @@ -23,11 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../../Configuration.h" -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; 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 3e4ad06477..4cd2cab72f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp @@ -23,14 +23,14 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" #include //static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; @@ -352,7 +352,7 @@ void lv_draw_language(void) { disp_language(gCfgItems.language, SELECTED); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_CN, language_menu.chinese_s); lv_obj_align(label_CN, buttonCN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 0e0283d32a..2f4fe327fd 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 @@ -23,10 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -234,7 +234,7 @@ void lv_draw_level_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); 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 9f03793c24..b79e84e8cb 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 @@ -23,10 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -252,7 +252,7 @@ void lv_draw_machine_para(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, -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 0cf5bbaf7f..930d2639bb 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 @@ -23,10 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -218,7 +218,7 @@ void lv_draw_machine_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); 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 3d68019b35..f1040ba214 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -23,14 +23,15 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "draw_ui.h" + #include "../../../../gcode/queue.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -253,7 +254,7 @@ void lv_draw_manualLevel(void) { lv_obj_t *label_Point5 = lv_label_create(buttonPoint5, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Point1, leveling_menu.position1); lv_obj_align(label_Point1, buttonPoint1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 9b7200b5a9..c27718b31d 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 @@ -23,11 +23,11 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -384,7 +384,7 @@ void lv_draw_manual_level_pos_settings(void) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { ZERO(public_buf_l); 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 e82124f705..6b43b8257b 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 @@ -23,11 +23,11 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -284,7 +284,7 @@ void lv_draw_max_feedrate_settings(void) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { lv_label_set_text(labelTurnPage, machine_menu.next); 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 f6568df143..1766abf061 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 @@ -23,10 +23,10 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -310,7 +310,7 @@ void lv_draw_motor_settings(void) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); 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 a6c0c0551a..8e8302d707 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 @@ -23,14 +23,15 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "draw_ui.h" + #include "../../../../gcode/queue.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -268,7 +269,7 @@ void lv_draw_move_motor(void) { labelV = lv_label_create(buttonV, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelXI, move_menu.x_add); lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -321,7 +322,7 @@ void disp_move_dist() { lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move10.bin"); lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move10.bin"); } - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if ((int)(10 * uiCfg.move_dist) == 1) { lv_label_set_text(labelV, move_menu.step_01mm); lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 4842776304..585c2fa75e 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 @@ -23,25 +23,23 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../../lvgl/src/lv_objx/lv_img.h" //#include "../../lvgl/src/lv_core/lv_disp.h" //#include "../../lvgl/src/lv_core/lv_refr.h" -//#include "../../MarlinCore.h" -#include "draw_ui.h" -#include "../../../../MarlinCore.h" -#include "../../../../module/temperature.h" +#include "../../../../gcode/gcode.h" #include "../../../../gcode/queue.h" +#include "../../../../module/planner.h" +#include "../../../../module/temperature.h" +#include "../../../../inc/MarlinConfig.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" #endif -#include "../../../../gcode/gcode.h" -#include "../../../../module/planner.h" - #if HAS_TRINAMIC_CONFIG #include "../../../../module/stepper/indirection.h" #include "../../../../feature/tmc_util.h" 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 4a4a0ee130..6ee5ac88c0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp @@ -23,17 +23,17 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" #include "../../../../module/motion.h" #include "../../../../sd/cardreader.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -135,24 +135,21 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (gCfgItems.finish_power_off == 1) { - gCfgItems.finish_power_off = 0; + if (gCfgItems.finish_power_off) { + gCfgItems.finish_power_off = false; lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin"); lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin"); lv_label_set_text(label_PowerOff, printing_more_menu.manual); - lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - lv_obj_refresh_ext_draw_pad(label_PowerOff); - update_spi_flash(); } else { - gCfgItems.finish_power_off = 1; + gCfgItems.finish_power_off = true; lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin"); lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin"); lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); - lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - lv_obj_refresh_ext_draw_pad(label_PowerOff); - update_spi_flash(); } + lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_obj_refresh_ext_draw_pad(label_PowerOff); + update_spi_flash(); } break; case ID_O_BABY_STEP: @@ -229,7 +226,7 @@ void lv_draw_operation(void) { lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel); - if (gCfgItems.finish_power_off == 1) { + if (gCfgItems.finish_power_off) { lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin"); lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin"); } @@ -362,7 +359,7 @@ void lv_draw_operation(void) { } label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelPreHeat, operation_menu.temp); lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -372,7 +369,7 @@ void lv_draw_operation(void) { lv_label_set_text(label_Fan, operation_menu.fan); lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - if (gCfgItems.finish_power_off == 1) + if (gCfgItems.finish_power_off) lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); else lv_label_set_text(label_PowerOff, printing_more_menu.manual); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp index f7dd2060b8..ec6129446a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp @@ -24,14 +24,14 @@ #if BOTH(HAS_TFT_LVGL_UI, ADVANCED_PAUSE_FEATURE) #include "draw_ui.h" -#include "lv_conf.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" #include "../../../../feature/pause.h" +#include "../../../../inc/MarlinConfig.h" void lv_draw_pause_message(const PauseMessage msg) { switch (msg) { 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 9b99971f4f..d1c3a4a795 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 @@ -23,11 +23,11 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -163,7 +163,7 @@ void lv_draw_pause_position(void) { lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX); lv_label_set_text(labelXValue, 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 f58a47b341..b08c9bd947 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -23,15 +23,15 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" +#include "../../../../inc/MarlinConfig.h" static lv_obj_t * scr; extern lv_group_t* g; @@ -275,7 +275,7 @@ void lv_draw_preHeat(void) { lv_obj_t *labelOff = lv_label_create(buttonOff, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelAdd, preheat_menu.add); lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -312,7 +312,7 @@ void disp_temp_type() { if (uiCfg.curSprayerChoose == 1) { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.ext2); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } @@ -320,7 +320,7 @@ void disp_temp_type() { else { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.ext1); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } @@ -330,7 +330,7 @@ void disp_temp_type() { else { lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_bed.bin"); lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_bed.bin"); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.hotbed); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } @@ -375,7 +375,7 @@ void disp_step_heat() { lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_degree.bin"); } - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.stepHeat == 1) { lv_label_set_text(labelStep, preheat_menu.step_1c); lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 e84bb395e0..d92943a37c 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 @@ -23,14 +23,15 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "draw_ui.h" + #include "../../../../sd/cardreader.h" +#include "../../../../inc/MarlinConfig.h" static lv_obj_t * scr; extern lv_group_t* g; @@ -270,7 +271,7 @@ void lv_draw_print_file(void) { //lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); /* - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelPageUp, tool_menu.preheat); lv_obj_align(labelPageUp, buttonPageUp, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); 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 0b49bf4ab7..6481061800 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -23,23 +23,25 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" +#include "../../../../MarlinCore.h" // for marlin_state #include "../../../../module/temperature.h" #include "../../../../module/motion.h" #include "../../../../sd/cardreader.h" #include "../../../../gcode/queue.h" #include "../../../../gcode/gcode.h" +#include "../../../../inc/MarlinConfig.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" #endif + #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) #include "../../../marlinui.h" #endif @@ -60,11 +62,9 @@ static lv_obj_t * buttonPause, *buttonOperat, *buttonStop; #define ID_STOP 2 #define ID_OPTION 3 -uint8_t once_flag = 0; +bool once_flag; // = false +extern bool flash_preview_begin, default_preview_flg, gcode_preview_over; extern uint32_t To_pre_view; -extern uint8_t flash_preview_begin; -extern uint8_t default_preview_flg; -extern uint8_t gcode_preview_over; static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { @@ -73,7 +73,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (gcode_preview_over != 1) { + if (!gcode_preview_over) { if (uiCfg.print_state == WORKING) { // #if ENABLED(PARK_HEAD_ON_PAUSE) // queue.inject_P(PSTR("M25 P\nM24")); @@ -117,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (gcode_preview_over != 1) { + if (!gcode_preview_over) { lv_clear_printing(); lv_draw_dialog(DIALOG_TYPE_STOP); } @@ -128,7 +128,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (gcode_preview_over != 1) { + if (!gcode_preview_over) { lv_clear_printing(); lv_draw_operation(); } @@ -290,7 +290,7 @@ void lv_draw_printing(void) { labelStop = lv_label_create(buttonStop, NULL); labelOperat = lv_label_create(buttonOperat, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelPause, uiCfg.print_state == WORKING ? printing_menu.pause : printing_menu.resume); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0); @@ -378,7 +378,7 @@ void setProBarRate() { int rate; volatile long long rate_tmp_r; - if (gCfgItems.from_flash_pic != 1) { + if (!gCfgItems.from_flash_pic) { #if ENABLED(SDSUPPORT) rate_tmp_r = (long long)card.getIndex() * 100; #endif @@ -405,15 +405,15 @@ void setProBarRate() { if (once_flag == 0) { stop_print_time(); - flash_preview_begin = 0; - default_preview_flg = 0; + flash_preview_begin = false; + default_preview_flg = false; lv_clear_printing(); lv_draw_dialog(DIALOG_TYPE_FINISH_PRINT); - once_flag = 1; + once_flag = true; #if HAS_SUICIDE - if (gCfgItems.finish_power_off == 1) { + if (gCfgItems.finish_power_off) { gcode.process_subcommands_now_P(PSTR("M1001")); queue.inject_P(PSTR("M81")); marlin_state = MF_RUNNING; 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 54ffdca64a..276e8fb551 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 @@ -25,7 +25,7 @@ #include "draw_ready_print.h" #include "draw_tool.h" -#include "lv_conf.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" @@ -36,8 +36,8 @@ #include -#include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" +#include "../../../../inc/MarlinConfig.h" #include @@ -186,7 +186,7 @@ void lv_draw_ready_print(void) { //lv_obj_t *label_print = lv_label_create(buttonPrint, NULL); //lv_obj_t *label_set = lv_label_create(buttonSet, NULL); lv_obj_t *label_tool = lv_label_create(buttonTool, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { //lv_label_set_text(label_print, main_menu.print); //lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); @@ -279,7 +279,7 @@ void lv_draw_ready_print(void) { lv_obj_t *label_print = lv_label_create(buttonPrint, NULL); lv_btn_set_layout(buttonPrint, LV_LAYOUT_OFF); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_print, main_menu.print); lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 6c10713d8a..d23fe40182 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp @@ -23,18 +23,20 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" #include "draw_ready_print.h" #include "draw_set.h" -#include "lv_conf.h" +#include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "draw_ui.h" -#include "../../../../gcode/queue.h" + #include "pic_manager.h" +#include "../../../../gcode/queue.h" +#include "../../../../inc/MarlinConfig.h" + static lv_obj_t * scr; extern lv_group_t* g; @@ -331,7 +333,7 @@ void lv_draw_set(void) { #endif lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_EepromSet, set_menu.eepromSet); lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 baad23f9ae..ff45fba461 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 @@ -23,11 +23,11 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -278,7 +278,7 @@ void lv_draw_step_settings(void) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); #endif - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { lv_label_set_text(labelTurnPage, machine_menu.next); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); 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 10aa7badff..b19048f1c0 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 @@ -23,13 +23,12 @@ #if BOTH(HAS_TFT_LVGL_UI, HAS_TRINAMIC_CONFIG) -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" -#include "../../../../module/planner.h" #include "../../../../module/stepper/indirection.h" #include "../../../../feature/tmc_util.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -310,7 +309,7 @@ void lv_draw_tmc_current_settings(void) { lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { //#if AXIS_IS_TMC(E1) lv_label_set_text(labelTurnPage, machine_menu.next); 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 3e014a781c..04087f632e 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 @@ -23,15 +23,13 @@ #if BOTH(HAS_TFT_LVGL_UI, HAS_STEALTHCHOP) -#include "lv_conf.h" #include "draw_ui.h" +#include -#include "../../../../MarlinCore.h" -#include "../../../../module/planner.h" #include "../../../../module/stepper/indirection.h" #include "../../../../feature/tmc_util.h" #include "../../../../gcode/gcode.h" -#include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -232,7 +230,6 @@ void lv_draw_tmc_step_mode_settings(void) { lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL; //#endif - labelXState = NULL; buttonXState = NULL; labelYState = NULL; @@ -493,7 +490,7 @@ void lv_draw_tmc_step_mode_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { if (uiCfg.para_ui_page != 1) { lv_label_set_text(labelXText, machine_menu.X_StepMode); lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); 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 3681b1b2d6..b6ef6e64da 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -23,16 +23,16 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" #include "draw_ui.h" +#include //#include "../lvgl/src/lv_objx/lv_imgbtn.h" //#include "../lvgl/src/lv_objx/lv_img.h" //#include "../lvgl/src/lv_core/lv_disp.h" //#include "../lvgl/src/lv_core/lv_refr.h" -#include "../../../../MarlinCore.h" #include "../../../../gcode/queue.h" #include "../../../../module/temperature.h" +#include "../../../../inc/MarlinConfig.h" extern lv_group_t * g; static lv_obj_t * scr; @@ -236,7 +236,7 @@ void lv_draw_tool(void) { //lv_obj_t *label_More = lv_label_create(buttonMore, NULL); lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language != 0) { + if (gCfgItems.multiple_language) { lv_label_set_text(labelPreHeat, tool_menu.preheat); lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); 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 519fae2f39..1f21136668 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -34,10 +34,11 @@ #include -#include "../../../../MarlinCore.h" +#include "../../../../MarlinCore.h" // for marlin_state #include "../../../../sd/cardreader.h" #include "../../../../module/motion.h" #include "../../../../module/planner.h" +#include "../../../../inc/MarlinConfig.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" @@ -57,15 +58,13 @@ num_key_value_state value; keyboard_value_state keyboard_value; uint32_t To_pre_view; -uint8_t gcode_preview_over; -uint8_t flash_preview_begin; -uint8_t default_preview_flg; +bool gcode_preview_over, flash_preview_begin, default_preview_flg; uint32_t size = 809; uint16_t row; uint8_t temperature_change_frequency; uint8_t printing_rate_update_flag; -extern uint8_t once_flag; +extern bool once_flag; extern uint8_t sel_id; extern uint8_t public_buf[512]; extern uint8_t bmp_public_buf[17 * 1024]; @@ -116,10 +115,10 @@ void gCfgItems_init() { gCfgItems.language = LANG_PORTUGUESE; #endif gCfgItems.leveling_mode = 0; - gCfgItems.from_flash_pic = 0; + gCfgItems.from_flash_pic = false; gCfgItems.curFilesize = 0; - gCfgItems.finish_power_off = 0; - gCfgItems.pause_reprint = 0; + gCfgItems.finish_power_off = false; + gCfgItems.pause_reprint = false; gCfgItems.pausePosX = -1; gCfgItems.pausePosY = -1; gCfgItems.pausePosZ = 5; @@ -407,7 +406,6 @@ void tft_style_init() { lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF); lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF); lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF); - } #define MAX_TITLE_LEN 28 @@ -609,14 +607,14 @@ char *creat_title_text() { pre_read_cnt = (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0])); To_pre_view = pre_read_cnt; - gcode_preview_over = 1; - gCfgItems.from_flash_pic = 1; + gcode_preview_over = true; + gCfgItems.from_flash_pic = true; update_spi_flash(); } else { - gcode_preview_over = 0; - default_preview_flg = 1; - gCfgItems.from_flash_pic = 0; + gcode_preview_over = false; + default_preview_flg = true; + gCfgItems.from_flash_pic = false; update_spi_flash(); } card.closefile(); @@ -681,8 +679,8 @@ char *creat_title_text() { size = 809; row = 0; - gcode_preview_over = 0; - //flash_preview_begin = 1; + gcode_preview_over = false; + //flash_preview_begin = true; card.closefile(); @@ -696,7 +694,7 @@ char *creat_title_text() { //bakup_file_path((uint8_t *)curFileName, strlen(curFileName)); srcfp = file; mksReprint.mks_printer_state = MKS_WORKING; - once_flag = 0; + once_flag = false; } } */ @@ -727,7 +725,7 @@ char *creat_title_text() { #endif card.startFileprint(); TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); - once_flag = 0; + once_flag = false; } return; } @@ -813,8 +811,8 @@ char *creat_title_text() { size = 809; row = 0; - gcode_preview_over = 0; - //flash_preview_begin = 1; + gcode_preview_over = false; + //flash_preview_begin = true; card.closefile(); @@ -828,7 +826,7 @@ char *creat_title_text() { //bakup_file_path((uint8_t *)curFileName, strlen(curFileName)); srcfp = file; mksReprint.mks_printer_state = MKS_WORKING; - once_flag = 0; + once_flag = false; } } */ @@ -859,7 +857,7 @@ char *creat_title_text() { #endif card.startFileprint(); TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); - once_flag = 0; + once_flag = false; } return; } @@ -894,17 +892,17 @@ char *creat_title_text() { } void disp_pre_gcode(int xpos_pixel, int ypos_pixel) { - if (gcode_preview_over == 1) gcode_preview(list_file.file_name[sel_id], xpos_pixel, ypos_pixel); + if (gcode_preview_over) gcode_preview(list_file.file_name[sel_id], xpos_pixel, ypos_pixel); #if HAS_BAK_VIEW_IN_FLASH - if (flash_preview_begin == 1) { - flash_preview_begin = 0; + if (flash_preview_begin) { + flash_preview_begin = false; Draw_default_preview(xpos_pixel, ypos_pixel, 1); } #endif #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH - if (default_preview_flg == 1) { + if (default_preview_flg) { Draw_default_preview(xpos_pixel, ypos_pixel, 0); - default_preview_flg = 0; + default_preview_flg = false; } #endif } @@ -971,7 +969,7 @@ void GUI_RefreshPage() { } if (printing_rate_update_flag || marlin_state == MF_SD_COMPLETE) { printing_rate_update_flag = 0; - if (gcode_preview_over == 0) setProBarRate(); + if (!gcode_preview_over) setProBarRate(); } break; @@ -1359,8 +1357,8 @@ void draw_return_ui() { lv_draw_print_file(); break; case PRINTING_UI: - if (gCfgItems.from_flash_pic == 1) flash_preview_begin = 1; - else default_preview_flg = 1; + if (gCfgItems.from_flash_pic) flash_preview_begin = true; + else default_preview_flg = true; lv_draw_printing(); break; case MOVE_MOTOR_UI: 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 51782688c0..00faedac4e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -174,12 +174,12 @@ extern char public_buf_l[30]; typedef struct { uint32_t spi_flash_flag; uint8_t disp_rotation_180; - uint8_t multiple_language; + bool multiple_language; uint8_t language; uint8_t leveling_mode; - uint8_t from_flash_pic; - uint8_t finish_power_off; - uint8_t pause_reprint; + bool from_flash_pic; + bool finish_power_off; + bool pause_reprint; uint8_t wifi_mode_sel; uint8_t fileSysType; uint8_t wifi_type; 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 9cf4555b25..ce158ef7fb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp @@ -23,13 +23,12 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" -#include "draw_ui.h" +#include +#include "tft_lvgl_configuration.h" #if ENABLED(USE_WIFI_FUNCTION) -#include "../../../../../Configuration.h" -#include "../../../../module/temperature.h" +#include "draw_ui.h" extern lv_group_t * g; static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text; @@ -135,7 +134,7 @@ void lv_draw_wifi(void) { label_Reconnect = lv_label_create(buttonReconnect, NULL); } - if (gCfgItems.multiple_language !=0) { + if (gCfgItems.multiple_language) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); 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 14fd63f852..2680194868 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 @@ -23,13 +23,12 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" -#include "draw_ui.h" +#include +#include "tft_lvgl_configuration.h" #if ENABLED(USE_WIFI_FUNCTION) -#include "../../../../../Configuration.h" -#include "../../../../module/temperature.h" +#include "draw_ui.h" #define NAME_BTN_X 330 #define NAME_BTN_Y 48 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 86733470dd..81a5f5c3be 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 @@ -23,13 +23,12 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" -#include "draw_ui.h" +#include +#include "tft_lvgl_configuration.h" #if ENABLED(USE_WIFI_FUNCTION) -#include "../../../../../Configuration.h" -#include "../../../../module/planner.h" +#include "draw_ui.h" extern lv_group_t * g; static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL; @@ -48,8 +47,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - lv_clear_wifi_settings(); - draw_return_ui(); + lv_clear_wifi_settings(); + draw_return_ui(); } break; case ID_WIFI_MODEL: @@ -57,18 +56,18 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - if (gCfgItems.wifi_mode_sel == AP_MODEL) { - gCfgItems.wifi_mode_sel = STA_MODEL; - lv_label_set_text(labelModelValue, WIFI_STA_TEXT); - lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); - update_spi_flash(); - } - else{ - gCfgItems.wifi_mode_sel = AP_MODEL; - lv_label_set_text(labelModelValue, WIFI_AP_TEXT); - lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); - update_spi_flash(); - } + if (gCfgItems.wifi_mode_sel == AP_MODEL) { + gCfgItems.wifi_mode_sel = STA_MODEL; + lv_label_set_text(labelModelValue, WIFI_STA_TEXT); + lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); + update_spi_flash(); + } + else { + gCfgItems.wifi_mode_sel = AP_MODEL; + lv_label_set_text(labelModelValue, WIFI_AP_TEXT); + lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); + update_spi_flash(); + } } break; case ID_WIFI_NAME: @@ -76,9 +75,9 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - keyboard_value=wifiName; - lv_clear_wifi_settings(); - lv_draw_keyboard(); + keyboard_value = wifiName; + lv_clear_wifi_settings(); + lv_draw_keyboard(); } break; case ID_WIFI_PASSWORD: @@ -87,8 +86,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { keyboard_value=wifiPassWord; - lv_clear_wifi_settings(); - lv_draw_keyboard(); + lv_clear_wifi_settings(); + lv_draw_keyboard(); } break; case ID_WIFI_CLOUD: @@ -115,8 +114,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - lv_clear_wifi_settings(); - lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS); + lv_clear_wifi_settings(); + lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS); } break; } @@ -211,7 +210,7 @@ void lv_draw_wifi_settings(void) { lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); } - lv_obj_set_event_cb_mks(buttonCloudValue, event_handler,ID_WIFI_CLOUD, NULL,0); + lv_obj_set_event_cb_mks(buttonCloudValue, event_handler,ID_WIFI_CLOUD, NULL,0); lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonCloudValue, LV_LAYOUT_OFF); @@ -240,7 +239,7 @@ void lv_draw_wifi_settings(void) { lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); - if (gCfgItems.multiple_language !=0) { + if (gCfgItems.multiple_language) { if (gCfgItems.wifi_mode_sel == AP_MODEL) { lv_label_set_text(labelModelValue, WIFI_AP_TEXT); lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); @@ -295,5 +294,4 @@ void lv_clear_wifi_settings() { } #endif // USE_WIFI_FUNCTION - #endif // HAS_TFT_LVGL_UI 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 50fa0aaf99..059656bbb5 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 @@ -23,13 +23,12 @@ #if HAS_TFT_LVGL_UI -#include "lv_conf.h" -#include "draw_ui.h" +#include +#include "tft_lvgl_configuration.h" #if ENABLED(USE_WIFI_FUNCTION) -#include "../../../../../Configuration.h" -#include "../../../../module/temperature.h" +#include "draw_ui.h" static lv_obj_t * scr; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp b/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp index cf64571292..b9c7ccd9e6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp @@ -23,10 +23,11 @@ #if HAS_TFT_LVGL_UI -#include "draw_ui.h" +#include "tft_lvgl_configuration.h" #if ENABLED(USE_WIFI_FUNCTION) +#include "draw_ui.h" #include "wifiSerial.h" #include diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index 07ac563802..70c48f5c8e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -206,11 +206,11 @@ static const char assets[][LONG_FILENAME_LENGTH] = { "bmp_return.bin", #if ENABLED(USE_WIFI_FUNCTION) - //wifi screen + // wifi screen "bmp_wifi.bin", #endif - //babystep screen + // babystep screen "bmp_baby_move0_01.bin", "bmp_baby_move0_05.bin", "bmp_baby_move0_1.bin" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp index 2b6f5f89f6..e6c30b30f8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp @@ -23,24 +23,22 @@ #if HAS_TFT_LVGL_UI -#include "../../../../MarlinCore.h" - -#include "lv_conf.h" #include "draw_ui.h" +#include + +#include "../../../../gcode/gcode.h" #include "../../../../module/temperature.h" +#include "../../../../module/planner.h" #include "../../../../module/motion.h" #include "../../../../sd/cardreader.h" -#include "../../../../gcode/queue.h" +#include "../../../../inc/MarlinConfig.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" #endif -#include "../../../../gcode/gcode.h" -#include "../../../../module/planner.h" - extern uint32_t To_pre_view; -extern uint8_t flash_preview_begin, default_preview_flg, gcode_preview_over; +extern bool flash_preview_begin, default_preview_flg, gcode_preview_over; void printer_state_polling() { if (uiCfg.print_state == PAUSING) { @@ -76,7 +74,7 @@ void printer_state_polling() { // #if ENABLED(POWER_LOSS_RECOVERY) // if (recovery.enabled) recovery.save(true); // #endif - gCfgItems.pause_reprint = 1; + gCfgItems.pause_reprint = true; update_spi_flash(); } #endif @@ -105,7 +103,7 @@ void printer_state_polling() { uiCfg.print_state = WORKING; start_print_time(); - gCfgItems.pause_reprint = 0; + gCfgItems.pause_reprint = false; update_spi_flash(); } } @@ -137,7 +135,7 @@ void printer_state_polling() { ); gcode.process_subcommands_now(public_buf_m); - if ((gCfgItems.pause_reprint) == 1 && (gCfgItems.pausePosZ != (float)-1)) { + if (gCfgItems.pause_reprint && gCfgItems.pausePosZ != -1.0f) { gcode.process_subcommands_now_P(PSTR("G91")); ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ); @@ -148,7 +146,7 @@ void printer_state_polling() { uiCfg.print_state = WORKING; start_print_time(); - gCfgItems.pause_reprint = 0; + gCfgItems.pause_reprint = false; update_spi_flash(); } #endif @@ -240,10 +238,10 @@ void filament_check() { stop_print_time(); uiCfg.print_state = PAUSING; - if (gCfgItems.from_flash_pic == 1) - flash_preview_begin = 1; + if (gCfgItems.from_flash_pic) + flash_preview_begin = true; else - default_preview_flg = 1; + default_preview_flg = true; lv_draw_printing(); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp index f74ed3c798..6143037c2b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp @@ -72,7 +72,7 @@ lv_group_t* g; uint16_t DeviceCode = 0x9488; extern uint8_t sel_id; -extern uint8_t gcode_preview_over, flash_preview_begin, default_preview_flg; +extern bool flash_preview_begin, default_preview_flg, gcode_preview_over; uint8_t bmp_public_buf[17 * 1024]; @@ -80,9 +80,8 @@ void SysTick_Callback() { lv_tick_inc(1); print_time_count(); #if ENABLED(USE_WIFI_FUNCTION) - if (tips_disp.timer == TIPS_TIMER_START) { + if (tips_disp.timer == TIPS_TIMER_START) tips_disp.timer_count++; - } #endif if (uiCfg.filament_loading_time_flg == 1) { uiCfg.filament_loading_time_cnt++; @@ -193,10 +192,10 @@ void tft_lvgl_init() { #if ENABLED(POWER_LOSS_RECOVERY) recovery.load(); if (recovery.valid()) { - if (gCfgItems.from_flash_pic == 1) - flash_preview_begin = 1; + if (gCfgItems.from_flash_pic) + flash_preview_begin = true; else - default_preview_flg = 1; + default_preview_flg = true; uiCfg.print_state = REPRINTING; @@ -408,36 +407,32 @@ lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) { } void lv_encoder_pin_init() { - #if 1 // HAS_DIGITAL_BUTTONS + #if BUTTON_EXISTS(EN1) + SET_INPUT_PULLUP(BTN_EN1); + #endif + #if BUTTON_EXISTS(EN2) + SET_INPUT_PULLUP(BTN_EN2); + #endif + #if BUTTON_EXISTS(ENC) + SET_INPUT_PULLUP(BTN_ENC); + #endif - #if BUTTON_EXISTS(EN1) - SET_INPUT_PULLUP(BTN_EN1); - #endif - #if BUTTON_EXISTS(EN2) - SET_INPUT_PULLUP(BTN_EN2); - #endif - #if BUTTON_EXISTS(ENC) - SET_INPUT_PULLUP(BTN_ENC); - #endif + #if BUTTON_EXISTS(BACK) + SET_INPUT_PULLUP(BTN_BACK); + #endif - #if BUTTON_EXISTS(BACK) - SET_INPUT_PULLUP(BTN_BACK); - #endif - - #if BUTTON_EXISTS(UP) - SET_INPUT(BTN_UP); - #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); - #endif - #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); - #endif - #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); - #endif - - #endif // HAS_DIGITAL_BUTTONS + #if BUTTON_EXISTS(UP) + SET_INPUT(BTN_UP); + #endif + #if BUTTON_EXISTS(DWN) + SET_INPUT(BTN_DWN); + #endif + #if BUTTON_EXISTS(LFT) + SET_INPUT(BTN_LFT); + #endif + #if BUTTON_EXISTS(RT) + SET_INPUT(BTN_RT); + #endif } #if 1 // HAS_ENCODER_ACTION diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp index 01c86ad7cb..6e15deffae 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp @@ -23,11 +23,13 @@ #if HAS_TFT_LVGL_UI -#include "draw_ui.h" -#include "wifiSerial.h" +#include "tft_lvgl_configuration.h" #if ENABLED(USE_WIFI_FUNCTION) +#include "draw_ui.h" +#include "wifiSerial.h" + #include #include #include diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp index e4fb4ece03..bfc23f238c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -66,14 +66,13 @@ int cfg_cloud_flag = 0; extern PRINT_TIME print_time; -char wifi_firm_ver[20] = {0}; +char wifi_firm_ver[20] = { 0 }; WIFI_GCODE_BUFFER espGcodeFifo; extern uint8_t pause_resum; uint8_t wifi_connect_flg = 0; extern volatile uint8_t get_temp_flag; - #define WIFI_MODE 2 #define WIFI_AP_MODE 3 @@ -96,7 +95,7 @@ extern uint32_t wifi_loop_cycle; volatile TRANSFER_STATE esp_state; uint8_t left_to_send = 0; -uint8_t left_to_save[96] = {0}; +uint8_t left_to_save[96] = { 0 }; volatile WIFI_DMA_RCV_FIFO wifiDmaRcvFifo; @@ -109,53 +108,44 @@ extern WIFI_PARA wifiPara; extern IP_PARA ipPara; extern CLOUD_PARA cloud_para; -extern uint8_t once_flag; -extern uint8_t flash_preview_begin; -extern uint8_t default_preview_flg; -extern uint8_t gcode_preview_over; +extern bool once_flag, flash_preview_begin, default_preview_flg, gcode_preview_over; extern uint8_t bmp_public_buf[17 * 1024]; -uint32_t getWifiTick() { +uint32_t getWifiTick() { return millis(); } -uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) { - if (lastTick <= curTick) { +uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) { + if (lastTick <= curTick) return (curTick - lastTick) * TICK_CYCLE; - } - else { + else return (0xFFFFFFFF - lastTick + curTick) * TICK_CYCLE; - } } void wifi_delay(int n) { uint32_t begin = getWifiTick(); uint32_t end = begin; - - while (getWifiTickDiff(begin, end) < (uint32_t)n) { + while (getWifiTickDiff(begin, end) < (uint32_t)n) end = getWifiTick(); - } } void wifi_reset() { uint32_t start, now; start = getWifiTick(); now = start; - WIFI_RESET(); - while (getWifiTickDiff(start, now) < 500) { + WIFI_RESET(); + while (getWifiTickDiff(start, now) < 500) now = getWifiTick(); - } - WIFI_SET(); + WIFI_SET(); } void mount_file_sys(uint8_t disk_type) { if (disk_type == FILE_SYS_SD) { - card.mount(); + TERN_(SDSUPPORT, card.mount()); } else if (disk_type == FILE_SYS_USB) { - } } @@ -201,7 +191,6 @@ static void dma_init() { memset(wifiDmaRcvFifo.bufferAddr[0], 0, 1024 * TRANS_RCV_FIFO_BLOCK_NUM); wifiDmaRcvFifo.read_cur = 0; wifiDmaRcvFifo.write_cur = 0; - } static void wifi_deInit() { @@ -300,7 +289,7 @@ void esp_port_begin(uint8_t interrupt) { WIFISERIAL.begin(WIFI_BAUDRATE); uint32_t serial_connect_timeout = millis() + 1000UL; while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - //for(uint8_t i=0;i<100;i++)WIFISERIAL.write(0x33); + //for (uint8_t i=0;i<100;i++)WIFISERIAL.write(0x33); #endif } else { @@ -310,7 +299,7 @@ void esp_port_begin(uint8_t interrupt) { WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE); uint32_t serial_connect_timeout = millis() + 1000UL; while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - //for(uint16_t i=0;i<65535;i++);//WIFISERIAL.write(0x33); + //for (uint16_t i=0;i<65535;i++);//WIFISERIAL.write(0x33); #endif dma_init(); } @@ -318,16 +307,14 @@ void esp_port_begin(uint8_t interrupt) { #if ENABLED(USE_WIFI_FUNCTION) -int raw_send_to_wifi(char *buf, int len) { - if (buf == 0 || len <= 0) return 0; + int raw_send_to_wifi(char *buf, int len) { + if (buf == 0 || len <= 0) return 0; + for (int i = 0; i < len; i++) + WIFISERIAL.write(*(buf + i)); + return len; + } - for (int i = 0; i < len; i++) - WIFISERIAL.write(*(buf + i)); - - return len; -} - -#endif // USE_WIFI_FUNCTION +#endif void wifi_ret_ack() {} @@ -342,7 +329,7 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { int apLen = strlen((const char *)uiCfg.wifi_name); int keyLen = strlen((const char *)uiCfg.wifi_key); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; buf_to_wifi[data_offset] = gCfgItems.wifi_mode_sel; @@ -361,18 +348,17 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { raw_send_to_wifi(buf_to_wifi, 5 + index_to_wifi); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; - } else if (type == WIFI_TRANS_INF) { if (len > (int)(sizeof(buf_to_wifi) - index_to_wifi - 5)) { - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; return 0; } - if (len > 0) { + if (len > 0) { memcpy(&buf_to_wifi[4 + index_to_wifi], buf, len); index_to_wifi += len; @@ -380,12 +366,12 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { return 0; if (buf_to_wifi[index_to_wifi + 3] == '\n') { - //mask "wait" "busy" "X:" + // mask "wait" "busy" "X:" if (((buf_to_wifi[4] == 'w') && (buf_to_wifi[5] == 'a') && (buf_to_wifi[6] == 'i') && (buf_to_wifi[7] == 't') ) || ((buf_to_wifi[4] == 'b') && (buf_to_wifi[5] == 'u') && (buf_to_wifi[6] == 's') && (buf_to_wifi[7] == 'y') ) || ((buf_to_wifi[4] == 'X') && (buf_to_wifi[5] == ':') ) - ) { - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ) { + ZERO(buf_to_wifi); index_to_wifi = 0; return 0; } @@ -398,13 +384,13 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { raw_send_to_wifi(buf_to_wifi, 5 + index_to_wifi); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); - index_to_wifi = 0; - } + ZERO(buf_to_wifi); + index_to_wifi = 0; + } } } else if (type == WIFI_EXCEP_INF) { - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); buf_to_wifi[0] = wifi_ret_head; buf_to_wifi[1] = type; @@ -415,25 +401,21 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { raw_send_to_wifi(buf_to_wifi, 6); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; } else if (type == WIFI_CLOUD_CFG) { int data_offset = 4; int urlLen = strlen((const char *)uiCfg.cloud_hostUrl); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; - if (gCfgItems.cloud_enable == true) - buf_to_wifi[data_offset] = 0x0A; - else - buf_to_wifi[data_offset] = 0x05; - + buf_to_wifi[data_offset] = gCfgItems.cloud_enable ? 0x0A : 0x05; buf_to_wifi[data_offset + 1] = urlLen; strncpy(&buf_to_wifi[data_offset + 2], (const char *)uiCfg.cloud_hostUrl, urlLen); - buf_to_wifi[data_offset + urlLen + 2] = uiCfg.cloud_port & 0xFF; - buf_to_wifi[data_offset + urlLen + 3] = (uiCfg.cloud_port >> 8) & 0xFF; + buf_to_wifi[data_offset + urlLen + 2] = uiCfg.cloud_port & 0xFF; + buf_to_wifi[data_offset + urlLen + 3] = (uiCfg.cloud_port >> 8) & 0xFF; buf_to_wifi[data_offset + urlLen + 4] = wifi_ret_tail; index_to_wifi = urlLen + 4; @@ -445,11 +427,11 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { raw_send_to_wifi(buf_to_wifi, 5 + index_to_wifi); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; } else if (type == WIFI_CLOUD_UNBIND) { - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); buf_to_wifi[0] = wifi_ret_head; buf_to_wifi[1] = type; @@ -459,7 +441,7 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { raw_send_to_wifi(buf_to_wifi, 5); - memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + ZERO(buf_to_wifi); index_to_wifi = 0; } } @@ -467,22 +449,16 @@ int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { int send_to_wifi(char *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); } -void set_cur_file_sys(int fileType) { - gCfgItems.fileSysType = fileType; -} +void set_cur_file_sys(int fileType) { gCfgItems.fileSysType = fileType; } void get_file_list(char *path) { - if ( path == 0) { - return; - } + if (!path) return; if (gCfgItems.fileSysType == FILE_SYS_SD) { - #if ENABLED(SDSUPPORT) - card.mount(); - #endif + TERN_(SDSUPPORT, card.mount()); } else if (gCfgItems.fileSysType == FILE_SYS_USB) { - //udisk + // udisk } Explore_Disk(path, 0); } @@ -502,24 +478,19 @@ FILE_WRITER file_writer; int32_t lastFragment = 0; -char lastBinaryCmd[50] = {0}; +char lastBinaryCmd[50] = { 0 }; int total_write = 0; -char binary_head[2] = {0, 0}; +char binary_head[2] = { 0, 0 }; unsigned char binary_data_len = 0; int write_to_file(char *buf, int len) { - int i; - int res; - - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { file_writer.write_buf[file_writer.write_index++] = buf[i]; if (file_writer.write_index >= 512) { - res = card.write(file_writer.write_buf, file_writer.write_index); - if (res == -1) { - return -1; - } - memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + int res = card.write(file_writer.write_buf, file_writer.write_index); + if (res == -1) return -1; + ZERO(file_writer.write_buf); file_writer.write_index = 0; } } @@ -536,7 +507,7 @@ int write_to_file(char *buf, int len) { #define ESP_TYPE_WIFI_LIST (uint8_t)0x4 -uint8_t esp_msg_buf[UART_RX_BUFFER_SIZE] = {0}; +uint8_t esp_msg_buf[UART_RX_BUFFER_SIZE] = { 0 }; uint16_t esp_msg_index = 0; typedef struct { @@ -564,93 +535,71 @@ static int cut_msg_head(uint8_t *msg, uint16_t msgLen, uint16_t cutLen) { return msgLen - cutLen; } +uint8_t Explore_Disk(char* path , uint8_t recu_level) { + char tmp[200]; + char Fstream[200]; -uint8_t Explore_Disk (char* path , uint8_t recu_level) { - char tmp[200]; - char Fstream[200]; - - if (path == 0)return 0; + if (!path) return 0; const uint8_t fileCnt = card.get_num_Files(); for (uint8_t i = 0; i < fileCnt; i++) { - const uint16_t nr = - #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA) - fileCnt - 1 - - #endif - i; + card.getfilename_sorted(SD_ORDER(i, fileCnt)); - #if ENABLED(SDCARD_SORT_ALPHA) - card.getfilename_sorted(nr); - #else - card.getfilename_sorted(nr); - #endif - memset(tmp, 0, sizeof(tmp)); - //if (card.longFilename[0] == 0) - strcpy(tmp, card.filename); - //else - //strcpy(tmp, card.longFilename); + //if (card.longFilename[0] == 0) + strcpy(tmp, card.filename); + //else + // strcpy(tmp, card.longFilename); - memset(Fstream, 0, sizeof(Fstream)); - strcpy(Fstream, tmp); + ZERO(Fstream); + strcpy(Fstream, tmp); - if (card.flag.filenameIsDir && (recu_level <= 10)) { - strcat(Fstream, ".DIR\r\n"); - send_to_wifi(Fstream, strlen(Fstream)); - } - else { - strcat(Fstream, "\r\n"); - send_to_wifi(Fstream, strlen(Fstream)); - } + if (card.flag.filenameIsDir && recu_level <= 10) + strcat(Fstream, ".DIR"); + + strcat(Fstream, "\r\n"); + send_to_wifi(Fstream, strlen(Fstream)); } return fileCnt; } static void wifi_gcode_exec(uint8_t *cmd_line) { - int8_t tempBuf[100] = {0}; + int8_t tempBuf[100] = { 0 }; uint8_t *tmpStr = 0; int cmd_value; volatile int print_rate; - if ((strstr((char *)&cmd_line[0], "\n") != 0) && ((strstr((char *)&cmd_line[0], "G") != 0) || (strstr((char *)&cmd_line[0], "M") != 0) || (strstr((char *)&cmd_line[0], "T") != 0) )) { + if (strchr((char *)cmd_line, '\n') && (strchr((char *)cmd_line, 'G') || strchr((char *)cmd_line, 'M') || strchr((char *)cmd_line, 'T'))) { + tmpStr = (uint8_t *)strchr((char *)cmd_line, '\n'); + if (tmpStr) *tmpStr = '\0'; - tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "\n"); + tmpStr = (uint8_t *)strchr((char *)cmd_line, '\r'); + if (tmpStr) *tmpStr = '\0'; + + tmpStr = (uint8_t *)strchr((char *)cmd_line, '*'); + if (tmpStr) *tmpStr = '\0'; + + tmpStr = (uint8_t *)strchr((char *)cmd_line, 'M'); if (tmpStr) { - *tmpStr = '\0'; - } - tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "\r"); - if (tmpStr) { - *tmpStr = '\0'; - } - tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "*"); - if (tmpStr) { - *tmpStr = '\0'; - } - tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "M"); - if ( tmpStr) { cmd_value = atoi((char *)(tmpStr + 1)); - tmpStr = (uint8_t *)strstr((char *)tmpStr, " "); + tmpStr = (uint8_t *)strchr((char *)tmpStr, ' '); switch (cmd_value) { - case 20: //print sd / udisk file + case 20: // M20: Print SD / µdisk file if (uiCfg.print_state == IDLE) { int index = 0; if (tmpStr == 0) { gCfgItems.fileSysType = FILE_SYS_SD; send_to_wifi((char *)"Begin file list\r\n", strlen("Begin file list\r\n")); - get_file_list((char *)"0:/"); - send_to_wifi((char *)"End file list\r\n", strlen("End file list\r\n")); - send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); break; } - while (tmpStr[index] == ' ') - index++; + while (tmpStr[index] == ' ') index++; if (gCfgItems.wifi_type == ESP_WIFI) { char *path = (char *)tempBuf; @@ -658,13 +607,11 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if (strlen((char *)&tmpStr[index]) < 80) { send_to_wifi((char *)"Begin file list\r\n", strlen("Begin file list\r\n")); - if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) { + if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) gCfgItems.fileSysType = FILE_SYS_SD; - - } - else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) { + else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) gCfgItems.fileSysType = FILE_SYS_USB; - } + strcpy((char *)path, (char *)&tmpStr[index]); get_file_list(path); send_to_wifi((char *)"End file list\r\n", strlen("End file list\r\n")); @@ -683,49 +630,37 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { /*select the file*/ if (uiCfg.print_state == IDLE) { int index = 0; - while (tmpStr[index] == ' ') - index++; + while (tmpStr[index] == ' ') index++; if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) { if (strlen((char *)&tmpStr[index]) < 80) { - memset(list_file.file_name[sel_id], 0, sizeof(list_file.file_name[sel_id])); + ZERO(list_file.file_name[sel_id]); if (gCfgItems.wifi_type == ESP_WIFI) { - if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) { + if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) gCfgItems.fileSysType = FILE_SYS_SD; - - } - else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) { + else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) gCfgItems.fileSysType = FILE_SYS_USB; - } - else { - if (tmpStr[index] != '/') - strcat((char *)list_file.file_name[0], "/"); - } + else if (tmpStr[index] != '/') + strcat((char *)list_file.file_name[0], "/"); strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]); } - else { + else strcpy(list_file.file_name[sel_id], (char *)&tmpStr[index]); - } char *cur_name=strrchr(list_file.file_name[sel_id],'/'); card.openFileRead(cur_name); - if (card.isFileOpen()) { + if (card.isFileOpen()) send_to_wifi((char *)"File selected\r\n", strlen("File selected\r\n")); - - } else { send_to_wifi((char *)"file.open failed\r\n", strlen("file.open failed\r\n")); strcpy(list_file.file_name[sel_id], "notValid"); } send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); - } - - } } break; @@ -740,60 +675,57 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { uiCfg.print_state = WORKING; lv_draw_printing(); - if (gcode_preview_over != 1) { - #if ENABLED(SDSUPPORT) - char *cur_name; - cur_name=strrchr(list_file.file_name[sel_id],'/'); + #if ENABLED(SDSUPPORT) + if (!gcode_preview_over) { + char *cur_name = strrchr(list_file.file_name[sel_id], '/'); - SdFile file; - SdFile *curDir; - card.endFilePrint(); - const char * const fname = card.diveToFile(true, curDir, cur_name); - if (!fname) return; - if (file.open(curDir, fname, O_READ)) { - gCfgItems.curFilesize = file.fileSize(); - file.close(); - update_spi_flash(); - } - card.openFileRead(cur_name); - if (card.isFileOpen()) { - feedrate_percentage = 100; - //saved_feedrate_percentage = feedrate_percentage; - planner.flow_percentage[0] = 100; - planner.e_factor[0]= planner.flow_percentage[0]*0.01; - if (EXTRUDERS==2) { - planner.flow_percentage[1] = 100; - planner.e_factor[1]= planner.flow_percentage[1]*0.01; - } - card.startFileprint(); - #if ENABLED(POWER_LOSS_RECOVERY) - recovery.prepare(); - #endif - once_flag = 0; - } - #endif + card.endFilePrint(); - } + SdFile file; + SdFile *curDir; + const char * const fname = card.diveToFile(true, curDir, cur_name); + if (!fname) return; + if (file.open(curDir, fname, O_READ)) { + gCfgItems.curFilesize = file.fileSize(); + file.close(); + update_spi_flash(); + } + card.openFileRead(cur_name); + if (card.isFileOpen()) { + //saved_feedrate_percentage = feedrate_percentage; + feedrate_percentage = 100; + planner.flow_percentage[0] = 100; + planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; + #if EXTRUDERS == 2 + planner.flow_percentage[1] = 100; + planner.e_factor[1] = planner.flow_percentage[1] * 0.01f; + #endif + card.startFileprint(); + TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); + once_flag = false; + } + } + #endif } else if (uiCfg.print_state == PAUSED) { uiCfg.print_state = RESUMING; clear_cur_ui(); start_print_time(); - if (gCfgItems.from_flash_pic==1) - flash_preview_begin = 1; + if (gCfgItems.from_flash_pic) + flash_preview_begin = true; else - default_preview_flg = 1; - lv_draw_printing(); + default_preview_flg = true; + lv_draw_printing(); } else if (uiCfg.print_state == REPRINTING) { uiCfg.print_state = REPRINTED; clear_cur_ui(); start_print_time(); - if (gCfgItems.from_flash_pic==1) - flash_preview_begin = 1; + if (gCfgItems.from_flash_pic) + flash_preview_begin = true; else - default_preview_flg = 1; + default_preview_flg = true; lv_draw_printing(); } } @@ -808,13 +740,13 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { clear_cur_ui(); #if ENABLED(SDSUPPORT) - card.pauseSDPrint(); - uiCfg.print_state = PAUSING; - #endif - if (gCfgItems.from_flash_pic==1) - flash_preview_begin = 1; + card.pauseSDPrint(); + uiCfg.print_state = PAUSING; + #endif + if (gCfgItems.from_flash_pic) + flash_preview_begin = true; else - default_preview_flg = 1; + default_preview_flg = true; lv_draw_printing(); send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); } @@ -826,9 +758,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { stop_print_time(); clear_cur_ui(); - #if ENABLED(SDSUPPORT) - uiCfg.print_state = IDLE; - card.flag.abort_sd_printing = true; + #if ENABLED(SDSUPPORT) + uiCfg.print_state = IDLE; + card.flag.abort_sd_printing = true; #endif lv_draw_ready_print(); @@ -841,15 +773,10 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { /*report print rate*/ if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) { print_rate = uiCfg.totalSend; - - memset((char *)tempBuf, 0, sizeof(tempBuf)); - + ZERO(tempBuf); sprintf((char *)tempBuf, "M27 %d\r\n", print_rate); - send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); - } - break; case 28: @@ -857,112 +784,105 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if (uiCfg.print_state == IDLE) { int index = 0; - while (tmpStr[index] == ' ') - index++; + while (tmpStr[index] == ' ') index++; if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) { strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); if (gCfgItems.fileSysType == FILE_SYS_SD) { - memset(tempBuf, 0, sizeof(tempBuf)); + ZERO(tempBuf); sprintf((char *)tempBuf, "%s", file_writer.saveFileName); } else if (gCfgItems.fileSysType == FILE_SYS_USB) { - memset(tempBuf, 0, sizeof(tempBuf)); + ZERO(tempBuf); sprintf((char *)tempBuf, "%s", (char *)file_writer.saveFileName); } mount_file_sys(gCfgItems.fileSysType); #if ENABLED(SDSUPPORT) - char *cur_name=strrchr(list_file.file_name[sel_id],'/'); - card.openFileWrite(cur_name); - if (card.isFileOpen()) { - memset(file_writer.saveFileName, 0, sizeof(file_writer.saveFileName)); - strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); - memset(tempBuf, 0, sizeof(tempBuf)); - sprintf((char *)tempBuf, "Writing to file: %s\r\n", (char *)file_writer.saveFileName); - wifi_ret_ack(); - send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); - - total_write = 0; - wifi_link_state = WIFI_WAIT_TRANS_START; - - } - else{ - wifi_link_state = WIFI_CONNECTED; - clear_cur_ui(); - lv_draw_dialog(DIALOG_TRANSFER_NO_DEVICE); - } + char *cur_name = strrchr(list_file.file_name[sel_id], '/'); + card.openFileWrite(cur_name); + if (card.isFileOpen()) { + ZERO(file_writer.saveFileName); + strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); + ZERO(tempBuf); + sprintf((char *)tempBuf, "Writing to file: %s\r\n", (char *)file_writer.saveFileName); + wifi_ret_ack(); + send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); + total_write = 0; + wifi_link_state = WIFI_WAIT_TRANS_START; + } + else { + wifi_link_state = WIFI_CONNECTED; + clear_cur_ui(); + lv_draw_dialog(DIALOG_TRANSFER_NO_DEVICE); + } #endif - } - } break; case 105: case 991: - memset(tempBuf, 0, sizeof(tempBuf)); + ZERO(tempBuf); if (cmd_value == 105) { send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); sprintf((char *)tempBuf,"T:%.1f /%.1f B:%.1f /%.1f T0:%.1f /%.1f T1:%.1f /%.1f @:0 B@:0\r\n", - (float)thermalManager.temp_hotend[0].celsius,(float)thermalManager.temp_hotend[0].target, + (float)thermalManager.temp_hotend[0].celsius, (float)thermalManager.temp_hotend[0].target, #if HAS_HEATED_BED - (float)thermalManager.temp_bed.celsius,(float)thermalManager.temp_bed.target, + (float)thermalManager.temp_bed.celsius, (float)thermalManager.temp_bed.target, #else - (float)0,(float)0, + 0.0f, 0.0f, #endif - (float)thermalManager.temp_hotend[0].celsius,(float)thermalManager.temp_hotend[0].target, + (float)thermalManager.temp_hotend[0].celsius, (float)thermalManager.temp_hotend[0].target, #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER - (float)thermalManager.temp_hotend[1].celsius,(float)thermalManager.temp_hotend[1].target + (float)thermalManager.temp_hotend[1].celsius, (float)thermalManager.temp_hotend[1].target #else - (float)0,(float)0 + 0.0f, 0.0f #endif ); } else { sprintf((char *)tempBuf,"T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n", - (int)thermalManager.temp_hotend[0].celsius,(int)thermalManager.temp_hotend[0].target, + (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target, #if HAS_HEATED_BED - (int)thermalManager.temp_bed.celsius,(int)thermalManager.temp_bed.target, + (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target, #else - 0,0, - #endif - (int)thermalManager.temp_hotend[0].celsius,(int)thermalManager.temp_hotend[0].target, - #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER - (int)thermalManager.temp_hotend[1].celsius,(int)thermalManager.temp_hotend[1].target - #else - 0,0 + 0, 0, #endif + (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target, + #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER + (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target + #else + 0, 0 + #endif ); } send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); - queue.enqueue_one_P(PSTR("M105")); - break; + case 992: if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { - memset(tempBuf,0,sizeof(tempBuf)); + ZERO(tempBuf); sprintf((char *)tempBuf, "M992 %d%d:%d%d:%d%d\r\n", print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); wifi_ret_ack(); send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); } - break; + case 994: if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { - memset(tempBuf,0,sizeof(tempBuf)); - if (strlen((char *)list_file.file_name[sel_id]) > (100-1)) { - return; - } + ZERO(tempBuf); + if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return; sprintf((char *)tempBuf, "M994 %s;%d\n", list_file.file_name[sel_id],(int)gCfgItems.curFilesize); wifi_ret_ack(); send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); } break; + case 997: if (uiCfg.print_state == IDLE) { wifi_ret_ack(); @@ -985,18 +905,17 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { case 998: if (uiCfg.print_state == IDLE) { - if (atoi((char *)tmpStr) == 0) { + int v = atoi((char *)tmpStr); + if (v == 0) set_cur_file_sys(0); - } - else if (atoi((char *)tmpStr) == 1) { + else if (v == 1) set_cur_file_sys(1); - } wifi_ret_ack(); } break; case 115: - memset(tempBuf,0,sizeof(tempBuf)); + ZERO(tempBuf); send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); send_to_wifi((char *)"FIRMWARE_NAME:Robin_nano\r\n", strlen("FIRMWARE_NAME:Robin_nano\r\n")); break; @@ -1004,55 +923,50 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { default: strcat((char *)cmd_line, "\n"); - uint32_t left; + if (espGcodeFifo.wait_tick > 5) { + uint32_t left; + if (espGcodeFifo.r > espGcodeFifo.w) + left = espGcodeFifo.r - espGcodeFifo.w - 1; + else + left = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; - if (espGcodeFifo.wait_tick> 5) { - - if (espGcodeFifo.r > espGcodeFifo.w) - left = espGcodeFifo.r - espGcodeFifo.w - 1; - else - left = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; - if (left >= strlen((const char *)cmd_line)) { - uint32_t index = 0; - while (index < strlen((const char *)cmd_line)) { - espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; - espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; - index++; - } + if (left >= strlen((const char *)cmd_line)) { + uint32_t index = 0; + while (index < strlen((const char *)cmd_line)) { + espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; + espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; + index++; + } if (left - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); else need_ok_later = true; - - } - - } + } + } break; - } } - else{ + else { strcat((char *)cmd_line, "\n"); - uint32_t left_g; - if (espGcodeFifo.wait_tick > 5) { - - if (espGcodeFifo.r > espGcodeFifo.w) - left_g = espGcodeFifo.r - espGcodeFifo.w - 1; + if (espGcodeFifo.wait_tick > 5) { + uint32_t left_g; + if (espGcodeFifo.r > espGcodeFifo.w) + left_g = espGcodeFifo.r - espGcodeFifo.w - 1; else left_g = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; + if (left_g >= strlen((const char *)cmd_line)) { uint32_t index = 0; while (index < strlen((const char *)cmd_line)) { espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; - espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; + espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; index++; } - if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) - send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); - else - need_ok_later = true; - + if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + else + need_ok_later = true; } } } @@ -1066,12 +980,7 @@ static int32_t charAtArray(const uint8_t *_array, uint32_t _arrayLen, uint8_t _c } void get_wifi_list_command_send() { - char buf[6] = {0}; - buf[0] = 0xA5; - buf[1] = 0x07; - buf[2] = 0x00; - buf[3] = 0x00; - buf[4] = 0xFC; + char buf[] = { 0xA5, 0x07, 0x00, 0x00, 0xFC }; raw_send_to_wifi(buf, 5); } @@ -1079,60 +988,57 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { int wifiNameLen, wifiKeyLen, hostLen, id_len, ver_len; if (msgLen <= 0) return; - //ip + + // ip sprintf(ipPara.ip_addr, "%d.%d.%d.%d", msg[0], msg[1], msg[2], msg[3]); - //port - //connect state - if (msg[6] == 0x0A) - wifi_link_state = WIFI_CONNECTED; - else if (msg[6] == 0x0E) - wifi_link_state = WIFI_EXCEPTION; - else - wifi_link_state = WIFI_NOT_CONFIG; + // port + // connect state + switch (msg[6]) { + case 0x0A: wifi_link_state = WIFI_CONNECTED; break; + case 0x0E: wifi_link_state = WIFI_EXCEPTION; break; + default: wifi_link_state = WIFI_NOT_CONFIG; break; + } - //mode + // mode wifiPara.mode = msg[7]; - - //wifi name + // wifi name wifiNameLen = msg[8]; wifiKeyLen = msg[9 + wifiNameLen]; if (wifiNameLen < 32) { - memset(wifiPara.ap_name, 0, sizeof(wifiPara.ap_name)); + ZERO(wifiPara.ap_name); memcpy(wifiPara.ap_name, &msg[9], wifiNameLen); - memset(&wifi_list.wifiConnectedName,0,sizeof(wifi_list.wifiConnectedName)); - memcpy(&wifi_list.wifiConnectedName,&msg[9],wifiNameLen); + memset(&wifi_list.wifiConnectedName, 0, sizeof(wifi_list.wifiConnectedName)); + memcpy(&wifi_list.wifiConnectedName, &msg[9], wifiNameLen); - //wifi key + // wifi key if (wifiKeyLen < 64) { - memset(wifiPara.keyCode, 0, sizeof(wifiPara.keyCode)); + ZERO(wifiPara.keyCode); memcpy(wifiPara.keyCode, &msg[10 + wifiNameLen], wifiKeyLen); } } - cloud_para.state =msg[10 + wifiNameLen + wifiKeyLen]; hostLen = msg[11 + wifiNameLen + wifiKeyLen]; if (cloud_para.state) { if (hostLen < 96) { - memset(cloud_para.hostUrl, 0, sizeof(cloud_para.hostUrl)); + ZERO(cloud_para.hostUrl); memcpy(cloud_para.hostUrl, &msg[12 + wifiNameLen + wifiKeyLen], hostLen); } cloud_para.port = msg[12 + wifiNameLen + wifiKeyLen + hostLen] + (msg[13 + wifiNameLen + wifiKeyLen + hostLen] << 8); - } // id id_len = msg[14 + wifiNameLen + wifiKeyLen + hostLen]; if (id_len == 20) { - memset(cloud_para.id, 0, sizeof(cloud_para.id)); + ZERO(cloud_para.id); memcpy(cloud_para.id, (const char *)&msg[15 + wifiNameLen + wifiKeyLen + hostLen], id_len); } ver_len = msg[15 + wifiNameLen + wifiKeyLen + hostLen + id_len]; if (ver_len < 20) { - memset(wifi_firm_ver, 0, sizeof(wifi_firm_ver)); + ZERO(wifi_firm_ver); memcpy(wifi_firm_ver, (const char *)&msg[16 + wifiNameLen + wifiKeyLen + hostLen + id_len], ver_len); } @@ -1155,35 +1061,29 @@ static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { } static void wifi_list_msg_handle(uint8_t * msg, uint16_t msgLen) { - int wifiNameLen,wifiMsgIdex=1; - int8_t wifi_name_is_same=0; - int8_t i,j; - int8_t wifi_name_num=0; - uint8_t *str=0; + int wifiNameLen,wifiMsgIdex = 1; + int8_t wifi_name_is_same = 0; + int8_t i, j; + int8_t wifi_name_num = 0; + uint8_t *str = 0; int8_t valid_name_num; - if (msgLen <= 0) - return; - if (disp_state == KEY_BOARD_UI) - return; + if (msgLen <= 0) return; + if (disp_state == KEY_BOARD_UI) return; wifi_list.getNameNum = msg[0]; if (wifi_list.getNameNum < 20) { uiCfg.command_send = 1; - - memset(wifi_list.wifiName,0,sizeof(wifi_list.wifiName)); - + ZERO(wifi_list.wifiName); wifi_name_num = wifi_list.getNameNum; - - valid_name_num=0; - str = wifi_list.wifiName[valid_name_num]; + valid_name_num = 0; + str = wifi_list.wifiName[0]; if (wifi_list.getNameNum > 0) wifi_list.currentWifipage = 1; - for (i = 0; i 0x80) { wifi_name_is_same = 1; //break; @@ -1211,65 +1110,50 @@ static void wifi_list_msg_handle(uint8_t * msg, uint16_t msgLen) { //i--; continue; } - if (i < WIFI_TOTAL_NUMBER-1) { + if (i < WIFI_TOTAL_NUMBER - 1) str = wifi_list.wifiName[++valid_name_num]; - } } - wifiMsgIdex += wifiNameLen; - wifi_list.RSSI[i] = msg[wifiMsgIdex]; - wifiMsgIdex += 1; + wifiMsgIdex += wifiNameLen; + wifi_list.RSSI[i] = msg[wifiMsgIdex++]; } wifi_list.getNameNum = wifi_name_num; - if (wifi_list.getNameNum % NUMBER_OF_PAGE == 0) { - wifi_list.getPage = wifi_list.getNameNum/NUMBER_OF_PAGE; - } - else { - wifi_list.getPage = wifi_list.getNameNum/NUMBER_OF_PAGE + 1; - } + wifi_list.getPage = wifi_list.getNameNum / NUMBER_OF_PAGE + ((wifi_list.getNameNum % NUMBER_OF_PAGE) != 0); wifi_list.nameIndex = 0; - if (disp_state == WIFI_LIST_UI) - disp_wifi_list(); + + if (disp_state == WIFI_LIST_UI) disp_wifi_list(); } } static void gcode_msg_handle(uint8_t * msg, uint16_t msgLen) { - uint8_t gcodeBuf[100] = {0}; - char *index_s; - char *index_e; + uint8_t gcodeBuf[100] = { 0 }; + char *index_s, *index_e; - if (msgLen <= 0) - return; + if (msgLen <= 0) return; index_s = (char *)msg; - index_e = (char *)strstr((char *)msg, "\n"); + index_e = (char *)strchr((char *)msg, '\n'); if (*msg == 'N') { - index_s = (char *)strstr((char *)msg, " "); - while ((*index_s) == ' ') { - index_s++; - } + index_s = (char *)strchr((char *)msg, ' '); + while (*index_s == ' ') index_s++; } while ((index_e != 0) && ((int)index_s < (int)index_e)) { if ((int)(index_e - index_s) < (int)sizeof(gcodeBuf)) { - memset(gcodeBuf, 0, sizeof(gcodeBuf)); - + ZERO(gcodeBuf); memcpy(gcodeBuf, index_s, index_e - index_s + 1); - wifi_gcode_exec(gcodeBuf); } - while ((*index_e == '\r') || (*index_e == '\n')) - index_e++; - + while ((*index_e == '\r') || (*index_e == '\n')) index_e++; index_s = index_e; - index_e = (char *)strstr(index_s, "\n"); + index_e = (char *)strchr(index_s, '\n'); } } void utf8_2_unicode(uint8_t *source,uint8_t Len) { - uint8_t i=0,char_i=0,char_byte_num=0; - uint16_t u16_h,u16_m,u16_l,u16_value; + uint8_t i = 0, char_i = 0, char_byte_num = 0; + uint16_t u16_h, u16_m, u16_l, u16_value; uint8_t FileName_unicode[30]; - memset(FileName_unicode, 0, sizeof(FileName_unicode)); + ZERO(FileName_unicode); while (1) { char_byte_num = source[i] & 0xF0; @@ -1282,8 +1166,8 @@ void utf8_2_unicode(uint8_t *source,uint8_t Len) { else if (char_byte_num == 0XC0 || char_byte_num == 0XD0) { //--2byte - u16_h = (((uint16_t)source[i] <<8) & 0x1F00) >> 2; - u16_l = ((uint16_t)source[i+1] & 0x003F); + u16_h = (((uint16_t)source[i] << 8) & 0x1F00) >> 2; + u16_l = ((uint16_t)source[i + 1] & 0x003F); u16_value = (u16_h | u16_l); FileName_unicode[char_i] = (uint8_t)((u16_value & 0xFF00) >> 8); FileName_unicode[char_i + 1] = (uint8_t)(u16_value & 0x00FF); @@ -1292,9 +1176,9 @@ void utf8_2_unicode(uint8_t *source,uint8_t Len) { } else if (char_byte_num == 0XE0) { //--3byte - u16_h = (((uint16_t)source[i] <<8 ) & 0x0F00) << 4; - u16_m = (((uint16_t)source[i+1] << 8) & 0x3F00) >> 2; - u16_l = ((uint16_t)source[i+2] & 0x003F); + u16_h = (((uint16_t)source[i] << 8) & 0x0F00) << 4; + u16_m = (((uint16_t)source[i + 1] << 8) & 0x3F00) >> 2; + u16_l = ((uint16_t)source[i + 2] & 0x003F); u16_value = (u16_h | u16_m | u16_l); FileName_unicode[char_i] = (uint8_t)((u16_value & 0xFF00) >> 8); FileName_unicode[char_i + 1] = (uint8_t)(u16_value & 0x00FF); @@ -1309,9 +1193,9 @@ void utf8_2_unicode(uint8_t *source,uint8_t Len) { else { break; } - if (i >= Len || i >= 255)break; + if (i >= Len || i >= 255) break; } - memcpy(source, FileName_unicode, sizeof(FileName_unicode)); + COPY(source, FileName_unicode); } char saveFilePath[50]; @@ -1343,18 +1227,18 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { if (msgLen != fileNameLen + 5) return; file_writer.fileLen = *((uint32_t *)(msg + 1)); - memset(file_writer.saveFileName, 0, sizeof(file_writer.saveFileName)); + ZERO(file_writer.saveFileName); memcpy(file_writer.saveFileName, msg + 5, fileNameLen); utf8_2_unicode(file_writer.saveFileName,fileNameLen); - memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + ZERO(file_writer.write_buf); if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath)) return; - memset(saveFilePath, 0, sizeof(saveFilePath)); + ZERO(saveFilePath); if (gCfgItems.fileSysType == FILE_SYS_SD) { //sprintf((char *)saveFilePath, "/%s", file_writer.saveFileName); @@ -1392,7 +1276,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { sprintf((char *)saveFilePath, "/%s", dosName); ZERO(list_file.long_name[sel_id]); - memcpy(list_file.long_name[sel_id],dosName,sizeof(dosName)); + memcpy(list_file.long_name[sel_id], dosName, sizeof(dosName)); char *cur_name=strrchr((const char *)saveFilePath,'/'); @@ -1412,7 +1296,8 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); return; } - #endif + + #endif // SDSUPPORT wifi_link_state = WIFI_TRANS_FILE; @@ -1432,14 +1317,14 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { uint32_t frag = *((uint32_t *)msg); if ((frag & FRAG_MASK) != (uint32_t)(lastFragment + 1)) { - memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + ZERO(file_writer.write_buf); file_writer.write_index = 0; wifi_link_state = WIFI_CONNECTED; upload_result = 2; } else { if (write_to_file((char *)msg + 4, msgLen - 4) < 0) { - memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + ZERO(file_writer.write_buf); file_writer.write_index = 0; wifi_link_state = WIFI_CONNECTED; upload_result = 2; @@ -1450,13 +1335,13 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { if ((frag & (~FRAG_MASK))) { int res = card.write(file_writer.write_buf, file_writer.write_index); if (res == -1) { - memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + ZERO(file_writer.write_buf); file_writer.write_index = 0; wifi_link_state = WIFI_CONNECTED; upload_result = 2; return; } - memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + ZERO(file_writer.write_buf); file_writer.write_index = 0; file_writer.tick_end = getWifiTick(); upload_time = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000; @@ -1493,7 +1378,7 @@ void esp_data_parser(char *cmdRxBuf, int len) { if (tail_pos == -1) { if (esp_msg_index >= sizeof(esp_msg_buf)) { - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + ZERO(esp_msg_buf); esp_msg_index = 0; } return; @@ -1503,7 +1388,7 @@ void esp_data_parser(char *cmdRxBuf, int len) { head_pos = charAtArray((uint8_t const *)&cmdRxBuf[len - leftLen], leftLen, ESP_PROTOC_HEAD); if (head_pos == -1) return; - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + ZERO(esp_msg_buf); memcpy(esp_msg_buf, &cmdRxBuf[len - leftLen + head_pos], leftLen - head_pos); esp_msg_index = leftLen - head_pos; @@ -1513,7 +1398,7 @@ void esp_data_parser(char *cmdRxBuf, int len) { tail_pos = charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL); if (tail_pos == -1) { if (esp_msg_index >= sizeof(esp_msg_buf)) { - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + ZERO(esp_msg_buf); esp_msg_index = 0; } return; @@ -1521,10 +1406,13 @@ void esp_data_parser(char *cmdRxBuf, int len) { } esp_frame.type = esp_msg_buf[1]; - if ((esp_frame.type != ESP_TYPE_NET) && (esp_frame.type != ESP_TYPE_GCODE) - && (esp_frame.type != ESP_TYPE_FILE_FIRST) && (esp_frame.type != ESP_TYPE_FILE_FRAGMENT) - &&(esp_frame.type != ESP_TYPE_WIFI_LIST)) { - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + if ( esp_frame.type != ESP_TYPE_NET + && esp_frame.type != ESP_TYPE_GCODE + && esp_frame.type != ESP_TYPE_FILE_FIRST + && esp_frame.type != ESP_TYPE_FILE_FRAGMENT + && esp_frame.type != ESP_TYPE_WIFI_LIST + ) { + ZERO(esp_msg_buf); esp_msg_index = 0; return; } @@ -1532,14 +1420,14 @@ void esp_data_parser(char *cmdRxBuf, int len) { esp_frame.dataLen = esp_msg_buf[2] + (esp_msg_buf[3] << 8); if ((int)(4 + esp_frame.dataLen) > (int)(sizeof(esp_msg_buf))) { - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + ZERO(esp_msg_buf); esp_msg_index = 0; return; } if (esp_msg_buf[4 + esp_frame.dataLen] != ESP_PROTOC_TAIL) { if (esp_msg_index >= sizeof(esp_msg_buf)) { - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + ZERO(esp_msg_buf); esp_msg_index = 0; } return; @@ -1568,7 +1456,7 @@ void esp_data_parser(char *cmdRxBuf, int len) { esp_msg_index = cut_msg_head(esp_msg_buf, esp_msg_index, esp_frame.dataLen + 5); if (esp_msg_index > 0) { if (charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_HEAD) == -1) { - memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + ZERO(esp_msg_buf); esp_msg_index = 0; return; } @@ -1626,7 +1514,7 @@ void stopEspTransfer() { void wifi_rcv_handle() { int32_t len = 0; - uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = {0}; + uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = { 0 }; int8_t getDataF = 0; if (wifi_link_state == WIFI_TRANS_FILE) { @@ -1717,7 +1605,7 @@ void wifi_rcv_handle() { } void wifi_looping() { - do { wifi_rcv_handle(); } while (wifi_link_state == WIFI_TRANS_FILE); + do { wifi_rcv_handle(); } while (wifi_link_state == WIFI_TRANS_FILE); } void mks_esp_wifi_init() { diff --git a/Marlin/src/pins/esp32/pins_E4D.h b/Marlin/src/pins/esp32/pins_E4D.h index 7b5595444c..ebb8e1af7d 100644 --- a/Marlin/src/pins/esp32/pins_E4D.h +++ b/Marlin/src/pins/esp32/pins_E4D.h @@ -42,30 +42,30 @@ // // Limit Switches // -#define X_MIN_PIN 34 -#define Y_MIN_PIN 35 -#define Z_MIN_PIN 16 // 15 +#define X_STOP_PIN 34 +#define Y_STOP_PIN 35 +#define Z_STOP_PIN 16 // // Steppers // -#define X_STEP_PIN 12 // 34//27 -#define X_DIR_PIN 13 // 35//26 -#define X_ENABLE_PIN 17 // 0//17//25 // used free pin +#define X_STEP_PIN 12 +#define X_DIR_PIN 13 +#define X_ENABLE_PIN 17 //#define X_CS_PIN 0 -#define Y_STEP_PIN 32 // 33 -#define Y_DIR_PIN 33 // 32 +#define Y_STEP_PIN 32 +#define Y_DIR_PIN 33 #define Y_ENABLE_PIN X_ENABLE_PIN //#define Y_CS_PIN 13 -#define Z_STEP_PIN 25 // 14 -#define Z_DIR_PIN 26 // 12 +#define Z_STEP_PIN 25 +#define Z_DIR_PIN 26 #define Z_ENABLE_PIN X_ENABLE_PIN //#define Z_CS_PIN 5 // SS_PIN -#define E0_STEP_PIN 27 // 16 -#define E0_DIR_PIN 14 // 17 +#define E0_STEP_PIN 27 +#define E0_DIR_PIN 14 #define E0_ENABLE_PIN X_ENABLE_PIN //#define E0_CS_PIN 21 @@ -78,9 +78,9 @@ // // Heaters / Fans // -#define HEATER_0_PIN 2 // 4//2//(D8) -#define FAN_PIN 0 // 2//15//13 (D9) -#define HEATER_BED_PIN 15 // 15//0 //(D10) +#define HEATER_0_PIN 2 +#define FAN_PIN 0 +#define HEATER_BED_PIN 15 // SPI #define SDSS 5 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 8792cd3dfa..5259b147fb 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -666,6 +666,7 @@ // // Custom board (with custom PIO env) // + #elif MB(CUSTOM) #include "pins_custom.h" // env:custom diff --git a/platformio.ini b/platformio.ini index 9d5f6c5ab8..8416b93a27 100644 --- a/platformio.ini +++ b/platformio.ini @@ -977,7 +977,6 @@ extends = env:mks_robin extra_scripts = ${common.extra_scripts} buildroot/share/PlatformIO/scripts/mks_robin_pro.py - # # TRIGORILLA PRO (STM32F103ZET6) # @@ -1026,7 +1025,6 @@ board = genericSTM32F103RC extra_scripts = ${common.extra_scripts} buildroot/share/PlatformIO/scripts/mks_robin_lite.py - # # MKS ROBIN LITE3 (STM32F103RCT6) #