From 6110a546351c7824fd2195692c0e12f80ab47b32 Mon Sep 17 00:00:00 2001 From: Zach Welch Date: Fri, 19 Oct 2018 12:23:46 -0700 Subject: [PATCH] Add M524 to abort SD printing (#11386) --- Marlin/Marlin_main.cpp | 53 ++++++++++++++++++++++++++---------------- Marlin/cardreader.cpp | 2 +- Marlin/cardreader.h | 2 +- Marlin/ultralcd.cpp | 4 +--- Marlin/ultralcd.h | 6 ----- 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index e7d8a78bca..fdec77414b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -206,6 +206,7 @@ * M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS) * M502 - Revert to the default "factory settings". ** Does not write them to EEPROM! ** * M503 - Print the current settings (in memory): "M503 S". S0 specifies compact output. + * M524 - Abort SD card print job started with M24 (Requires SDSUPPORT) * M540 - Enable/disable SD card abort on endstop hit: "M540 S". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) @@ -10838,6 +10839,17 @@ inline void gcode_M502() { } #endif +#if ENABLED(SDSUPPORT) + + /** + * M524: Abort the current SD print job (started with M24) + */ + inline void gcode_M524() { + if (IS_SD_PRINTING()) card.abort_sd_printing = true; + } + +#endif // SDSUPPORT + #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) /** @@ -13017,6 +13029,10 @@ void process_parsed_command() { case 504: gcode_M504(); break; // M504: Validate EEPROM #endif + #if ENABLED(SDSUPPORT) + case 524: gcode_M524(); break; // M524: Abort SD print job + #endif + #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) case 540: gcode_M540(); break; // M540: Set Abort on Endstop Hit for SD Printing #endif @@ -15296,27 +15312,24 @@ void loop() { card.checkautostart(); - #if ENABLED(ULTIPANEL) - if (abort_sd_printing) { - abort_sd_printing = false; - card.stopSDPrint( - #if SD_RESORT - true - #endif - ); - clear_command_queue(); - quickstop_stepper(); - print_job_timer.stop(); - thermalManager.disable_all_heaters(); - #if FAN_COUNT > 0 - for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0; + if (card.abort_sd_printing) { + card.stopSDPrint( + #if SD_RESORT + true #endif - wait_for_heatup = false; - #if ENABLED(POWER_LOSS_RECOVERY) - card.removeJobRecoveryFile(); - #endif - } - #endif + ); + clear_command_queue(); + quickstop_stepper(); + print_job_timer.stop(); + thermalManager.disable_all_heaters(); + #if FAN_COUNT > 0 + for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0; + #endif + wait_for_heatup = false; + #if ENABLED(POWER_LOSS_RECOVERY) + card.removeJobRecoveryFile(); + #endif + } #endif // SDSUPPORT diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 4f5fc0225e..082da72378 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -315,7 +315,7 @@ void CardReader::stopSDPrint( #if ENABLED(ADVANCED_PAUSE_FEATURE) did_pause_print = 0; #endif - sdprinting = false; + sdprinting = abort_sd_printing = false; if (isFileOpen()) file.close(); #if SD_RESORT if (re_sort) presort(); diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index fb6f003a99..c04347091e 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -117,7 +117,7 @@ public: FORCE_INLINE char* longest_filename() { return longFilename[0] ? longFilename : filename; } public: - bool saving, logging, sdprinting, cardOK, filenameIsDir; + bool saving, logging, sdprinting, cardOK, filenameIsDir, abort_sd_printing; char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH]; int8_t autostart_index; private: diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index d97349defe..5f5ceb7cb3 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -854,11 +854,9 @@ void lcd_quick_feedback(const bool clear_buttons) { lcd_reset_status(); } - bool abort_sd_printing; // =false - void lcd_sdcard_stop() { wait_for_heatup = wait_for_user = false; - abort_sd_printing = true; + card.abort_sd_printing = true; lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1); lcd_return_to_status(); } diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index d6bc799681..5386fa00ef 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -262,10 +262,4 @@ void lcd_reselect_last_file(); #endif -#if ENABLED(ULTIPANEL) && ENABLED(SDSUPPORT) - extern bool abort_sd_printing; -#else - constexpr bool abort_sd_printing = false; -#endif - #endif // ULTRALCD_H