From cca5844ba9ddf44d3ff53fdd6115d80f806ba9ac Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 7 May 2021 22:39:34 -0500 Subject: [PATCH] Misc. code cleanup --- Marlin/src/MarlinCore.cpp | 4 ++-- Marlin/src/gcode/queue.cpp | 10 +++------- Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 4 ++-- Marlin/src/lcd/extui/mks_ui/draw_ui.cpp | 4 +--- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 12 ++++-------- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 2794b8069..78a881a1d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -390,8 +390,8 @@ void startOrResumeJob() { } inline void finishSDPrinting() { - if (queue.enqueue_one_P(PSTR("M1001"))) { - marlin_state = MF_RUNNING; + if (queue.enqueue_one_P(PSTR("M1001"))) { // Keep trying until it gets queued + marlin_state = MF_RUNNING; // Signal to stop trying TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine()); TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished()); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 319ebe8a1..47b7d1feb 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -501,13 +501,9 @@ void GCodeQueue::get_serial_commands() { char* gpos = strchr(command, 'G'); if (gpos) { switch (strtol(gpos + 1, nullptr, 10)) { - case 0: case 1: - #if ENABLED(ARC_SUPPORT) - case 2: case 3: - #endif - #if ENABLED(BEZIER_CURVE_SUPPORT) - case 5: - #endif + case 0 ... 1: + TERN_(ARC_SUPPORT, case 2 ... 3:) + TERN_(BEZIER_CURVE_SUPPORT, case 5:) PORT_REDIRECT(SERIAL_PORTMASK(p)); // Reply to the serial port that sent the command SERIAL_ECHOLNPGM(STR_ERR_STOPPED); LCD_MESSAGEPGM(MSG_STOPPED); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index d31a1dcac..c502d0ae2 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -1477,7 +1477,7 @@ void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) { void DGUSScreenHandler::DGUS_RunoutInit(void) { #if PIN_EXISTS(MT_DET_1) - pinMode(MT_DET_1_PIN, INPUT_PULLUP); + SET_INPUT_PULLUP(MT_DET_1_PIN); #endif runout_mks.de_count = 0; runout_mks.de_times = 10; @@ -1496,7 +1496,7 @@ void DGUSScreenHandler::DGUS_Runout_Idle(void) { GotoScreen(MKSLCD_SCREEN_PAUSE); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please change filament!"), nullptr, true, true, true, true); - // SetupConfirmAction(nullptr); + //SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index c5ae77dd6..4134759b7 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -645,9 +645,7 @@ char *creat_title_text() { gcode_preview_over = false; card.closefile(); - char *cur_name; - - cur_name = strrchr(list_file.file_name[sel_id], '/'); + char *cur_name = strrchr(list_file.file_name[sel_id], '/'); SdFile file; SdFile *curDir; diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 897137d01..1e3262be3 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -1789,18 +1789,14 @@ void get_wifi_commands() { char* command = wifi_line_buffer; while (*command == ' ') command++; // skip any leading spaces - // Movement commands alert when stopped - if (IsStopped()) { + // Movement commands alert when stopped + if (IsStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { switch (strtol(gpos + 1, nullptr, 10)) { case 0 ... 1: - #if ENABLED(ARC_SUPPORT) - case 2 ... 3: - #endif - #if ENABLED(BEZIER_CURVE_SUPPORT) - case 5: - #endif + TERN_(ARC_SUPPORT, case 2 ... 3:) + TERN_(BEZIER_CURVE_SUPPORT, case 5:) SERIAL_ECHOLNPGM(STR_ERR_STOPPED); LCD_MESSAGEPGM(MSG_STOPPED); break;