From d2be40491b62ea2169c431a734a48319ff0940f7 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 5 Apr 2021 22:11:06 +0200 Subject: [PATCH] PP recovery: clamp initial position to software endstops As done when initializing the printer from a cold start, we need to clamp the starting position to software endstops before setting the planner position since 0,0 is frequently out-of-bounds. This avoids an useless move during recovery that can cause a crash: - Initial X is set to be 0 - G1 performed by homing will clamp X>=0, resulting in a positive shift - If X is already at max X (extruder being parked due to PP), this will slam at X+, causing an immediate crash. --- Firmware/Marlin_main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 982a93db6..56da22763 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -11169,11 +11169,6 @@ bool recover_machine_state_after_power_panic() // Recover last E axis position current_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E)); - memcpy(destination, current_position, sizeof(destination)); - - SERIAL_ECHOPGM("recover_machine_state_after_power_panic, initial "); - print_world_coordinates(); - // 3) Initialize the logical to physical coordinate system transformation. world2machine_initialize(); // SERIAL_ECHOPGM("recover_machine_state_after_power_panic, initial "); @@ -11185,7 +11180,11 @@ bool recover_machine_state_after_power_panic() // 5) Set the physical positions from the logical positions using the world2machine transformation // This is only done to inizialize Z/E axes with physical locations, since X/Y are unknown. + clamp_to_software_endstops(current_position); + memcpy(destination, current_position, sizeof(destination)); plan_set_position_curposXYZE(); + SERIAL_ECHOPGM("recover_machine_state_after_power_panic, initial "); + print_world_coordinates(); // 6) Power up the Z motors, mark their positions as known. axis_known_position[Z_AXIS] = true;