Przeglądaj źródła

Fix single nozzle temp change, do slower extra prime (#14696)

InsanityAutomation 5 lat temu
rodzic
commit
dc6fa04f68

+ 13
- 13
Marlin/src/gcode/feature/advance/M900.cpp Wyświetl plik

@@ -44,10 +44,10 @@
44 44
 void GcodeSuite::M900() {
45 45
 
46 46
   #if EXTRUDERS < 2
47
-    constexpr uint8_t tmp_extruder = 0;
47
+    constexpr uint8_t tool_index = 0;
48 48
   #else
49
-    const uint8_t tmp_extruder = parser.intval('T', active_extruder);
50
-    if (tmp_extruder >= EXTRUDERS) {
49
+    const uint8_t tool_index = parser.intval('T', active_extruder);
50
+    if (tool_index >= EXTRUDERS) {
51 51
       SERIAL_ECHOLNPGM("?T value out of range.");
52 52
       return;
53 53
     }
@@ -55,17 +55,17 @@ void GcodeSuite::M900() {
55 55
 
56 56
   #if ENABLED(EXTRA_LIN_ADVANCE_K)
57 57
 
58
-    bool ext_slot = TEST(lin_adv_slot, tmp_extruder);
58
+    bool ext_slot = TEST(lin_adv_slot, tool_index);
59 59
 
60 60
     if (parser.seenval('S')) {
61 61
       const bool slot = parser.value_bool();
62 62
       if (ext_slot != slot) {
63 63
         ext_slot = slot;
64
-        SET_BIT_TO(lin_adv_slot, tmp_extruder, slot);
64
+        SET_BIT_TO(lin_adv_slot, tool_index, slot);
65 65
         planner.synchronize();
66
-        const float temp = planner.extruder_advance_K[tmp_extruder];
67
-        planner.extruder_advance_K[tmp_extruder] = saved_extruder_advance_K[tmp_extruder];
68
-        saved_extruder_advance_K[tmp_extruder] = temp;
66
+        const float temp = planner.extruder_advance_K[tool_index];
67
+        planner.extruder_advance_K[tool_index] = saved_extruder_advance_K[tool_index];
68
+        saved_extruder_advance_K[tool_index] = temp;
69 69
       }
70 70
     }
71 71
 
@@ -73,10 +73,10 @@ void GcodeSuite::M900() {
73 73
       const float newK = parser.value_float();
74 74
       if (WITHIN(newK, 0, 10)) {
75 75
         if (ext_slot)
76
-          saved_extruder_advance_K[tmp_extruder] = newK;
76
+          saved_extruder_advance_K[tool_index] = newK;
77 77
         else {
78 78
           planner.synchronize();
79
-          planner.extruder_advance_K[tmp_extruder] = newK;
79
+          planner.extruder_advance_K[tool_index] = newK;
80 80
         }
81 81
       }
82 82
       else
@@ -87,10 +87,10 @@ void GcodeSuite::M900() {
87 87
       const float newL = parser.value_float();
88 88
       if (WITHIN(newL, 0, 10)) {
89 89
         if (!ext_slot)
90
-          saved_extruder_advance_K[tmp_extruder] = newL;
90
+          saved_extruder_advance_K[tool_index] = newL;
91 91
         else {
92 92
           planner.synchronize();
93
-          planner.extruder_advance_K[tmp_extruder] = newL;
93
+          planner.extruder_advance_K[tool_index] = newL;
94 94
         }
95 95
       }
96 96
       else
@@ -117,7 +117,7 @@ void GcodeSuite::M900() {
117 117
       const float newK = parser.value_float();
118 118
       if (WITHIN(newK, 0, 10)) {
119 119
         planner.synchronize();
120
-        planner.extruder_advance_K[tmp_extruder] = newK;
120
+        planner.extruder_advance_K[tool_index] = newK;
121 121
       }
122 122
       else
123 123
         SERIAL_ECHOLNPGM("?K value out of range (0-10).");

+ 83
- 79
Marlin/src/module/tool_change.cpp Wyświetl plik

@@ -146,10 +146,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
146 146
         parkingtraveldistance,    // M951 D
147 147
         compensationmultiplier;
148 148
 
149
-  inline void magnetic_parking_extruder_tool_change(const uint8_t tmp_extruder) {
149
+  inline void magnetic_parking_extruder_tool_change(const uint8_t new_tool) {
150 150
 
151 151
     const float oldx = current_position[X_AXIS],
152
-                grabpos = mpe_settings.parking_xpos[tmp_extruder] + (tmp_extruder ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
152
+                grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
153 153
                 offsetcompensation =
154 154
                   #if HAS_HOTEND_OFFSET
155 155
                     hotend_offset[X_AXIS][active_extruder] * mpe_settings.compensation_factor
@@ -174,14 +174,14 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
174 174
 
175 175
     // STEP 1
176 176
 
177
-    current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
177
+    current_position[X_AXIS] = mpe_settings.parking_xpos[new_tool] + offsetcompensation;
178 178
 
179 179
     if (DEBUGGING(LEVELING)) {
180
-      DEBUG_ECHOPAIR("(1) Move extruder ", int(tmp_extruder));
180
+      DEBUG_ECHOPAIR("(1) Move extruder ", int(new_tool));
181 181
       DEBUG_POS(" to new extruder ParkPos", current_position);
182 182
     }
183 183
 
184
-    planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
184
+    planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
185 185
     planner.synchronize();
186 186
 
187 187
     // STEP 2
@@ -189,11 +189,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
189 189
     current_position[X_AXIS] = grabpos + offsetcompensation;
190 190
 
191 191
     if (DEBUGGING(LEVELING)) {
192
-      DEBUG_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder));
192
+      DEBUG_ECHOPAIR("(2) Couple extruder ", int(new_tool));
193 193
       DEBUG_POS(" to new extruder GrabPos", current_position);
194 194
     }
195 195
 
196
-    planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
196
+    planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
197 197
     planner.synchronize();
198 198
 
199 199
     // Delay before moving tool, to allow magnetic coupling
@@ -201,24 +201,24 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
201 201
 
202 202
     // STEP 3
203 203
 
204
-    current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
204
+    current_position[X_AXIS] = mpe_settings.parking_xpos[new_tool] + offsetcompensation;
205 205
     if (DEBUGGING(LEVELING)) {
206
-      DEBUG_ECHOPAIR("(3) Move extruder ", int(tmp_extruder));
206
+      DEBUG_ECHOPAIR("(3) Move extruder ", int(new_tool));
207 207
       DEBUG_POS(" back to new extruder ParkPos", current_position);
208 208
     }
209 209
 
210
-    planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
210
+    planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
211 211
     planner.synchronize();
212 212
 
213 213
     // STEP 4
214 214
 
215 215
     current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation;
216 216
     if (DEBUGGING(LEVELING)) {
217
-      DEBUG_ECHOPAIR("(4) Move extruder ", int(tmp_extruder));
217
+      DEBUG_ECHOPAIR("(4) Move extruder ", int(new_tool));
218 218
       DEBUG_POS(" close to old extruder ParkPos", current_position);
219 219
     }
220 220
 
221
-    planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
221
+    planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
222 222
     planner.synchronize();
223 223
 
224 224
     // STEP 5
@@ -226,11 +226,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
226 226
     current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + offsetcompensation;
227 227
 
228 228
     if (DEBUGGING(LEVELING)) {
229
-      DEBUG_ECHOPAIR("(5) Park extruder ", int(tmp_extruder));
229
+      DEBUG_ECHOPAIR("(5) Park extruder ", int(new_tool));
230 230
       DEBUG_POS(" at old extruder ParkPos", current_position);
231 231
     }
232 232
 
233
-    planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
233
+    planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
234 234
     planner.synchronize();
235 235
 
236 236
     // STEP 6
@@ -238,11 +238,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
238 238
     current_position[X_AXIS] = oldx;
239 239
 
240 240
     if (DEBUGGING(LEVELING)) {
241
-      DEBUG_ECHOPAIR("(6) Move extruder ", int(tmp_extruder));
241
+      DEBUG_ECHOPAIR("(6) Move extruder ", int(new_tool));
242 242
       DEBUG_POS(" to starting position", current_position);
243 243
     }
244 244
 
245
-    planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
245
+    planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
246 246
     planner.synchronize();
247 247
 
248 248
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Autopark done.");
@@ -269,7 +269,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
269 269
     #endif
270 270
   }
271 271
 
272
-  inline void parking_extruder_tool_change(const uint8_t tmp_extruder, bool no_move) {
272
+  inline void parking_extruder_tool_change(const uint8_t new_tool, bool no_move) {
273 273
     if (!no_move) {
274 274
 
275 275
       constexpr float parkingposx[] = PARKING_EXTRUDER_PARKING_X;
@@ -281,7 +281,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
281 281
       #endif
282 282
 
283 283
       const float midpos = (parkingposx[0] + parkingposx[1]) * 0.5 + x_offset,
284
-                  grabpos = parkingposx[tmp_extruder] + (tmp_extruder ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
284
+                  grabpos = parkingposx[new_tool] + (new_tool ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
285 285
 
286 286
       /**
287 287
        * 1. Move to park position of old extruder
@@ -325,11 +325,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
325 325
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
326 326
         pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
327 327
       #endif
328
-      pe_activate_solenoid(tmp_extruder);
328
+      pe_activate_solenoid(new_tool);
329 329
 
330 330
       // STEP 5
331 331
 
332
-      current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
332
+      current_position[X_AXIS] = grabpos + (new_tool ? -10 : 10);
333 333
       fast_line_to_current(X_AXIS);
334 334
 
335 335
       current_position[X_AXIS] = grabpos;
@@ -343,7 +343,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
343 343
 
344 344
       current_position[X_AXIS] = midpos
345 345
         #if HAS_HOTEND_OFFSET
346
-          - hotend_offset[X_AXIS][tmp_extruder]
346
+          - hotend_offset[X_AXIS][new_tool]
347 347
         #endif
348 348
       ;
349 349
       if (DEBUGGING(LEVELING)) {
@@ -357,7 +357,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
357 357
     }
358 358
     else { // nomove == true
359 359
       // Only engage magnetic field for new extruder
360
-      pe_activate_solenoid(tmp_extruder);
360
+      pe_activate_solenoid(new_tool);
361 361
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
362 362
         pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
363 363
       #endif
@@ -368,14 +368,14 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
368 368
 
369 369
 #if ENABLED(SWITCHING_TOOLHEAD)
370 370
 
371
-  inline void switching_toolhead_tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
371
+  inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
372 372
     if (no_move) return;
373 373
 
374 374
     constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
375 375
 
376 376
     constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
377 377
     const float placexpos = toolheadposx[active_extruder],
378
-                grabxpos = toolheadposx[tmp_extruder];
378
+                grabxpos = toolheadposx[new_tool];
379 379
 
380 380
     /**
381 381
      * 1. Move to switch position of current toolhead
@@ -464,7 +464,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
464 464
 
465 465
 #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
466 466
 
467
-  inline void magnetic_switching_toolhead_tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
467
+  inline void magnetic_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
468 468
     if (no_move) return;
469 469
 
470 470
     constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS,
@@ -472,8 +472,8 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
472 472
 
473 473
     const float placexpos = toolheadposx[active_extruder],
474 474
                 placexclear = toolheadclearx[active_extruder],
475
-                grabxpos = toolheadposx[tmp_extruder],
476
-                grabxclear = toolheadclearx[tmp_extruder];
475
+                grabxpos = toolheadposx[new_tool],
476
+                grabxclear = toolheadclearx[new_tool];
477 477
 
478 478
     /**
479 479
      * 1. Move to switch position of current toolhead
@@ -564,11 +564,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
564 564
     #if ENABLED(PRIME_BEFORE_REMOVE) && (SWITCHING_TOOLHEAD_PRIME_MM || SWITCHING_TOOLHEAD_RETRACT_MM)
565 565
       #if SWITCHING_TOOLHEAD_PRIME_MM
566 566
         current_position[E_AXIS] += SWITCHING_TOOLHEAD_PRIME_MM;
567
-        planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_PRIME_FEEDRATE), tmp_extruder);
567
+        planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_PRIME_FEEDRATE), new_tool);
568 568
       #endif
569 569
       #if SWITCHING_TOOLHEAD_RETRACT_MM
570 570
         current_position[E_AXIS] -= SWITCHING_TOOLHEAD_RETRACT_MM;
571
-        planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_RETRACT_FEEDRATE), tmp_extruder);
571
+        planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_RETRACT_FEEDRATE), new_tool);
572 572
       #endif
573 573
     #else
574 574
       planner.synchronize();
@@ -595,12 +595,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
595 595
   inline void est_deactivate_solenoid() { OUT_WRITE(SOL0_PIN, LOW); }
596 596
   void est_init() { est_activate_solenoid(); }
597 597
 
598
-  inline void em_switching_toolhead_tool_change(const uint8_t tmp_extruder, bool no_move) {
598
+  inline void em_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move) {
599 599
     if (no_move) return;
600 600
 
601 601
     constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
602 602
     const float placexpos = toolheadposx[active_extruder],
603
-                grabxpos = toolheadposx[tmp_extruder];
603
+                grabxpos = toolheadposx[new_tool];
604 604
 
605 605
     /**
606 606
      * 1. Raise Z-Axis to give enough clearance
@@ -688,7 +688,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
688 688
     // 9. Apply Z hotend offset to current position
689 689
 
690 690
     if (DEBUGGING(LEVELING)) DEBUG_POS("(9) Applying Z-offset", current_position);
691
-    current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
691
+    current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][new_tool];
692 692
 
693 693
     if (DEBUGGING(LEVELING)) DEBUG_POS("EMST Tool-Change done.", current_position);
694 694
   }
@@ -703,7 +703,7 @@ inline void invalid_extruder_error(const uint8_t e) {
703 703
 
704 704
 #if ENABLED(DUAL_X_CARRIAGE)
705 705
 
706
-  inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) {
706
+  inline void dualx_tool_change(const uint8_t new_tool, bool &no_move) {
707 707
     if (DEBUGGING(LEVELING)) {
708 708
       DEBUG_ECHOPGM("Dual X Carriage Mode ");
709 709
       switch (dual_x_carriage_mode) {
@@ -728,7 +728,7 @@ inline void invalid_extruder_error(const uint8_t e) {
728 728
     }
729 729
 
730 730
     // Activate the new extruder ahead of calling set_axis_is_at_home!
731
-    active_extruder = tmp_extruder;
731
+    active_extruder = new_tool;
732 732
 
733 733
     // This function resets the max/min values - the current position may be overwritten below.
734 734
     set_axis_is_at_home(X_AXIS);
@@ -764,35 +764,37 @@ inline void invalid_extruder_error(const uint8_t e) {
764 764
  * Perform a tool-change, which may result in moving the
765 765
  * previous tool out of the way and the new tool into place.
766 766
  */
767
-void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
767
+void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
768 768
 
769 769
   #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
770
-    if (tmp_extruder == active_extruder) return;
770
+    if (new_tool == active_extruder) return;
771 771
   #endif
772 772
 
773
+  const uint8_t old_tool = active_extruder;
774
+
773 775
   #if ENABLED(MIXING_EXTRUDER)
774 776
 
775 777
     UNUSED(no_move);
776 778
 
777
-    if (tmp_extruder >= MIXING_VIRTUAL_TOOLS)
778
-      return invalid_extruder_error(tmp_extruder);
779
+    if (new_tool >= MIXING_VIRTUAL_TOOLS)
780
+      return invalid_extruder_error(new_tool);
779 781
 
780 782
     #if MIXING_VIRTUAL_TOOLS > 1
781 783
       // T0-Tnnn: Switch virtual tool by changing the index to the mix
782
-      mixer.T(tmp_extruder);
784
+      mixer.T(new_tool);
783 785
     #endif
784 786
 
785 787
   #elif ENABLED(PRUSA_MMU2)
786 788
 
787 789
     UNUSED(no_move);
788 790
 
789
-    mmu2.tool_change(tmp_extruder);
791
+    mmu2.tool_change(new_tool);
790 792
 
791 793
   #elif EXTRUDERS < 2
792 794
 
793 795
     UNUSED(no_move);
794 796
 
795
-    if (tmp_extruder) invalid_extruder_error(tmp_extruder);
797
+    if (new_tool) invalid_extruder_error(new_tool);
796 798
     return;
797 799
 
798 800
   #else // EXTRUDERS > 1
@@ -800,12 +802,12 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
800 802
     planner.synchronize();
801 803
 
802 804
     #if ENABLED(DUAL_X_CARRIAGE)  // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_MIRRORED_MODE
803
-      if (tmp_extruder != 0 && dxc_is_duplicating())
804
-         return invalid_extruder_error(tmp_extruder);
805
+      if (new_tool != 0 && dxc_is_duplicating())
806
+         return invalid_extruder_error(new_tool);
805 807
     #endif
806 808
 
807
-    if (tmp_extruder >= EXTRUDERS)
808
-      return invalid_extruder_error(tmp_extruder);
809
+    if (new_tool >= EXTRUDERS)
810
+      return invalid_extruder_error(new_tool);
809 811
 
810 812
     if (!no_move && !all_axes_homed()) {
811 813
       no_move = true;
@@ -827,7 +829,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
827 829
     #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
828 830
       const bool should_swap = can_move_away && toolchange_settings.swap_length;
829 831
       #if ENABLED(PREVENT_COLD_EXTRUSION)
830
-        const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(active_extruder) || thermalManager.targetTooColdToExtrude(tmp_extruder));
832
+        const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(old_tool) || thermalManager.targetTooColdToExtrude(new_tool));
831 833
       #else
832 834
         constexpr bool too_cold = false;
833 835
       #endif
@@ -835,7 +837,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
835 837
         if (too_cold) {
836 838
           SERIAL_ECHO_MSG(MSG_ERR_HOTEND_TOO_COLD);
837 839
           #if ENABLED(SINGLENOZZLE)
838
-            active_extruder = tmp_extruder;
840
+            active_extruder = new_tool;
839 841
             return;
840 842
           #endif
841 843
         }
@@ -843,8 +845,8 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
843 845
           #if ENABLED(ADVANCED_PAUSE_FEATURE)
844 846
             do_pause_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed));
845 847
           #else
846
-            current_position[E_AXIS] -= toolchange_settings.swap_length / planner.e_factor[active_extruder];
847
-            planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.retract_speed), active_extruder);
848
+            current_position[E_AXIS] -= toolchange_settings.swap_length / planner.e_factor[old_tool];
849
+            planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.retract_speed), old_tool);
848 850
             planner.synchronize();
849 851
           #endif
850 852
         }
@@ -856,17 +858,17 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
856 858
       TEMPORARY_BED_LEVELING_STATE(false);
857 859
     #endif
858 860
 
859
-    if (tmp_extruder != active_extruder) {
861
+    if (new_tool != old_tool) {
860 862
 
861 863
       #if SWITCHING_NOZZLE_TWO_SERVOS
862
-        raise_nozzle(active_extruder);
864
+        raise_nozzle(old_tool);
863 865
       #endif
864 866
 
865 867
       REMEMBER(fr, feedrate_mm_s, XY_PROBE_FEEDRATE_MM_S);
866 868
 
867 869
       #if HAS_SOFTWARE_ENDSTOPS
868 870
         #if HAS_HOTEND_OFFSET
869
-          #define _EXT_ARGS , active_extruder, tmp_extruder
871
+          #define _EXT_ARGS , old_tool, new_tool
870 872
         #else
871 873
           #define _EXT_ARGS
872 874
         #endif
@@ -891,7 +893,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
891 893
             current_position[X_AXIS] = toolchange_settings.change_point.x;
892 894
             current_position[Y_AXIS] = toolchange_settings.change_point.y;
893 895
           #endif
894
-          planner.buffer_line(current_position, feedrate_mm_s, active_extruder);
896
+          planner.buffer_line(current_position, feedrate_mm_s, old_tool);
895 897
           planner.synchronize();
896 898
         }
897 899
       #endif
@@ -900,26 +902,26 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
900 902
         #if ENABLED(DUAL_X_CARRIAGE)
901 903
           constexpr float xdiff = 0;
902 904
         #else
903
-          const float xdiff = hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder];
905
+          const float xdiff = hotend_offset[X_AXIS][new_tool] - hotend_offset[X_AXIS][old_tool];
904 906
         #endif
905
-        const float ydiff = hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder],
906
-                    zdiff = hotend_offset[Z_AXIS][tmp_extruder] - hotend_offset[Z_AXIS][active_extruder];
907
+        const float ydiff = hotend_offset[Y_AXIS][new_tool] - hotend_offset[Y_AXIS][old_tool],
908
+                    zdiff = hotend_offset[Z_AXIS][new_tool] - hotend_offset[Z_AXIS][old_tool];
907 909
       #else
908 910
         constexpr float xdiff = 0, ydiff = 0, zdiff = 0;
909 911
       #endif
910 912
 
911 913
       #if ENABLED(DUAL_X_CARRIAGE)
912
-        dualx_tool_change(tmp_extruder, no_move);
914
+        dualx_tool_change(new_tool, no_move);
913 915
       #elif ENABLED(PARKING_EXTRUDER)                                   // Dual Parking extruder
914
-        parking_extruder_tool_change(tmp_extruder, no_move);
916
+        parking_extruder_tool_change(new_tool, no_move);
915 917
       #elif ENABLED(MAGNETIC_PARKING_EXTRUDER)                          // Magnetic Parking extruder
916
-        magnetic_parking_extruder_tool_change(tmp_extruder);
918
+        magnetic_parking_extruder_tool_change(new_tool);
917 919
       #elif ENABLED(SWITCHING_TOOLHEAD)                                 // Switching Toolhead
918
-        switching_toolhead_tool_change(tmp_extruder, no_move);
920
+        switching_toolhead_tool_change(new_tool, no_move);
919 921
       #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)                        // Magnetic Switching Toolhead
920
-        magnetic_switching_toolhead_tool_change(tmp_extruder, no_move);
922
+        magnetic_switching_toolhead_tool_change(new_tool, no_move);
921 923
       #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)                 // Magnetic Switching ToolChanger
922
-        em_switching_toolhead_tool_change(tmp_extruder, no_move);
924
+        em_switching_toolhead_tool_change(new_tool, no_move);
923 925
       #elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS   // Switching Nozzle (single servo)
924 926
         // Raise by a configured distance to avoid workpiece, except with
925 927
         // SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
@@ -928,7 +930,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
928 930
           NOMORE(current_position[Z_AXIS], soft_endstop[Z_AXIS].max);
929 931
         #endif
930 932
         if (!no_move) fast_line_to_current(Z_AXIS);
931
-        move_nozzle_servo(tmp_extruder);
933
+        move_nozzle_servo(new_tool);
932 934
       #endif
933 935
 
934 936
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
@@ -939,7 +941,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
939 941
       current_position[Z_AXIS] += zdiff;
940 942
 
941 943
       // Set the new active extruder if not already done in tool specific function above
942
-      active_extruder = tmp_extruder;
944
+      active_extruder = new_tool;
943 945
 
944 946
       // Tell the planner the new "current position"
945 947
       sync_plan_position();
@@ -956,28 +958,30 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
956 958
 
957 959
         #if ENABLED(SINGLENOZZLE)
958 960
           #if FAN_COUNT > 0
959
-            singlenozzle_fan_speed[active_extruder] = thermalManager.fan_speed[0];
960
-            thermalManager.fan_speed[0] = singlenozzle_fan_speed[tmp_extruder];
961
+            singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0];
962
+            thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool];
961 963
           #endif
962 964
 
963
-          singlenozzle_temp[active_extruder] = thermalManager.temp_hotend[0].target;
964
-          if (singlenozzle_temp[tmp_extruder] && singlenozzle_temp[tmp_extruder] != singlenozzle_temp[active_extruder]) {
965
-            thermalManager.setTargetHotend(singlenozzle_temp[tmp_extruder], 0);
965
+          singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target;
966
+          if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) {
967
+            thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0);
966 968
             #if HAS_DISPLAY
967 969
               thermalManager.set_heating_message(0);
968 970
             #endif
969 971
             (void)thermalManager.wait_for_hotend(0, false);  // Wait for heating or cooling
970 972
           }
971
-          active_extruder = tmp_extruder;
972 973
         #endif
973 974
 
974 975
         #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
975 976
           if (should_swap && !too_cold) {
976 977
             #if ENABLED(ADVANCED_PAUSE_FEATURE)
977
-              do_pause_e_move(toolchange_settings.swap_length + toolchange_settings.extra_prime, MMM_TO_MMS(toolchange_settings.prime_speed));
978
+              do_pause_e_move(toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.prime_speed));
979
+              do_pause_e_move(toolchange_settings.extra_prime, ADVANCED_PAUSE_PURGE_FEEDRATE);
978 980
             #else
979
-              current_position[E_AXIS] += (toolchange_settings.swap_length + toolchange_settings.extra_prime) / planner.e_factor[tmp_extruder];
980
-              planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), tmp_extruder);
981
+              current_position[E_AXIS] += toolchange_settings.swap_length / planner.e_factor[new_tool];
982
+              planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), new_tool);
983
+              current_position[E_AXIS] += toolchange_settings.extra_prime / planner.e_factor[new_tool];
984
+              planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed * 0.2f), new_tool);
981 985
             #endif
982 986
             planner.synchronize();
983 987
             planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = current_position[E_AXIS] - (TOOLCHANGE_FIL_EXTRA_PRIME)));
@@ -989,7 +993,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
989 993
           // If the original position is within tool store area, go to X origin at once
990 994
           if (destination[Y_AXIS] < SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR) {
991 995
             current_position[X_AXIS] = 0;
992
-            planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
996
+            planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], new_tool);
993 997
             planner.synchronize();
994 998
           }
995 999
         #else
@@ -1022,14 +1026,14 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
1022 1026
       #endif
1023 1027
 
1024 1028
       #if ENABLED(PRUSA_MMU2)
1025
-        mmu2.tool_change(tmp_extruder);
1029
+        mmu2.tool_change(new_tool);
1026 1030
       #endif
1027 1031
 
1028 1032
       #if SWITCHING_NOZZLE_TWO_SERVOS
1029
-        lower_nozzle(active_extruder);
1033
+        lower_nozzle(new_tool);
1030 1034
       #endif
1031 1035
 
1032
-    } // (tmp_extruder != active_extruder)
1036
+    } // (new_tool != old_tool)
1033 1037
 
1034 1038
     planner.synchronize();
1035 1039
 
@@ -1039,8 +1043,8 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
1039 1043
     #endif
1040 1044
 
1041 1045
     #if ENABLED(MK2_MULTIPLEXER)
1042
-      if (tmp_extruder >= E_STEPPERS) return invalid_extruder_error(tmp_extruder);
1043
-      select_multiplexed_stepper(tmp_extruder);
1046
+      if (new_tool >= E_STEPPERS) return invalid_extruder_error(new_tool);
1047
+      select_multiplexed_stepper(new_tool);
1044 1048
     #endif
1045 1049
 
1046 1050
     #if DO_SWITCH_EXTRUDER

Ładowanie…
Anuluj
Zapisz