Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort on endstop hit improvement: custom G-Code feature #24461

Merged
merged 7 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,11 @@
*/
//#define SD_ABORT_ON_ENDSTOP_HIT

/**
* Run custom G-Code when endstop hit occured.
*/
//#define SD_ABORT_ON_ENDSTOP_HIT_CUSTOM_GCODE "M300 S1000 P500"
Copy link
Member

@thisiskeithb thisiskeithb Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend grouping this under //#define SD_ABORT_ON_ENDSTOP_HIT and then wrap it with an #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT):

  /**
   * Abort SD printing when any endstop is triggered.
   * This feature is enabled with 'M540 S1' or from the LCD menu.
   * 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_CUSTOM_GCODE "G28XY"  // G-code to run on endstop hit (e.g., "G28XY" or "G27")
  #endif

Note: I've modified the default G-code to match EVENT_GCODE_SD_ABORT.


//#define SD_REPRINT_LAST_SELECTED_FILE // On print completion open the LCD Menu and select the same file

//#define AUTO_REPORT_SD_STATUS // Auto-report media status with 'M27 S<seconds>'
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ void Endstops::event_handler() {
card.abortFilePrintNow();
quickstop_stepper();
thermalManager.disable_all_heaters();
#ifdef SD_ABORT_ON_ENDSTOP_HIT_CUSTOM_GCODE
queue.clear();
queue.inject(F(SD_ABORT_ON_ENDSTOP_HIT_CUSTOM_GCODE));
#endif
print_job_timer.stop();
}
#endif
Expand Down