浏览代码

Merge pull request #5493 from thinkyhead/rc_fix_recover_unhop

Prevent retract un-hop at wrong height
Scott Lahteine 8 年前
父节点
当前提交
efb8b8425c
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10
    1
      Marlin/Marlin_main.cpp

+ 10
- 1
Marlin/Marlin_main.cpp 查看文件

2741
 
2741
 
2742
   void retract(bool retracting, bool swapping = false) {
2742
   void retract(bool retracting, bool swapping = false) {
2743
 
2743
 
2744
+    static float hop_height;
2745
+
2744
     if (retracting == retracted[active_extruder]) return;
2746
     if (retracting == retracted[active_extruder]) return;
2745
 
2747
 
2746
     float old_feedrate_mm_s = feedrate_mm_s;
2748
     float old_feedrate_mm_s = feedrate_mm_s;
2755
       prepare_move_to_destination();
2757
       prepare_move_to_destination();
2756
 
2758
 
2757
       if (retract_zlift > 0.01) {
2759
       if (retract_zlift > 0.01) {
2760
+        hop_height = current_position[Z_AXIS];
2761
+        // Pretend current position is lower
2758
         current_position[Z_AXIS] -= retract_zlift;
2762
         current_position[Z_AXIS] -= retract_zlift;
2759
         SYNC_PLAN_POSITION_KINEMATIC();
2763
         SYNC_PLAN_POSITION_KINEMATIC();
2764
+        // Raise up to the old current_position
2760
         prepare_move_to_destination();
2765
         prepare_move_to_destination();
2761
       }
2766
       }
2762
     }
2767
     }
2763
     else {
2768
     else {
2764
 
2769
 
2765
-      if (retract_zlift > 0.01) {
2770
+      // If the height hasn't been altered, undo the Z hop
2771
+      if (retract_zlift > 0.01 && hop_height == current_position[Z_AXIS]) {
2772
+        // Pretend current position is higher. Z will lower on the next move
2766
         current_position[Z_AXIS] += retract_zlift;
2773
         current_position[Z_AXIS] += retract_zlift;
2767
         SYNC_PLAN_POSITION_KINEMATIC();
2774
         SYNC_PLAN_POSITION_KINEMATIC();
2768
       }
2775
       }
2771
       float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
2778
       float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
2772
       current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
2779
       current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
2773
       sync_plan_position_e();
2780
       sync_plan_position_e();
2781
+
2782
+      // Lower Z and recover E
2774
       prepare_move_to_destination();
2783
       prepare_move_to_destination();
2775
     }
2784
     }
2776
 
2785
 

正在加载...
取消
保存