Explorar el Código

Merge pull request #8112 from thinkyhead/bf1_fwretract_fix_oct26

[1.1.x] Improved Firmware Retraction logic
Scott Lahteine hace 7 años
padre
commit
e374d87ac4

+ 36
- 41
Marlin/Marlin_main.cpp Ver fichero

1013
       pixels.show(); // initialize to all off
1013
       pixels.show(); // initialize to all off
1014
 
1014
 
1015
       #if ENABLED(NEOPIXEL_STARTUP_TEST)
1015
       #if ENABLED(NEOPIXEL_STARTUP_TEST)
1016
-        delay(2000);
1016
+        safe_delay(1000);
1017
         set_neopixel_color(pixels.Color(255, 0, 0, 0));  // red
1017
         set_neopixel_color(pixels.Color(255, 0, 0, 0));  // red
1018
-        delay(2000);
1018
+        safe_delay(1000);
1019
         set_neopixel_color(pixels.Color(0, 255, 0, 0));  // green
1019
         set_neopixel_color(pixels.Color(0, 255, 0, 0));  // green
1020
-        delay(2000);
1020
+        safe_delay(1000);
1021
         set_neopixel_color(pixels.Color(0, 0, 255, 0));  // blue
1021
         set_neopixel_color(pixels.Color(0, 0, 255, 0));  // blue
1022
-        delay(2000);
1022
+        safe_delay(1000);
1023
       #endif
1023
       #endif
1024
       set_neopixel_color(pixels.Color(NEO_WHITE));       // white
1024
       set_neopixel_color(pixels.Color(NEO_WHITE));       // white
1025
     }
1025
     }
3162
     #endif
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
     if (retracted[active_extruder] == retracting) return;
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
     #endif
3178
     #endif
3174
-    if (!retracting) swapping = retracted_swap[active_extruder];
3175
 
3179
 
3176
     /* // debugging
3180
     /* // debugging
3177
       SERIAL_ECHOLNPAIR("retracting ", retracting);
3181
       SERIAL_ECHOLNPAIR("retracting ", retracting);
3188
     //*/
3192
     //*/
3189
 
3193
 
3190
     const bool has_zhop = retract_zlift > 0.01;     // Is there a hop set?
3194
     const bool has_zhop = retract_zlift > 0.01;     // Is there a hop set?
3191
-
3192
     const float old_feedrate_mm_s = feedrate_mm_s;
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
     // The current position will be the destination for E and Z moves
3197
     // The current position will be the destination for E and Z moves
3199
     set_destination_from_current();
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
     if (retracting) {
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
       // Retract by moving from a faux E position back to the current E position
3204
       // Retract by moving from a faux E position back to the current E position
3209
       feedrate_mm_s = retract_feedrate_mm_s;
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
       sync_plan_position_e();
3207
       sync_plan_position_e();
3212
       prepare_move_to_destination();
3208
       prepare_move_to_destination();
3213
 
3209
 
3214
       // Is a Z hop set, and has the hop not yet been done?
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
     else {
3220
     else {
3223
       // If a hop was done and Z hasn't changed, undo the Z hop
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
       // A retract multiplier has been added here to get faster swap recovery
3230
       // A retract multiplier has been added here to get faster swap recovery
3232
       feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;
3231
       feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;
3233
 
3232
 
3234
       const float move_e = swapping ? swap_retract_length + swap_retract_recover_length : retract_length + retract_recover_length;
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
       sync_plan_position_e();
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
     #if EXTRUDERS > 1
3244
     #if EXTRUDERS > 1
3250
       if (swapping) retracted_swap[active_extruder] = retracting;
3245
       if (swapping) retracted_swap[active_extruder] = retracting;
3251
     #endif
3246
     #endif
3264
       SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
3259
       SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
3265
     //*/
3260
     //*/
3266
 
3261
 
3267
-  } // retract()
3262
+  }
3268
 
3263
 
3269
 #endif // FWRETRACT
3264
 #endif // FWRETRACT
3270
 
3265
 

+ 4
- 1
Marlin/language_en.h Ver fichero

615
   #define MSG_CONTROL_RETRACT_RECOVER_SWAP    _UxGT("S UnRet mm")
615
   #define MSG_CONTROL_RETRACT_RECOVER_SWAP    _UxGT("S UnRet mm")
616
 #endif
616
 #endif
617
 #ifndef MSG_CONTROL_RETRACT_RECOVERF
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
 #endif
622
 #endif
620
 #ifndef MSG_AUTORETRACT
623
 #ifndef MSG_AUTORETRACT
621
   #define MSG_AUTORETRACT                     _UxGT("AutoRetr.")
624
   #define MSG_AUTORETRACT                     _UxGT("AutoRetr.")

+ 1
- 0
Marlin/language_fr.h Ver fichero

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

+ 1
- 0
Marlin/language_pl-DOGM.h Ver fichero

43
 #define MSG_LEVEL_BED_WAITING               _UxGT("Kliknij by rozp.")
43
 #define MSG_LEVEL_BED_WAITING               _UxGT("Kliknij by rozp.")
44
 #define MSG_LEVEL_BED_NEXT_POINT            _UxGT("Następny punkt")
44
 #define MSG_LEVEL_BED_NEXT_POINT            _UxGT("Następny punkt")
45
 #define MSG_LEVEL_BED_DONE                  _UxGT("Wypoziomowano!")
45
 #define MSG_LEVEL_BED_DONE                  _UxGT("Wypoziomowano!")
46
+#define MSG_USER_MENU                       _UxGT("Własne Polecenia")
46
 #define MSG_SET_HOME_OFFSETS                _UxGT("Ust. poz. zer.")
47
 #define MSG_SET_HOME_OFFSETS                _UxGT("Ust. poz. zer.")
47
 #define MSG_HOME_OFFSETS_APPLIED            _UxGT("Poz. zerowa ust.")
48
 #define MSG_HOME_OFFSETS_APPLIED            _UxGT("Poz. zerowa ust.")
48
 #define MSG_SET_ORIGIN                      _UxGT("Ustaw punkt zero")
49
 #define MSG_SET_ORIGIN                      _UxGT("Ustaw punkt zero")

+ 1
- 0
Marlin/language_pl-HD44780.h Ver fichero

43
 #define MSG_LEVEL_BED_WAITING               _UxGT("Kliknij by rozp.")
43
 #define MSG_LEVEL_BED_WAITING               _UxGT("Kliknij by rozp.")
44
 #define MSG_LEVEL_BED_NEXT_POINT            _UxGT("Nastepny punkt")
44
 #define MSG_LEVEL_BED_NEXT_POINT            _UxGT("Nastepny punkt")
45
 #define MSG_LEVEL_BED_DONE                  _UxGT("Wypoziomowano!")
45
 #define MSG_LEVEL_BED_DONE                  _UxGT("Wypoziomowano!")
46
+#define MSG_USER_MENU                       _UxGT("Wlasne Polecenia")
46
 #define MSG_SET_HOME_OFFSETS                _UxGT("Ust. poz. zer.")
47
 #define MSG_SET_HOME_OFFSETS                _UxGT("Ust. poz. zer.")
47
 #define MSG_HOME_OFFSETS_APPLIED            _UxGT("Poz. zerowa ust.")
48
 #define MSG_HOME_OFFSETS_APPLIED            _UxGT("Poz. zerowa ust.")
48
 #define MSG_SET_ORIGIN                      _UxGT("Ustaw punkt zero")
49
 #define MSG_SET_ORIGIN                      _UxGT("Ustaw punkt zero")

+ 1
- 1
Marlin/planner.h Ver fichero

288
         return 1.0;
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
     #endif
293
     #endif
294
 
294
 

+ 3
- 0
Marlin/ultralcd.cpp Ver fichero

3726
         MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &swap_retract_recover_length, -100, 100);
3726
         MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &swap_retract_recover_length, -100, 100);
3727
       #endif
3727
       #endif
3728
       MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate_mm_s, 1, 999);
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
       END_MENU();
3732
       END_MENU();
3730
     }
3733
     }
3731
 
3734
 

Loading…
Cancelar
Guardar