diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 921d36b7a8..b1a7662e71 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1589,6 +1589,9 @@ * Endstops must be activated for this option to work. */ //#define SD_ABORT_ON_ENDSTOP_HIT + #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) + //#define SD_ABORT_ON_ENDSTOP_HIT_GCODE "G28XY" // G-code to run on endstop hit (e.g., "G28XY" or "G27") + #endif //#define SD_REPRINT_LAST_SELECTED_FILE // On print completion open the LCD Menu and select the same file diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 33c94ae357..f4fbda747b 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -551,6 +551,10 @@ void Endstops::event_handler() { card.abortFilePrintNow(); quickstop_stepper(); thermalManager.disable_all_heaters(); + #ifdef SD_ABORT_ON_ENDSTOP_HIT_GCODE + queue.clear(); + queue.inject(F(SD_ABORT_ON_ENDSTOP_HIT_GCODE)); + #endif print_job_timer.stop(); } #endif