@ -151,6 +151,12 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
// Machine state
// Machine state
COPY ( info . current_position , current_position ) ;
COPY ( info . current_position , current_position ) ;
# if HAS_HOME_OFFSET
COPY ( info . home_offset , home_offset ) ;
# endif
# if HAS_POSITION_SHIFT
COPY ( info . position_shift , position_shift ) ;
# endif
info . feedrate = uint16_t ( feedrate_mm_s * 60.0f ) ;
info . feedrate = uint16_t ( feedrate_mm_s * 60.0f ) ;
# if HOTENDS > 1
# if HOTENDS > 1
@ -187,7 +193,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
info . retract_hop = fwretract . current_hop ;
info . retract_hop = fwretract . current_hop ;
# endif
# endif
//r elative mode
// R elative mode
info . relative_mode = relative_mode ;
info . relative_mode = relative_mode ;
info . relative_modes_e = gcode . axis_relative_modes [ E_AXIS ] ;
info . relative_modes_e = gcode . axis_relative_modes [ E_AXIS ] ;
@ -239,9 +245,9 @@ void PrintJobRecovery::resume() {
gcode . process_subcommands_now_P ( PSTR ( " M420 S0 Z0 " ) ) ;
gcode . process_subcommands_now_P ( PSTR ( " M420 S0 Z0 " ) ) ;
# endif
# endif
// Set Z to 0, raise Z by 2mm, and Home (XY only for Cartesian) with no raise
// Set Z to 0, raise Z by RECOVERY_ZRAISE, and Home (XY only for Cartesian)
// (Only do simulated homing in Marlin Dev Mode.)
// with no raise. (Only do simulated homing in Marlin Dev Mode.)
gcode . process_subcommands_now_P ( PSTR ( " G92.0 Z0 \n G1 Z " STRINGIFY ( RECOVERY_ZRAISE ) " \n G28 R0 "
gcode . process_subcommands_now_P ( PSTR ( " G92.9 E 0 Z0 \n G1 Z " STRINGIFY ( RECOVERY_ZRAISE ) " \n G28 R0 "
# if ENABLED(MARLIN_DEV_MODE)
# if ENABLED(MARLIN_DEV_MODE)
" S "
" S "
# elif !IS_KINEMATIC
# elif !IS_KINEMATIC
@ -252,7 +258,7 @@ void PrintJobRecovery::resume() {
// Pretend that all axes are homed
// Pretend that all axes are homed
axis_homed = axis_known_position = xyz_bits ;
axis_homed = axis_known_position = xyz_bits ;
char cmd [ 4 0] , str_1 [ 16 ] , str_2 [ 16 ] ;
char cmd [ 5 0] , str_1 [ 16 ] , str_2 [ 16 ] ;
// Select the previously active tool (with no_move)
// Select the previously active tool (with no_move)
# if EXTRUDERS > 1
# if EXTRUDERS > 1
@ -315,16 +321,16 @@ void PrintJobRecovery::resume() {
memcpy ( & mixer . gradient , & info . gradient , sizeof ( info . gradient ) ) ;
memcpy ( & mixer . gradient , & info . gradient , sizeof ( info . gradient ) ) ;
# endif
# endif
// Restore Z (plus raise) and E positions with G92.0
// Extrude and retract to clean the nozzle
dtostrf ( info . current_position [ Z_AXIS ] + RECOVERY_ZRAISE , 1 , 3 , str_1 ) ;
# if POWER_LOSS_PURGE_LEN
dtostrf ( info . current_position [ E_AXIS ]
//sprintf_P(cmd, PSTR("G1 E%d F200"), POWER_LOSS_PURGE_LEN);
# if ENABLED(SAVE_EACH_CMD_MODE)
//gcode.process_subcommands_now(cmd);
- 5 // Extra extrusion on restart
gcode . process_subcommands_now_P ( PSTR ( " G1 E " STRINGIFY ( POWER_LOSS_PURGE_LEN ) " F200 " ) ) ;
# endif
# endif
, 1 , 3 , str_2
# if POWER_LOSS_RETRACT_LEN
) ;
sprintf_P ( cmd , PSTR ( " G1 E%d F3000 " ) , POWER_LOSS_PURGE_LEN - POWER_LOSS_RETRACT_LEN ) ;
sprintf_P ( cmd , PSTR ( " G92.0 Z%s E%s " ) , str_1 , str_2 ) ;
gcode . process_subcommands_now ( cmd ) ;
gcode . process_subcommands_now ( cmd ) ;
# endif
// Move back to the saved XY
// Move back to the saved XY
dtostrf ( info . current_position [ X_AXIS ] , 1 , 3 , str_1 ) ;
dtostrf ( info . current_position [ X_AXIS ] , 1 , 3 , str_1 ) ;
@ -337,13 +343,37 @@ void PrintJobRecovery::resume() {
sprintf_P ( cmd , PSTR ( " G1 Z%s F200 " ) , str_1 ) ;
sprintf_P ( cmd , PSTR ( " G1 Z%s F200 " ) , str_1 ) ;
gcode . process_subcommands_now ( cmd ) ;
gcode . process_subcommands_now ( cmd ) ;
// Un-retract
# if POWER_LOSS_PURGE_LEN
//sprintf_P(cmd, PSTR("G1 E%d F3000"), POWER_LOSS_PURGE_LEN);
//gcode.process_subcommands_now(cmd);
gcode . process_subcommands_now_P ( PSTR ( " G1 E " STRINGIFY ( POWER_LOSS_PURGE_LEN ) " F3000 " ) ) ;
# endif
// Restore the feedrate
// Restore the feedrate
sprintf_P ( cmd , PSTR ( " G1 F%d " ) , info . feedrate ) ;
sprintf_P ( cmd , PSTR ( " G1 F%d " ) , info . feedrate ) ;
gcode . process_subcommands_now ( cmd ) ;
gcode . process_subcommands_now ( cmd ) ;
//relative mode
// Restore E position with G92.9
if ( info . relative_mode ) relative_mode = true ;
dtostrf ( info . current_position [ E_AXIS ] , 1 , 3 , str_1 ) ;
if ( info . relative_modes_e ) gcode . axis_relative_modes [ E_AXIS ] = true ;
sprintf_P ( cmd , PSTR ( " G92.9 E%s " ) , str_1 ) ;
gcode . process_subcommands_now ( cmd ) ;
// Relative mode
relative_mode = info . relative_mode ;
gcode . axis_relative_modes [ E_AXIS ] = info . relative_modes_e ;
# if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
LOOP_XYZ ( i ) {
# if HAS_HOME_OFFSET
home_offset [ i ] = info . home_offset [ i ] ;
# endif
# if HAS_POSITION_SHIFT
position_shift [ i ] = info . position_shift [ i ] ;
# endif
update_workspace_offset ( ( AxisEnum ) i ) ;
}
# endif
// Process commands from the old pending queue
// Process commands from the old pending queue
uint8_t c = info . commands_in_queue , r = info . cmd_queue_index_r ;
uint8_t c = info . commands_in_queue , r = info . cmd_queue_index_r ;
@ -372,6 +402,25 @@ void PrintJobRecovery::resume() {
DEBUG_ECHO ( info . current_position [ i ] ) ;
DEBUG_ECHO ( info . current_position [ i ] ) ;
}
}
DEBUG_EOL ( ) ;
DEBUG_EOL ( ) ;
# if HAS_HOME_OFFSET
DEBUG_ECHOPGM ( " home_offset: " ) ;
LOOP_XYZ ( i ) {
if ( i ) DEBUG_CHAR ( ' , ' ) ;
DEBUG_ECHO ( info . home_offset [ i ] ) ;
}
DEBUG_EOL ( ) ;
# endif
# if HAS_POSITION_SHIFT
DEBUG_ECHOPGM ( " position_shift: " ) ;
LOOP_XYZ ( i ) {
if ( i ) DEBUG_CHAR ( ' , ' ) ;
DEBUG_ECHO ( info . position_shift [ i ] ) ;
}
DEBUG_EOL ( ) ;
# endif
DEBUG_ECHOLNPAIR ( " feedrate: " , info . feedrate ) ;
DEBUG_ECHOLNPAIR ( " feedrate: " , info . feedrate ) ;
# if HOTENDS > 1
# if HOTENDS > 1