diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 40ce54fb9b..a49fd586d9 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -378,6 +378,28 @@ void startOrResumeJob() { print_job_timer.start(); } +void abortSDPrinting() { + card.stopSDPrint( + #if SD_RESORT + true + #endif + ); + queue.clear(); + quickstop_stepper(); + print_job_timer.stop(); + #if DISABLED(SD_ABORT_NO_COOLDOWN) + thermalManager.disable_all_heaters(); + #endif + thermalManager.zero_fan_speeds(); + wait_for_heatup = false; + #if ENABLED(POWER_LOSS_RECOVERY) + card.removeJobRecoveryFile(); + #endif + #ifdef EVENT_GCODE_SD_STOP + queue.inject_P(PSTR(EVENT_GCODE_SD_STOP)); + #endif +} + /** * Manage several activities: * - Check for Filament Runout @@ -1124,34 +1146,12 @@ void loop() { idle(); // Do an idle first so boot is slightly faster #if ENABLED(SDSUPPORT) - card.checkautostart(); - - if (card.flag.abort_sd_printing) { - card.stopSDPrint( - #if SD_RESORT - true - #endif - ); - queue.clear(); - quickstop_stepper(); - print_job_timer.stop(); - #if DISABLED(SD_ABORT_NO_COOLDOWN) - thermalManager.disable_all_heaters(); - #endif - thermalManager.zero_fan_speeds(); - wait_for_heatup = false; - #if ENABLED(POWER_LOSS_RECOVERY) - card.removeJobRecoveryFile(); - #endif - #ifdef EVENT_GCODE_SD_STOP - queue.inject_P(PSTR(EVENT_GCODE_SD_STOP)); - #endif - } - - #endif // SDSUPPORT + if (card.flag.abort_sd_printing) abortSDPrinting(); + #endif queue.advance(); + endstops.event_handler(); } }