Browse Source

Merge pull request #1924 from thinkyhead/raise_z_for_m401_m402

Raise Z for M401 and M402
Scott Lahteine 9 years ago
parent
commit
0438f0d835
1 changed files with 22 additions and 2 deletions
  1. 22
    2
      Marlin/Marlin_main.cpp

+ 22
- 2
Marlin/Marlin_main.cpp View File

@@ -4276,14 +4276,34 @@ inline void gcode_M400() { st_synchronize(); }
4276 4276
 
4277 4277
 #if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED)
4278 4278
 
4279
+  #ifdef SERVO_ENDSTOPS
4280
+    void raise_z_for_servo() {
4281
+      float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING;
4282
+      if (!axis_known_position[Z_AXIS]) z_dest += zpos;
4283
+      if (zpos < z_dest)
4284
+        do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_dest); // also updates current_position
4285
+    }
4286
+  #endif
4287
+
4279 4288
   /**
4280 4289
    * M401: Engage Z Servo endstop if available
4281 4290
    */
4282
-  inline void gcode_M401() { deploy_z_probe(); }
4291
+  inline void gcode_M401() {
4292
+    #ifdef SERVO_ENDSTOPS
4293
+      raise_z_for_servo();
4294
+    #endif
4295
+    deploy_z_probe();
4296
+  }
4297
+
4283 4298
   /**
4284 4299
    * M402: Retract Z Servo endstop if enabled
4285 4300
    */
4286
-  inline void gcode_M402() { stow_z_probe(); }
4301
+  inline void gcode_M402() {
4302
+    #ifdef SERVO_ENDSTOPS
4303
+      raise_z_for_servo();
4304
+    #endif
4305
+    stow_z_probe();
4306
+  }
4287 4307
 
4288 4308
 #endif
4289 4309
 

Loading…
Cancel
Save