Skip to content

Commit

Permalink
Fix Resume Print with UBL (MarlinFirmware#21564)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
espr14 and thinkyhead authored Apr 13, 2021
1 parent 41c55a3 commit a5d6f6a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
10 changes: 6 additions & 4 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,13 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
unscaled_e_move(-(PAUSE_PARK_RETRACT_LENGTH), feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));

if (!axes_should_home()) {
// Move XY to starting position, then Z
do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE));
// Move XY back to saved position
destination.set(resume_position.x, resume_position.y, current_position.z);
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);

// Move Z_AXIS to saved position
do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
// Move Z back to saved position
destination.z = resume_position.z;
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
}

// Unretract
Expand Down
17 changes: 12 additions & 5 deletions Marlin/src/gcode/feature/pause/M701_M702.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ void GcodeSuite::M701() {
tool_change(target_extruder, false);
#endif

// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
auto move_z_by = [](const_float_t zdist) {
if (zdist) {
destination = current_position;
destination.z += zdist;
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
}
};

// Raise the Z axis (with max limit)
const float park_raise = _MIN(0, park_point.z, (Z_MAX_POS) - current_position.z);
move_z_by(park_raise);

// Load filament
#if HAS_PRUSA_MMU2
Expand All @@ -113,8 +121,7 @@ void GcodeSuite::M701() {
#endif

// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
move_z_by(-park_raise);

#if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU)
// Restore toolhead if it was changed
Expand Down
13 changes: 11 additions & 2 deletions Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ xyz_pos_t position_before_pause;
void MKS_pause_print_move() {
queue.exhaust();
position_before_pause = current_position;
do_blocking_move_to(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y, current_position.z + mks_park_pos.z);
destination.z = _MIN(current_position.z + mks_park_pos.z, Z_MAX_POS);
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
destination.set(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y);
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);
}

void MKS_resume_print_move() {
destination.set(position_before_pause.x, position_before_pause.y);
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);
destination.z = position_before_pause.z;
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
}
void MKS_resume_print_move() { do_blocking_move_to(position_before_pause); }

float z_offset_add = 0;

Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
#if ENABLED(TOOLCHANGE_PARK)
if (ok) {
#if ENABLED(TOOLCHANGE_NO_RETURN)
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
destination.set(current_position.x, current_position.y);
prepare_internal_move_to_destination(planner.settings.max_feedrate_mm_s[Z_AXIS]);
#else
do_blocking_move_to(destination, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE));
prepare_internal_move_to_destination(MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE));
#endif
}
#endif
Expand Down

0 comments on commit a5d6f6a

Please sign in to comment.