G80: handle power panic

This is handled in the same way crash detection is handled: homing/mbl
invalidates saved_target _and_ current position.

Fixes PP recovery during MBL and homing.
This commit is contained in:
Yuri D'Elia 2021-04-06 02:20:00 +02:00
parent b46a52ffa8
commit 449d181971
1 changed files with 16 additions and 7 deletions

View File

@ -10851,8 +10851,9 @@ void uvlo_()
} }
// save the global state at planning time // save the global state at planning time
bool pos_invalid = XY_NO_RESTORE_FLAG;
uint16_t feedrate_bckp; uint16_t feedrate_bckp;
if (current_block) if (current_block && !pos_invalid)
{ {
memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); memcpy(saved_target, current_block->gcode_target, sizeof(saved_target));
feedrate_bckp = current_block->gcode_feedrate; feedrate_bckp = current_block->gcode_feedrate;
@ -10930,8 +10931,13 @@ void uvlo_()
eeprom_update_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS), z_microsteps); eeprom_update_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS), z_microsteps);
// Store the current position. // Store the current position.
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), current_position[X_AXIS]); if (pos_invalid)
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), X_COORD_INVALID);
else
{
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), current_position[X_AXIS]);
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]);
}
// Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates) // Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates)
eeprom_update_word((uint16_t*)EEPROM_UVLO_FEEDRATE, feedrate_bckp); eeprom_update_word((uint16_t*)EEPROM_UVLO_FEEDRATE, feedrate_bckp);
@ -11282,10 +11288,13 @@ void restore_print_from_eeprom(bool mbl_was_active) {
// Move to the XY print position in logical coordinates, where the print has been killed, but // Move to the XY print position in logical coordinates, where the print has been killed, but
// without shifting Z along the way. This requires performing the move without mbl. // without shifting Z along the way. This requires performing the move without mbl.
sprintf_P(cmd, PSTR("G1 X%f Y%f F3000"), float pos_x = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0));
eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)), float pos_y = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4));
eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4))); if (pos_x != X_COORD_INVALID)
enquecommand(cmd); {
sprintf_P(cmd, PSTR("G1 X%f Y%f F3000"), pos_x, pos_y);
enquecommand(cmd);
}
// Enable MBL and switch to logical positioning // Enable MBL and switch to logical positioning
if (mbl_was_active) if (mbl_was_active)