diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 7dedc8a4b..a162d5c8a 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -455,6 +455,7 @@ extern void print_mesh_bed_leveling_table(); extern void stop_and_save_print_to_ram(float z_move, float e_move); extern void restore_print_from_ram_and_continue(float e_move); +extern void cancel_saved_printing(); //estimated time to end of the print diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f34899560..6684cf683 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10357,6 +10357,14 @@ void restore_print_from_ram_and_continue(float e_move) waiting_inside_plan_buffer_line_print_aborted = true; //unroll the stack } +// Cancel the state related to a currently saved print +void cancel_saved_printing() +{ + saved_target[0] = SAVED_TARGET_UNSET; + saved_printing_type = PRINTING_TYPE_NONE; + saved_printing = false; +} + void print_world_coordinates() { printf_P(_N("world coordinates: (%.3f, %.3f, %.3f)\n"), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5d0abeac9..d988e5488 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7312,30 +7312,26 @@ static void lcd_sd_updir() void lcd_print_stop() { -//-// - if(!card.sdprinting) - { - SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint - } - saved_printing = false; - saved_printing_type = PRINTING_TYPE_NONE; + if (!card.sdprinting) { + SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint + } + + CRITICAL_SECTION_START; + + // Clear any saved printing state + cancel_saved_printing(); cancel_heatup = true; -#ifdef MESH_BED_LEVELING - mbl.active = false; -#endif - // Stop the stoppers, update the position from the stoppers. - if (mesh_bed_leveling_flag == false && homing_flag == false) - { - planner_abort_hard(); - // Because the planner_abort_hard() initialized current_position[Z] from the stepper, - // Z baystep is no more applied. Reset it. - babystep_reset(); - } - // Clean the input command queue. + + // Abort the planner/queue/sd + planner_abort_hard(); cmdqueue_reset(); - lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); card.sdprinting = false; card.closefile(); + st_reset_timer(); + + CRITICAL_SECTION_END; + + lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); stoptime = _millis(); unsigned long t = (stoptime - starttime - pause_time) / 1000; //time in s pause_time = 0;