1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-29 23:07:42 +00:00

Add M524 to abort SD printing (#11386)

This commit is contained in:
Zach Welch 2018-10-19 12:23:46 -07:00 committed by Scott Lahteine
parent 86ac4683dd
commit 75298e654e
5 changed files with 36 additions and 31 deletions

View File

@ -206,6 +206,7 @@
* M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS) * M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS)
* M502 - Revert to the default "factory settings". ** Does not write them to EEPROM! ** * 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. * 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) * 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) * 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) * M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
@ -10838,6 +10839,17 @@ inline void gcode_M502() {
} }
#endif #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) #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
/** /**
@ -13017,6 +13029,10 @@ void process_parsed_command() {
case 504: gcode_M504(); break; // M504: Validate EEPROM case 504: gcode_M504(); break; // M504: Validate EEPROM
#endif #endif
#if ENABLED(SDSUPPORT)
case 524: gcode_M524(); break; // M524: Abort SD print job
#endif
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
case 540: gcode_M540(); break; // M540: Set Abort on Endstop Hit for SD Printing case 540: gcode_M540(); break; // M540: Set Abort on Endstop Hit for SD Printing
#endif #endif
@ -15296,27 +15312,24 @@ void loop() {
card.checkautostart(); card.checkautostart();
#if ENABLED(ULTIPANEL) if (card.abort_sd_printing) {
if (abort_sd_printing) { card.stopSDPrint(
abort_sd_printing = false; #if SD_RESORT
card.stopSDPrint( true
#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 #endif
wait_for_heatup = false; );
#if ENABLED(POWER_LOSS_RECOVERY) clear_command_queue();
card.removeJobRecoveryFile(); quickstop_stepper();
#endif print_job_timer.stop();
} thermalManager.disable_all_heaters();
#endif #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 #endif // SDSUPPORT

View File

@ -315,7 +315,7 @@ void CardReader::stopSDPrint(
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)
did_pause_print = 0; did_pause_print = 0;
#endif #endif
sdprinting = false; sdprinting = abort_sd_printing = false;
if (isFileOpen()) file.close(); if (isFileOpen()) file.close();
#if SD_RESORT #if SD_RESORT
if (re_sort) presort(); if (re_sort) presort();

View File

@ -117,7 +117,7 @@ public:
FORCE_INLINE char* longest_filename() { return longFilename[0] ? longFilename : filename; } FORCE_INLINE char* longest_filename() { return longFilename[0] ? longFilename : filename; }
public: public:
bool saving, logging, sdprinting, cardOK, filenameIsDir; bool saving, logging, sdprinting, cardOK, filenameIsDir, abort_sd_printing;
char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH]; char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
int8_t autostart_index; int8_t autostart_index;
private: private:

View File

@ -854,11 +854,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
lcd_reset_status(); lcd_reset_status();
} }
bool abort_sd_printing; // =false
void lcd_sdcard_stop() { void lcd_sdcard_stop() {
wait_for_heatup = wait_for_user = false; wait_for_heatup = wait_for_user = false;
abort_sd_printing = true; card.abort_sd_printing = true;
lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1); lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
lcd_return_to_status(); lcd_return_to_status();
} }

View File

@ -262,10 +262,4 @@
void lcd_reselect_last_file(); void lcd_reselect_last_file();
#endif #endif
#if ENABLED(ULTIPANEL) && ENABLED(SDSUPPORT)
extern bool abort_sd_printing;
#else
constexpr bool abort_sd_printing = false;
#endif
#endif // ULTRALCD_H #endif // ULTRALCD_H