Browse Source

Raise Z for M401 and M402

Scott Lahteine 9 years ago
parent
commit
63b98b8280
1 changed files with 22 additions and 2 deletions
  1. 22
    2
      Marlin/Marlin_main.cpp

+ 22
- 2
Marlin/Marlin_main.cpp View File

4309
 
4309
 
4310
 #if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED)
4310
 #if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED)
4311
 
4311
 
4312
+  #ifdef SERVO_ENDSTOPS
4313
+    void raise_z_for_servo() {
4314
+      float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING;
4315
+      if (!axis_known_position[Z_AXIS]) z_dest += zpos;
4316
+      if (zpos < z_dest)
4317
+        do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_dest); // also updates current_position
4318
+    }
4319
+  #endif
4320
+
4312
   /**
4321
   /**
4313
    * M401: Engage Z Servo endstop if available
4322
    * M401: Engage Z Servo endstop if available
4314
    */
4323
    */
4315
-  inline void gcode_M401() { deploy_z_probe(); }
4324
+  inline void gcode_M401() {
4325
+    #ifdef SERVO_ENDSTOPS
4326
+      raise_z_for_servo();
4327
+    #endif
4328
+    deploy_z_probe();
4329
+  }
4330
+
4316
   /**
4331
   /**
4317
    * M402: Retract Z Servo endstop if enabled
4332
    * M402: Retract Z Servo endstop if enabled
4318
    */
4333
    */
4319
-  inline void gcode_M402() { stow_z_probe(); }
4334
+  inline void gcode_M402() {
4335
+    #ifdef SERVO_ENDSTOPS
4336
+      raise_z_for_servo();
4337
+    #endif
4338
+    stow_z_probe();
4339
+  }
4320
 
4340
 
4321
 #endif
4341
 #endif
4322
 
4342
 

Loading…
Cancel
Save