|
@@ -94,13 +94,16 @@ void FWRetract::retract(const bool retracting
|
94
|
94
|
#endif
|
95
|
95
|
) {
|
96
|
96
|
|
97
|
|
- static float hop_height, // Remember where the Z height started
|
98
|
|
- hop_amount = 0.0; // Total amount lifted, for use in recover
|
|
97
|
+ static float hop_amount = 0.0; // Total amount lifted, for use in recover
|
99
|
98
|
|
100
|
|
- // Simply never allow two retracts or recovers in a row
|
|
99
|
+ // Prevent two retracts or recovers in a row
|
101
|
100
|
if (retracted[active_extruder] == retracting) return;
|
102
|
101
|
|
|
102
|
+ // Prevent two swap-retract or recovers in a row
|
103
|
103
|
#if EXTRUDERS > 1
|
|
104
|
+ // Allow G10 S1 only after G10
|
|
105
|
+ if (swapping && retracted_swap[active_extruder] == retracting) return;
|
|
106
|
+ // G11 priority to recover the long retract if activated
|
104
|
107
|
if (!retracting) swapping = retracted_swap[active_extruder];
|
105
|
108
|
#else
|
106
|
109
|
const bool swapping = false;
|
|
@@ -121,64 +124,56 @@ void FWRetract::retract(const bool retracting
|
121
|
124
|
//*/
|
122
|
125
|
|
123
|
126
|
const bool has_zhop = retract_zlift > 0.01; // Is there a hop set?
|
124
|
|
-
|
125
|
127
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
126
|
|
- const int16_t old_flow = planner.flow_percentage[active_extruder];
|
127
|
|
-
|
128
|
|
- // Don't apply flow multiplication to retract/recover
|
129
|
|
- planner.flow_percentage[active_extruder] = 100;
|
130
|
128
|
|
131
|
129
|
// The current position will be the destination for E and Z moves
|
132
|
130
|
set_destination_from_current();
|
133
|
|
-
|
134
|
131
|
stepper.synchronize(); // Wait for buffered moves to complete
|
135
|
132
|
|
136
|
|
- if (retracting) {
|
137
|
|
- // Remember the Z height since G-code may include its own Z-hop
|
138
|
|
- // For best results turn off Z hop if G-code already includes it
|
139
|
|
- hop_height = destination[Z_AXIS];
|
|
133
|
+ const float renormalize = 100.0 / planner.flow_percentage[active_extruder] / planner.volumetric_multiplier[active_extruder];
|
140
|
134
|
|
|
135
|
+ if (retracting) {
|
141
|
136
|
// Retract by moving from a faux E position back to the current E position
|
142
|
137
|
feedrate_mm_s = retract_feedrate_mm_s;
|
143
|
|
- current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) / planner.volumetric_multiplier[active_extruder];
|
|
138
|
+ current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) * renormalize;
|
144
|
139
|
sync_plan_position_e();
|
145
|
140
|
prepare_move_to_destination();
|
146
|
141
|
|
147
|
142
|
// Is a Z hop set, and has the hop not yet been done?
|
148
|
|
- if (has_zhop) {
|
149
|
|
- hop_amount += retract_zlift; // Carriage is raised for retraction hop
|
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
|
152
|
|
- prepare_move_to_destination(); // Raise up to the old current pos
|
|
143
|
+ // No double zlifting
|
|
144
|
+ // Feedrate to the max
|
|
145
|
+ if (has_zhop && !hop_amount) {
|
|
146
|
+ hop_amount += retract_zlift; // Carriage is raised for retraction hop
|
|
147
|
+ feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
|
|
148
|
+ current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z.
|
|
149
|
+ SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
|
150
|
+ prepare_move_to_destination(); // Raise up to the old current pos
|
153
|
151
|
}
|
154
|
152
|
}
|
155
|
153
|
else {
|
156
|
154
|
// If a hop was done and Z hasn't changed, undo the Z hop
|
157
|
|
- if (hop_amount && NEAR(hop_height, destination[Z_AXIS])) {
|
158
|
|
- current_position[Z_AXIS] += hop_amount; // Pretend current pos is higher. Next move lowers Z.
|
159
|
|
- SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
160
|
|
- prepare_move_to_destination(); // Lower to the old current pos
|
161
|
|
- hop_amount = 0.0;
|
|
155
|
+ if (hop_amount) {
|
|
156
|
+ current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z.
|
|
157
|
+ SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
|
158
|
+ feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
|
|
159
|
+ prepare_move_to_destination(); // Raise up to the old current pos
|
|
160
|
+ hop_amount = 0.0; // Clear hop
|
162
|
161
|
}
|
163
|
162
|
|
164
|
163
|
// A retract multiplier has been added here to get faster swap recovery
|
165
|
164
|
feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;
|
166
|
165
|
|
167
|
166
|
const float move_e = swapping ? swap_retract_length + swap_retract_recover_length : retract_length + retract_recover_length;
|
168
|
|
- current_position[E_AXIS] -= move_e / planner.volumetric_multiplier[active_extruder];
|
|
167
|
+ current_position[E_AXIS] -= move_e * renormalize;
|
169
|
168
|
sync_plan_position_e();
|
170
|
|
-
|
171
|
169
|
prepare_move_to_destination(); // Recover E
|
172
|
170
|
}
|
173
|
171
|
|
174
|
|
- // Restore flow and feedrate
|
175
|
|
- planner.flow_percentage[active_extruder] = old_flow;
|
176
|
|
- feedrate_mm_s = old_feedrate_mm_s;
|
|
172
|
+ feedrate_mm_s = old_feedrate_mm_s; // Restore original feedrate
|
177
|
173
|
|
178
|
|
- // The active extruder is now retracted or recovered
|
179
|
|
- retracted[active_extruder] = retracting;
|
|
174
|
+ retracted[active_extruder] = retracting; // Active extruder now retracted / recovered
|
180
|
175
|
|
181
|
|
- // If swap retract/recover then update the retracted_swap flag too
|
|
176
|
+ // If swap retract/recover update the retracted_swap flag too
|
182
|
177
|
#if EXTRUDERS > 1
|
183
|
178
|
if (swapping) retracted_swap[active_extruder] = retracting;
|
184
|
179
|
#endif
|
|
@@ -197,6 +192,6 @@ void FWRetract::retract(const bool retracting
|
197
|
192
|
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
|
198
|
193
|
//*/
|
199
|
194
|
|
200
|
|
-} // retract()
|
|
195
|
+}
|
201
|
196
|
|
202
|
197
|
#endif // FWRETRACT
|