浏览代码

Fix FWRETRACT logic, apply common sense

Scott Lahteine 7 年前
父节点
当前提交
6569b9ba56
共有 5 个文件被更改,包括 41 次插入39 次删除
  1. 32
    37
      Marlin/Marlin_main.cpp
  2. 4
    1
      Marlin/language_en.h
  3. 1
    0
      Marlin/language_fr.h
  4. 1
    1
      Marlin/planner.h
  5. 3
    0
      Marlin/ultralcd.cpp

+ 32
- 37
Marlin/Marlin_main.cpp 查看文件

@@ -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
 

+ 4
- 1
Marlin/language_en.h 查看文件

@@ -615,7 +615,10 @@
615 615
   #define MSG_CONTROL_RETRACT_RECOVER_SWAP    _UxGT("S UnRet mm")
616 616
 #endif
617 617
 #ifndef MSG_CONTROL_RETRACT_RECOVERF
618
-  #define MSG_CONTROL_RETRACT_RECOVERF        _UxGT("UnRet  V")
618
+  #define MSG_CONTROL_RETRACT_RECOVERF        _UxGT("UnRet V")
619
+#endif
620
+#ifndef MSG_CONTROL_RETRACT_RECOVER_SWAPF
621
+  #define MSG_CONTROL_RETRACT_RECOVER_SWAPF   _UxGT("S UnRet V")
619 622
 #endif
620 623
 #ifndef MSG_AUTORETRACT
621 624
   #define MSG_AUTORETRACT                     _UxGT("AutoRetr.")

+ 1
- 0
Marlin/language_fr.h 查看文件

@@ -222,6 +222,7 @@
222 222
 #define MSG_CONTROL_RETRACT_RECOVER         _UxGT("UnRet mm")
223 223
 #define MSG_CONTROL_RETRACT_RECOVER_SWAP    _UxGT("Ech. UnRet mm")
224 224
 #define MSG_CONTROL_RETRACT_RECOVERF        _UxGT("UnRet V")
225
+#define MSG_CONTROL_RETRACT_RECOVER_SWAPF   _UxGT("Ech. UnRet V")
225 226
 #define MSG_AUTORETRACT                     _UxGT("Retract. Auto.")
226 227
 #define MSG_FILAMENTCHANGE                  _UxGT("Changer filament")
227 228
 #define MSG_INIT_SDCARD                     _UxGT("Init. la carte SD")

+ 1
- 1
Marlin/planner.h 查看文件

@@ -288,7 +288,7 @@ class Planner {
288 288
         return 1.0;
289 289
       }
290 290
 
291
-      FORCE_INLINE static bool leveling_active_at_z(const float &lz) { return true; }
291
+      FORCE_INLINE static bool leveling_active_at_z(const float &lz) { UNUSED(lz); return true; }
292 292
 
293 293
     #endif
294 294
 

+ 3
- 0
Marlin/ultralcd.cpp 查看文件

@@ -3726,6 +3726,9 @@ void kill_screen(const char* lcd_msg) {
3726 3726
         MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &swap_retract_recover_length, -100, 100);
3727 3727
       #endif
3728 3728
       MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate_mm_s, 1, 999);
3729
+      #if EXTRUDERS > 1
3730
+        MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &swap_retract_recover_feedrate_mm_s, 1, 999);
3731
+      #endif
3729 3732
       END_MENU();
3730 3733
     }
3731 3734
 

正在加载...
取消
保存