From 834ad14c8d43dd3496280717fcd428c88f870942 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 6 Jul 2016 12:00:28 -0700 Subject: [PATCH] Add quickstop_stepper to update current position with stepper.quick_stop() --- Marlin/Marlin.h | 4 +--- Marlin/MarlinSerial.cpp | 3 ++- Marlin/Marlin_main.cpp | 18 +++++++----------- Marlin/endstops.cpp | 5 +---- Marlin/ultralcd.cpp | 5 +---- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 9d40ce161..2159fb019 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -230,9 +230,7 @@ void ok_to_send(); void reset_bed_level(); void kill(const char*); -#if DISABLED(DELTA) && DISABLED(SCARA) - void set_current_position_from_planner(); -#endif +void quickstop_stepper(); #if ENABLED(FILAMENT_RUNOUT_SENSOR) void handle_filament_runout(); diff --git a/Marlin/MarlinSerial.cpp b/Marlin/MarlinSerial.cpp index 7f1920528..82812986b 100644 --- a/Marlin/MarlinSerial.cpp +++ b/Marlin/MarlinSerial.cpp @@ -450,7 +450,8 @@ MarlinSerial customizedSerial; case state_M41: switch (c) { case '0': - { state = state_RESET; stepper.quick_stop(); } + state = state_RESET; + quickstop_stepper(); break; case ';': state = state_IGNORE; diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c4cdbb731..3d8ba8443 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1109,7 +1109,7 @@ inline void get_serial_commands() { // If command was e-stop process now if (strcmp(command, "M108") == 0) wait_for_heatup = false; if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED)); - if (strcmp(command, "M410") == 0) stepper.quick_stop(); + if (strcmp(command, "M410") == 0) { quickstop_stepper(); } #endif #if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0 @@ -4556,12 +4556,7 @@ inline void gcode_M105() { * This will stop the carriages mid-move, so most likely they * will be out of sync with the stepper position after this. */ - inline void gcode_M410() { - stepper.quick_stop(); - #if DISABLED(DELTA) && DISABLED(SCARA) - set_current_position_from_planner(); - #endif - } + inline void gcode_M410() { quickstop_stepper(); } #endif @@ -5990,8 +5985,9 @@ inline void gcode_M400() { stepper.synchronize(); } #endif // FILAMENT_WIDTH_SENSOR -#if DISABLED(DELTA) && DISABLED(SCARA) - void set_current_position_from_planner() { +void quickstop_stepper() { + stepper.quick_stop(); + #if DISABLED(DELTA) && DISABLED(SCARA) stepper.synchronize(); #if ENABLED(AUTO_BED_LEVELING_FEATURE) vector_3 pos = planner.adjusted_position(); // values directly from steppers... @@ -6004,8 +6000,8 @@ inline void gcode_M400() { stepper.synchronize(); } current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS); #endif sync_plan_position(); // ...re-apply to planner position - } -#endif + #endif +} #if ENABLED(MESH_BED_LEVELING) diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 81a080ebf..3bfb67a11 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -186,10 +186,7 @@ void Endstops::report_state() { if (stepper.abort_on_endstop_hit) { card.sdprinting = false; card.closefile(); - stepper.quick_stop(); - #if DISABLED(DELTA) && DISABLED(SCARA) - set_current_position_from_planner(); - #endif + quickstop_stepper(); thermalManager.disable_all_heaters(); // switch off all heaters. } #endif diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index ca0db6d67..87104d87e 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -556,14 +556,11 @@ static void lcd_status_screen() { static void lcd_sdcard_stop() { card.stopSDPrint(); clear_command_queue(); - stepper.quick_stop(); + quickstop_stepper(); print_job_timer.stop(); thermalManager.autotempShutdown(); wait_for_heatup = false; lcd_setstatus(MSG_PRINT_ABORTED, true); - #if DISABLED(DELTA) && DISABLED(SCARA) - set_current_position_from_planner(); - #endif // !DELTA && !SCARA } #endif //SDSUPPORT