Browse Source

Update tool_change.cpp (#11559)

InsanityAutomation 6 years ago
parent
commit
9de730b2bf
1 changed files with 13 additions and 12 deletions
  1. 13
    12
      Marlin/src/module/tool_change.cpp

+ 13
- 12
Marlin/src/module/tool_change.cpp View File

@@ -354,6 +354,12 @@ inline void invalid_extruder_error(const uint8_t e) {
354 354
 void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
355 355
   planner.synchronize();
356 356
 
357
+  #if HAS_LEVELING
358
+      // Set current position to the physical position
359
+      const bool leveling_was_active = planner.leveling_active;
360
+      set_bed_leveling_enabled(false);
361
+   #endif
362
+  
357 363
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
358 364
 
359 365
     mixing_tool_change(tmp_extruder);
@@ -377,12 +383,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
377 383
           #endif
378 384
         }
379 385
 
380
-        #if HAS_LEVELING
381
-          // Set current position to the physical position
382
-          const bool leveling_was_active = planner.leveling_active;
383
-          set_bed_leveling_enabled(false);
384
-        #endif
385
-
386 386
         #if ENABLED(DUAL_X_CARRIAGE)
387 387
 
388 388
           #if HAS_SOFTWARE_ENDSTOPS
@@ -439,11 +439,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
439 439
           current_position[Z_AXIS] -= zdiff;
440 440
         #endif
441 441
 
442
-        #if HAS_LEVELING
443
-          // Restore leveling to re-establish the logical position
444
-          set_bed_leveling_enabled(leveling_was_active);
445
-        #endif
446
-
447 442
         // Tell the planner the new "current position"
448 443
         SYNC_PLAN_POSITION_KINEMATIC();
449 444
 
@@ -516,7 +511,13 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
516 511
     #if HAS_FANMUX
517 512
       fanmux_switch(active_extruder);
518 513
     #endif
519
-
514
+  
515
+    #if HAS_LEVELING
516
+          planner.synchronize();
517
+          // Restore leveling to re-establish the logical position
518
+          set_bed_leveling_enabled(leveling_was_active);
519
+    #endif
520
+  
520 521
     SERIAL_ECHO_START();
521 522
     SERIAL_ECHOLNPAIR(MSG_ACTIVE_EXTRUDER, (int)active_extruder);
522 523
 

Loading…
Cancel
Save