瀏覽代碼

Merge pull request #8111 from thinkyhead/bf2_fwretract_fix_oct26

[2.0.x] Improved Firmware Retraction logic
Scott Lahteine 7 年之前
父節點
當前提交
b338cafc65

+ 28
- 33
Marlin/src/feature/fwretract.cpp 查看文件

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

+ 4
- 4
Marlin/src/feature/leds/neopixel.cpp 查看文件

@@ -45,13 +45,13 @@ void setup_neopixel() {
45 45
   pixels.show(); // initialize to all off
46 46
 
47 47
   #if ENABLED(NEOPIXEL_STARTUP_TEST)
48
-    delay(2000);
48
+    safe_delay(1000);
49 49
     set_neopixel_color(pixels.Color(255, 0, 0, 0));  // red
50
-    delay(2000);
50
+    safe_delay(1000);
51 51
     set_neopixel_color(pixels.Color(0, 255, 0, 0));  // green
52
-    delay(2000);
52
+    safe_delay(1000);
53 53
     set_neopixel_color(pixels.Color(0, 0, 255, 0));  // blue
54
-    delay(2000);
54
+    safe_delay(1000);
55 55
   #endif
56 56
   set_neopixel_color(pixels.Color(NEO_WHITE));       // white
57 57
 }

+ 4
- 1
Marlin/src/lcd/language/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/src/lcd/language/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. Retr. 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
- 0
Marlin/src/lcd/language/language_pl-DOGM.h 查看文件

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

+ 1
- 0
Marlin/src/lcd/language/language_pl-HD44780.h 查看文件

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

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

@@ -3716,6 +3716,9 @@ void kill_screen(const char* lcd_msg) {
3716 3716
         MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.swap_retract_recover_length, -100, 100);
3717 3717
       #endif
3718 3718
       MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.retract_recover_feedrate_mm_s, 1, 999);
3719
+      #if EXTRUDERS > 1
3720
+        MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.swap_retract_recover_feedrate_mm_s, 1, 999);
3721
+      #endif
3719 3722
       END_MENU();
3720 3723
     }
3721 3724
 

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

@@ -308,7 +308,7 @@ class Planner {
308 308
         return 1.0;
309 309
       }
310 310
 
311
-      FORCE_INLINE static bool leveling_active_at_z(const float &lz) { return true; }
311
+      FORCE_INLINE static bool leveling_active_at_z(const float &lz) { UNUSED(lz); return true; }
312 312
 
313 313
     #endif
314 314
 

Loading…
取消
儲存