|
@@ -3162,16 +3162,20 @@ static void homeaxis(const AxisEnum axis) {
|
3162
|
3162
|
#endif
|
3163
|
3163
|
) {
|
3164
|
3164
|
|
3165
|
|
- static float hop_height, // Remember where the Z height started
|
3166
|
|
- hop_amount = 0.0; // Total amount lifted, for use in recover
|
|
3165
|
+ static float hop_amount = 0.0; // Total amount lifted, for use in recover
|
3167
|
3166
|
|
3168
|
|
- // Simply never allow two retracts or recovers in a row
|
|
3167
|
+ // Prevent two retracts or recovers in a row
|
3169
|
3168
|
if (retracted[active_extruder] == retracting) return;
|
3170
|
3169
|
|
3171
|
|
- #if EXTRUDERS < 2
|
3172
|
|
- bool swapping = false;
|
|
3170
|
+ // Prevent two swap-retract or recovers in a row
|
|
3171
|
+ #if EXTRUDERS > 1
|
|
3172
|
+ // Allow G10 S1 only after G10
|
|
3173
|
+ if (swapping && retracted_swap[active_extruder] == retracting) return;
|
|
3174
|
+ // G11 priority to recover the long retract if activated
|
|
3175
|
+ if (!retracting) swapping = retracted_swap[active_extruder];
|
|
3176
|
+ #else
|
|
3177
|
+ const bool swapping = false;
|
3173
|
3178
|
#endif
|
3174
|
|
- if (!retracting) swapping = retracted_swap[active_extruder];
|
3175
|
3179
|
|
3176
|
3180
|
/* // debugging
|
3177
|
3181
|
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
|
@@ -3188,64 +3192,55 @@ static void homeaxis(const AxisEnum axis) {
|
3188
|
3192
|
//*/
|
3189
|
3193
|
|
3190
|
3194
|
const bool has_zhop = retract_zlift > 0.01; // Is there a hop set?
|
3191
|
|
-
|
3192
|
3195
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
3193
|
|
- const int16_t old_flow = flow_percentage[active_extruder];
|
3194
|
|
-
|
3195
|
|
- // Don't apply flow multiplication to retract/recover
|
3196
|
|
- flow_percentage[active_extruder] = 100;
|
3197
|
3196
|
|
3198
|
3197
|
// The current position will be the destination for E and Z moves
|
3199
|
3198
|
set_destination_from_current();
|
|
3199
|
+ stepper.synchronize(); // Wait for buffered moves to complete
|
3200
|
3200
|
|
3201
|
|
- stepper.synchronize(); // Wait for all moves to finish
|
|
3201
|
+ const float renormalize = 100.0 / flow_percentage[active_extruder] / volumetric_multiplier[active_extruder];
|
3202
|
3202
|
|
3203
|
3203
|
if (retracting) {
|
3204
|
|
- // Remember the Z height since G-code may include its own Z-hop
|
3205
|
|
- // For best results turn off Z hop if G-code already includes it
|
3206
|
|
- hop_height = destination[Z_AXIS];
|
3207
|
|
-
|
3208
|
3204
|
// Retract by moving from a faux E position back to the current E position
|
3209
|
3205
|
feedrate_mm_s = retract_feedrate_mm_s;
|
3210
|
|
- current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) / volumetric_multiplier[active_extruder];
|
|
3206
|
+ current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) * renormalize;
|
3211
|
3207
|
sync_plan_position_e();
|
3212
|
3208
|
prepare_move_to_destination();
|
3213
|
3209
|
|
3214
|
3210
|
// Is a Z hop set, and has the hop not yet been done?
|
3215
|
|
- if (has_zhop) {
|
3216
|
|
- hop_amount += retract_zlift; // Carriage is raised for retraction hop
|
3217
|
|
- current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z.
|
3218
|
|
- SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
3219
|
|
- prepare_move_to_destination(); // Raise up to the old current pos
|
|
3211
|
+ if (has_zhop && !hop_amount) {
|
|
3212
|
+ hop_amount += retract_zlift; // Carriage is raised for retraction hop
|
|
3213
|
+ feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
|
|
3214
|
+ current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z.
|
|
3215
|
+ SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
|
3216
|
+ prepare_move_to_destination(); // Raise up to the old current pos
|
|
3217
|
+ feedrate_mm_s = retract_feedrate_mm_s; // Restore feedrate
|
3220
|
3218
|
}
|
3221
|
3219
|
}
|
3222
|
3220
|
else {
|
3223
|
3221
|
// If a hop was done and Z hasn't changed, undo the Z hop
|
3224
|
|
- if (hop_amount && NEAR(hop_height, destination[Z_AXIS])) {
|
3225
|
|
- current_position[Z_AXIS] += hop_amount; // Pretend current pos is higher. Next move lowers Z.
|
3226
|
|
- SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
3227
|
|
- prepare_move_to_destination(); // Lower to the old current pos
|
3228
|
|
- hop_amount = 0.0;
|
|
3222
|
+ if (hop_amount) {
|
|
3223
|
+ current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z.
|
|
3224
|
+ SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
|
|
3225
|
+ feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
|
|
3226
|
+ prepare_move_to_destination(); // Raise up to the old current pos
|
|
3227
|
+ hop_amount = 0.0; // Clear hop
|
3229
|
3228
|
}
|
3230
|
3229
|
|
3231
|
3230
|
// A retract multiplier has been added here to get faster swap recovery
|
3232
|
3231
|
feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;
|
3233
|
3232
|
|
3234
|
3233
|
const float move_e = swapping ? swap_retract_length + swap_retract_recover_length : retract_length + retract_recover_length;
|
3235
|
|
- current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
|
|
3234
|
+ current_position[E_AXIS] -= move_e * renormalize;
|
3236
|
3235
|
sync_plan_position_e();
|
3237
|
|
-
|
3238
|
|
- prepare_move_to_destination(); // Recover E
|
|
3236
|
+ prepare_move_to_destination(); // Recover E
|
3239
|
3237
|
}
|
3240
|
3238
|
|
3241
|
|
- // Restore flow and feedrate
|
3242
|
|
- flow_percentage[active_extruder] = old_flow;
|
3243
|
|
- feedrate_mm_s = old_feedrate_mm_s;
|
|
3239
|
+ feedrate_mm_s = old_feedrate_mm_s; // Restore original feedrate
|
3244
|
3240
|
|
3245
|
|
- // The active extruder is now retracted or recovered
|
3246
|
|
- retracted[active_extruder] = retracting;
|
|
3241
|
+ retracted[active_extruder] = retracting; // Active extruder now retracted / recovered
|
3247
|
3242
|
|
3248
|
|
- // If swap retract/recover then update the retracted_swap flag too
|
|
3243
|
+ // If swap retract/recover update the retracted_swap flag too
|
3249
|
3244
|
#if EXTRUDERS > 1
|
3250
|
3245
|
if (swapping) retracted_swap[active_extruder] = retracting;
|
3251
|
3246
|
#endif
|
|
@@ -3264,7 +3259,7 @@ static void homeaxis(const AxisEnum axis) {
|
3264
|
3259
|
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
|
3265
|
3260
|
//*/
|
3266
|
3261
|
|
3267
|
|
- } // retract()
|
|
3262
|
+ }
|
3268
|
3263
|
|
3269
|
3264
|
#endif // FWRETRACT
|
3270
|
3265
|
|