瀏覽代碼

Clean up tool-change syncs (#14666)

Scott Lahteine 6 年之前
父節點
當前提交
fac0e63058
No account linked to committer's email address
共有 1 個文件被更改,包括 35 次插入41 次删除
  1. 35
    41
      Marlin/src/module/tool_change.cpp

+ 35
- 41
Marlin/src/module/tool_change.cpp 查看文件

@@ -486,98 +486,92 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
486 486
     // 1. Move to switch position current toolhead
487 487
 
488 488
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
489
-
490 489
     if (DEBUGGING(LEVELING)) {
491 490
       SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
492 491
       DEBUG_POS("Move Y SwitchPos + Security", current_position);
493 492
     }
494
-
495 493
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
496
-    planner.synchronize();
497 494
 
498 495
     current_position[X_AXIS] = placexpos + SWITCHING_TOOLHEAD_X_SECURITY;
499
-
500
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move X SwitchPos + Security", current_position);
501
-
496
+    if (DEBUGGING(LEVELING)) {
497
+      planner.synchronize();
498
+      DEBUG_POS("Move X SwitchPos + Security", current_position);
499
+    }
502 500
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
503
-    planner.synchronize();
504 501
 
505 502
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
506
-
507
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
508
-
503
+    if (DEBUGGING(LEVELING)) {
504
+      planner.synchronize();
505
+      DEBUG_POS("Move Y SwitchPos", current_position);
506
+    }
509 507
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
510
-    planner.synchronize();
511 508
 
512 509
     current_position[X_AXIS] = placexpos;
513
-
514
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move X SwitchPos", current_position);
515
-
510
+    if (DEBUGGING(LEVELING)) {
511
+      planner.synchronize();
512
+      DEBUG_POS("Move X SwitchPos", current_position);
513
+    }
516 514
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25), active_extruder);
517
-    planner.synchronize();
518 515
 
519 516
     // 2. Release and place toolhead in the dock
520 517
 
521
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(2) Release and Place Toolhead");
518
+    if (DEBUGGING(LEVELING)) {
519
+      planner.synchronize();
520
+      SERIAL_ECHOLNPGM("(2) Release and Place Toolhead");
521
+    }
522 522
 
523 523
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
524
-
525 524
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
526
-
527 525
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1), active_extruder);
528
-    planner.synchronize();
529 526
 
530 527
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;
531
-
532
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
533
-
528
+    if (DEBUGGING(LEVELING)) {
529
+      planner.synchronize();
530
+      DEBUG_POS("Move Y SwitchPos + Security", current_position);
531
+    }
534 532
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
535
-    planner.synchronize();
536 533
 
537 534
     // 3. Move to new toolhead position
538 535
 
539
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Move to new toolhead position");
536
+    if (DEBUGGING(LEVELING)) {
537
+      planner.synchronize();
538
+      SERIAL_ECHOLNPGM("(3) Move to new toolhead position");
539
+    }
540 540
 
541 541
     current_position[X_AXIS] = grabxpos;
542
-
543 542
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
544
-
545 543
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
546
-    planner.synchronize();
547 544
 
548 545
     // 4. Grab the new toolhead and move to security position
549 546
 
550
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Grab new toolhead and move to security position");
547
+    if (DEBUGGING(LEVELING)) {
548
+      planner.synchronize();
549
+      SERIAL_ECHOLNPGM("(4) Grab new toolhead and move to security position");
550
+    }
551 551
 
552 552
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
553
-
554 553
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
555
-
556 554
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
557
-    planner.synchronize();
558 555
 
559 556
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
560
-
561
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
562
-
557
+    if (DEBUGGING(LEVELING)) {
558
+      planner.synchronize();
559
+      DEBUG_POS("Move Y SwitchPos", current_position);
560
+    }
563 561
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.2, active_extruder);
564 562
     planner.synchronize();
565
-    safe_delay(100);
563
+    safe_delay(100); // Give switch time to settle
566 564
 
567 565
     current_position[X_AXIS] = grabxpos + SWITCHING_TOOLHEAD_X_SECURITY;
568
-
569 566
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);
570
-
571 567
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.1, active_extruder);
572 568
     planner.synchronize();
573
-    safe_delay(100);
569
+    safe_delay(100); // Give switch time to settle
574 570
 
575 571
     current_position[Y_AXIS] += SWITCHING_TOOLHEAD_Y_CLEAR;
576
-
577 572
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
578
-
579 573
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
580
-    planner.synchronize();
574
+    planner.synchronize(); // Always sync last tool-change move
581 575
   }
582 576
 
583 577
 #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)

Loading…
取消
儲存