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.
This commit is contained in:
Yuri D'Elia 2021-04-05 22:11:06 +02:00
parent 3276320a06
commit d2be40491b

View file

@ -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;