Browse Source

Move delta homing to its own function

Scott Lahteine 8 years ago
parent
commit
c84b14c77a
1 changed files with 43 additions and 35 deletions
  1. 43
    35
      Marlin/Marlin_main.cpp

+ 43
- 35
Marlin/Marlin_main.cpp View File

@@ -2707,6 +2707,48 @@ inline void gcode_G4() {
2707 2707
 
2708 2708
 #endif // DEBUG_LEVELING_FEATURE
2709 2709
 
2710
+#if ENABLED(DELTA)
2711
+
2712
+  /**
2713
+   * A delta can only safely home all axes at the same time
2714
+   * This is like quick_home_xy() but for 3 towers.
2715
+   */
2716
+  inline void home_delta() {
2717
+    // Init the current position of all carriages to 0,0,0
2718
+    memset(current_position, 0, sizeof(current_position));
2719
+    sync_plan_position();
2720
+
2721
+    // Move all carriages together linearly until an endstop is hit.
2722
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (Z_MAX_LENGTH + 10);
2723
+    feedrate_mm_s = homing_feedrate_mm_s[X_AXIS];
2724
+    line_to_current_position();
2725
+    stepper.synchronize();
2726
+    endstops.hit_on_purpose(); // clear endstop hit flags
2727
+
2728
+    // Probably not needed. Double-check this line:
2729
+    memset(current_position, 0, sizeof(current_position));
2730
+
2731
+    // At least one carriage has reached the top.
2732
+    // Now back off and re-home each carriage separately.
2733
+    HOMEAXIS(A);
2734
+    HOMEAXIS(B);
2735
+    HOMEAXIS(C);
2736
+
2737
+    // Set all carriages to their home positions
2738
+    // Do this here all at once for Delta, because
2739
+    // XYZ isn't ABC. Applying this per-tower would
2740
+    // give the impression that they are the same.
2741
+    LOOP_XYZ(i) set_axis_is_at_home((AxisEnum)i);
2742
+
2743
+    SYNC_PLAN_POSITION_KINEMATIC();
2744
+
2745
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
2746
+      if (DEBUGGING(LEVELING)) DEBUG_POS("(DELTA)", current_position);
2747
+    #endif
2748
+  }
2749
+
2750
+#endif // DELTA
2751
+
2710 2752
 /**
2711 2753
  * G28: Home all axes according to settings
2712 2754
  *
@@ -2784,42 +2826,8 @@ inline void gcode_G28() {
2784 2826
 
2785 2827
 
2786 2828
   #if ENABLED(DELTA)
2787
-    /**
2788
-     * A delta can only safely home all axes at the same time
2789
-     * This is like quick_home_xy() but for 3 towers.
2790
-     */
2791
-
2792
-    // Init the current position of all carriages to 0,0,0
2793
-    memset(current_position, 0, sizeof(current_position));
2794
-    sync_plan_position();
2795
-
2796
-    // Move all carriages together linearly until an endstop is hit.
2797
-    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (Z_MAX_LENGTH + 10);
2798
-    feedrate_mm_s = homing_feedrate_mm_s[X_AXIS];
2799
-    line_to_current_position();
2800
-    stepper.synchronize();
2801
-    endstops.hit_on_purpose(); // clear endstop hit flags
2802
-
2803
-    // Probably not needed. Double-check this line:
2804
-    memset(current_position, 0, sizeof(current_position));
2805
-
2806
-    // At least one carriage has reached the top.
2807
-    // Now back off and re-home each carriage separately.
2808
-    HOMEAXIS(A);
2809
-    HOMEAXIS(B);
2810
-    HOMEAXIS(C);
2811
-
2812
-    // Set all carriages to their home positions
2813
-    // Do this here all at once for Delta, because
2814
-    // XYZ isn't ABC. Applying this per-tower would
2815
-    // give the impression that they are the same.
2816
-    LOOP_XYZ(i) set_axis_is_at_home((AxisEnum)i);
2817 2829
 
2818
-    SYNC_PLAN_POSITION_KINEMATIC();
2819
-
2820
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
2821
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(DELTA)", current_position);
2822
-    #endif
2830
+    home_delta();
2823 2831
 
2824 2832
   #else // NOT DELTA
2825 2833
 

Loading…
Cancel
Save