浏览代码

Merge pull request #6042 from thinkyhead/rc_fix_toolchange_z

Move Z last in tool-change for SWITCHING_EXTRUDER
Scott Lahteine 7 年前
父节点
当前提交
9b2b53f63a
共有 2 个文件被更改,包括 17 次插入17 次删除
  1. 16
    16
      Marlin/Marlin_main.cpp
  2. 1
    1
      Marlin/ultralcd.cpp

+ 16
- 16
Marlin/Marlin_main.cpp 查看文件

@@ -7851,6 +7851,7 @@ inline void gcode_M999() {
7851 7851
   inline void move_extruder_servo(uint8_t e) {
7852 7852
     const int angles[2] = SWITCHING_EXTRUDER_SERVO_ANGLES;
7853 7853
     MOVE_SERVO(SWITCHING_EXTRUDER_SERVO_NR, angles[e]);
7854
+    delay(500);
7854 7855
   }
7855 7856
 #endif
7856 7857
 
@@ -7997,25 +7998,15 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
7997 7998
 
7998 7999
           #if ENABLED(SWITCHING_EXTRUDER)
7999 8000
             // <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
8000
-            float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
8001
-                  z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
8001
+            const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
8002
+                        z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
8002 8003
 
8003 8004
             // Always raise by some amount (destination copied from current_position earlier)
8004
-            float save_Z = destination[Z_AXIS];  // save Z for later on
8005
-            destination[Z_AXIS] += z_raise;
8006
-            planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
8005
+            current_position[Z_AXIS] += z_raise;
8006
+            planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
8007 8007
             stepper.synchronize();
8008 8008
 
8009 8009
             move_extruder_servo(active_extruder);
8010
-            delay(500);
8011
-
8012
-            // Move back down, if needed
8013
-            if (z_raise != z_diff) {
8014
-              destination[Z_AXIS] = current_position[Z_AXIS] + z_diff;
8015
-              planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
8016
-              stepper.synchronize();
8017
-            }
8018
-            destination[Z_AXIS] = save_Z;  // restore original Z position so the 'Move to the "old position"' is correct
8019 8010
           #endif
8020 8011
 
8021 8012
           /**
@@ -8066,12 +8057,12 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
8066 8057
             #endif
8067 8058
 
8068 8059
             // Adjustments to the current position
8069
-            float xydiff[2] = { offset_vec.x, offset_vec.y };
8060
+            const float xydiff[2] = { offset_vec.x, offset_vec.y };
8070 8061
             current_position[Z_AXIS] += offset_vec.z;
8071 8062
 
8072 8063
           #else // !ABL_PLANAR
8073 8064
 
8074
-            float xydiff[2] = {
8065
+            const float xydiff[2] = {
8075 8066
               hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
8076 8067
               hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
8077 8068
             };
@@ -8138,6 +8129,15 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
8138 8129
           prepare_move_to_destination();
8139 8130
         }
8140 8131
 
8132
+        #if ENABLED(SWITCHING_EXTRUDER)
8133
+          // Move back down, if needed. (Including when the new tool is higher.)
8134
+          if (z_raise != z_diff) {
8135
+            destination[Z_AXIS] += z_diff;
8136
+            feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS];
8137
+            prepare_move_to_destination();
8138
+          }
8139
+        #endif
8140
+
8141 8141
       } // (tmp_extruder != active_extruder)
8142 8142
 
8143 8143
       stepper.synchronize();

+ 1
- 1
Marlin/ultralcd.cpp 查看文件

@@ -435,7 +435,7 @@ uint16_t max_display_update_time = 0;
435 435
         }
436 436
         else if (screen == lcd_status_screen && currentScreen == lcd_main_menu && PENDING(millis(), doubleclick_expire_ms))
437 437
           screen = lcd_babystep_z;
438
-      #endif 
438
+      #endif
439 439
 
440 440
       currentScreen = screen;
441 441
       encoderPosition = encoder;

正在加载...
取消
保存