Skip to content

Commit

Permalink
Add M524 to abort SD printing (#11386)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachwelch authored and thinkyhead committed Oct 19, 2018
1 parent 86ac468 commit 75298e6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
53 changes: 33 additions & 20 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<verbose>". 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<state>". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
* M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
* M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
Expand Down Expand Up @@ -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)

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Marlin/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CardReader {
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:
Expand Down
4 changes: 1 addition & 3 deletions Marlin/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 0 additions & 6 deletions Marlin/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 75298e6

Please sign in to comment.