Abort SD printing more safely (#10405)

Allow the current command to complete when aborting an SD print, otherwise some commands (G28, G29, etc.) will cause trouble.
This commit is contained in:
Scott Lahteine 2018-04-15 18:26:25 -05:00 committed by GitHub
parent 110e631656
commit d59ed4dce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 15 deletions

View File

@ -14220,6 +14220,7 @@ void setup() {
/**
* The main Marlin program loop
*
* - Abort SD printing if flagged
* - Save or log commands to SD
* - Process available commands (if not saving)
* - Call heater manager
@ -14228,11 +14229,33 @@ void setup() {
* - Call LCD update
*/
void loop() {
if (commands_in_queue < BUFSIZE) get_available_commands();
#if ENABLED(SDSUPPORT)
card.checkautostart(false);
#endif
#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;
#endif
wait_for_heatup = false;
}
#endif
#endif // SDSUPPORT
if (commands_in_queue < BUFSIZE) get_available_commands();
if (commands_in_queue) {

View File

@ -829,20 +829,10 @@ void kill_screen(const char* lcd_msg) {
lcd_reset_status();
}
bool abort_sd_printing; // =false
void lcd_sdcard_stop() {
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;
#endif
wait_for_heatup = false;
abort_sd_printing = true;
lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
lcd_return_to_status();
}

View File

@ -254,4 +254,10 @@ void lcd_reset_status();
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