diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 893a8d968b..ce4ffa0db9 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -898,6 +898,26 @@ void loop() { #endif for (;;) { + + #if ENABLED(SDSUPPORT) && 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; + #endif + wait_for_heatup = false; + } + #endif // SDSUPPORT && ULTIPANEL + if (commands_in_queue < BUFSIZE) get_available_commands(); advance_command_queue(); endstops.report_state(); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 242449ea60..59b1221e52 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -836,20 +836,10 @@ void kill_screen(const char* lcd_msg) { lcd_reset_status(); } + bool abort_sd_printing; // =false + void lcd_sdcard_stop() { - 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; - #endif - wait_for_heatup = false; + abort_sd_printing = true; lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1); lcd_return_to_status(); } diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index bfbddb436f..9af35467ae 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -261,4 +261,10 @@ void lcd_reset_status(); 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