|
@@ -125,7 +125,6 @@ void FWRetract::retract(const bool retracting
|
125
|
125
|
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
|
126
|
126
|
//*/
|
127
|
127
|
|
128
|
|
- const bool has_zhop = retract_zlift > 0.01; // Is there a hop set?
|
129
|
128
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
130
|
129
|
|
131
|
130
|
// The current position will be the destination for E and Z moves
|
|
@@ -144,23 +143,25 @@ void FWRetract::retract(const bool retracting
|
144
|
143
|
// Is a Z hop set, and has the hop not yet been done?
|
145
|
144
|
// No double zlifting
|
146
|
145
|
// Feedrate to the max
|
147
|
|
- if (has_zhop && !hop_amount) {
|
148
|
|
- hop_amount += retract_zlift; // Carriage is raised for retraction hop
|
149
|
|
- feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
|
150
|
|
- current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z.
|
151
|
|
- SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
|
146
|
+ if (retract_zlift > 0.01 && !hop_amount) { // Apply hop only once
|
|
147
|
+ const float old_z = current_position[Z_AXIS];
|
|
148
|
+ hop_amount += retract_zlift; // Add to the hop total (again, only once)
|
|
149
|
+ destination[Z_AXIS] += retract_zlift; // Raise Z by the zlift (M207 Z) amount
|
|
150
|
+ feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Maximum Z feedrate
|
152
|
151
|
prepare_move_to_destination(); // Raise up to the old current pos
|
|
152
|
+ current_position[Z_AXIS] = old_z; // Spoof the Z position
|
|
153
|
+ SYNC_PLAN_POSITION_KINEMATIC();
|
153
|
154
|
}
|
154
|
155
|
}
|
155
|
156
|
else {
|
156
|
157
|
// If a hop was done and Z hasn't changed, undo the Z hop
|
157
|
158
|
if (hop_amount) {
|
158
|
|
- current_position[Z_AXIS] += retract_zlift; // Pretend current pos is higher. Next move lowers Z.
|
159
|
|
- SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
|
159
|
+ current_position[Z_AXIS] += hop_amount; // Set actual Z (due to the prior hop)
|
160
|
160
|
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
|
161
|
|
- prepare_move_to_destination(); // Lower down to the old current pos
|
162
|
|
- hop_amount = 0.0; // Clear hop
|
163
|
|
- }
|
|
161
|
+ prepare_move_to_destination(); // Lower Z and update current_position
|
|
162
|
+ SYNC_PLAN_POSITION_KINEMATIC(); // Update the planner
|
|
163
|
+ hop_amount = 0.0; // Clear the hop amount
|
|
164
|
+ }
|
164
|
165
|
|
165
|
166
|
// A retract multiplier has been added here to get faster swap recovery
|
166
|
167
|
feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;
|