power panic: Fix an error in saved position
planner_abort_hard() calls planner_reset_position() which will set current_position vector to the machine position. We want to save this position when there is no position already saved (i.e. when there is no partial back-up or a saved print in RAM) When a power outage comes, the printer is in the middle of a gcode move. And at the moment a gcode is executed by the planner, the planner will update current_position vector to the final destination vector. This means current_position vector is invalidated during a power outage and so we must check what the actual machine position is instead and save it. This was working correctly before, this commit only fixes the regression in my pull request. Change in memory: Flash: -2 bytes SRAM: 0 bytes
This commit is contained in:
parent
5ee7ba84e3
commit
005f9f0d24
|
|
@ -73,14 +73,13 @@ void uvlo_() {
|
|||
saved_extruder_temperature = target_temperature[active_extruder];
|
||||
saved_extruder_relative_mode = axis_relative_modes & E_AXIS_MASK;
|
||||
saved_fan_speed = fanSpeed;
|
||||
memcpy(saved_pos, current_position, sizeof(saved_pos));
|
||||
if (pos_invalid) saved_pos[X_AXIS] = X_COORD_INVALID;
|
||||
}
|
||||
|
||||
// Stop all heaters before continuing
|
||||
setTargetHotend(0);
|
||||
setTargetBed(0);
|
||||
|
||||
// Fetch data not included in a partial back-up
|
||||
if (!sd_print_saved_in_ram) {
|
||||
// Calculate the file position, from which to resume this print.
|
||||
save_print_file_state();
|
||||
|
|
@ -100,6 +99,14 @@ void uvlo_() {
|
|||
// are in action.
|
||||
planner_abort_hard();
|
||||
|
||||
// When there is no position already saved, then we must grab whatever the current position is.
|
||||
// This is most likely a position where the printer is in the middle of a G-code move
|
||||
if (!sd_print_saved_in_ram && !isPartialBackupAvailable)
|
||||
{
|
||||
memcpy(saved_pos, current_position, sizeof(saved_pos));
|
||||
if (pos_invalid) saved_pos[X_AXIS] = X_COORD_INVALID;
|
||||
}
|
||||
|
||||
// Store the print logical Z position, which we need to recover (a slight error here would be
|
||||
// recovered on the next Gcode instruction, while a physical location error would not)
|
||||
float logical_z = saved_pos[Z_AXIS];
|
||||
|
|
|
|||
Loading…
Reference in New Issue