Browse Source

Account for home_offset in G29 handler

Scott Lahteine 8 years ago
parent
commit
1b7356b3a1
2 changed files with 28 additions and 19 deletions
  1. 26
    17
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/planner.cpp

+ 26
- 17
Marlin/Marlin_main.cpp View File

@@ -2841,7 +2841,7 @@ inline void gcode_G28() {
2841 2841
         }
2842 2842
         if (probe_point == 0) {
2843 2843
           // Set Z to a positive value before recording the first Z.
2844
-          current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2844
+          current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + home_offset[Z_AXIS];
2845 2845
           sync_plan_position();
2846 2846
         }
2847 2847
         else {
@@ -2850,7 +2850,7 @@ inline void gcode_G28() {
2850 2850
           iy = (probe_point - 1) / (MESH_NUM_X_POINTS);
2851 2851
           if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
2852 2852
           mbl.set_z(ix, iy, current_position[Z_AXIS]);
2853
-          current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2853
+          current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + home_offset[Z_AXIS];
2854 2854
           plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 60, active_extruder);
2855 2855
           st_synchronize();
2856 2856
         }
@@ -2859,8 +2859,8 @@ inline void gcode_G28() {
2859 2859
           ix = probe_point % (MESH_NUM_X_POINTS);
2860 2860
           iy = probe_point / (MESH_NUM_X_POINTS);
2861 2861
           if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
2862
-          current_position[X_AXIS] = mbl.get_x(ix);
2863
-          current_position[Y_AXIS] = mbl.get_y(iy);
2862
+          current_position[X_AXIS] = mbl.get_x(ix) + home_offset[X_AXIS];
2863
+          current_position[Y_AXIS] = mbl.get_y(iy) + home_offset[Y_AXIS];
2864 2864
           plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 60, active_extruder);
2865 2865
           st_synchronize();
2866 2866
           probe_point++;
@@ -3144,7 +3144,7 @@ inline void gcode_G28() {
3144 3144
 
3145 3145
           // raise extruder
3146 3146
           float measured_z,
3147
-                z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING;
3147
+                z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS];
3148 3148
 
3149 3149
           if (probePointCounter) {
3150 3150
             #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -3157,7 +3157,7 @@ inline void gcode_G28() {
3157 3157
           else {
3158 3158
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3159 3159
               if (DEBUGGING(LEVELING)) {
3160
-                SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING);
3160
+                SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS]);
3161 3161
                 SERIAL_EOL;
3162 3162
               }
3163 3163
             #endif
@@ -3318,9 +3318,18 @@ inline void gcode_G28() {
3318 3318
         p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
3319 3319
 
3320 3320
       // Probe at 3 arbitrary points
3321
-      float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, verbose_level),
3322
-            z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, p2, verbose_level),
3323
-            z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, p3, verbose_level);
3321
+      float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
3322
+                                  ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
3323
+                                  Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS],
3324
+                                  p1, verbose_level),
3325
+            z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
3326
+                                  ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
3327
+                                  current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
3328
+                                  p2, verbose_level),
3329
+            z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
3330
+                                  ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
3331
+                                  current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
3332
+                                  p3, verbose_level);
3324 3333
       clean_up_after_endstop_move();
3325 3334
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
3326 3335
 
@@ -6962,10 +6971,10 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
6962 6971
     set_current_to_destination();
6963 6972
     return;
6964 6973
   }
6965
-  int pix = mbl.select_x_index(current_position[X_AXIS]);
6966
-  int piy = mbl.select_y_index(current_position[Y_AXIS]);
6967
-  int ix = mbl.select_x_index(x);
6968
-  int iy = mbl.select_y_index(y);
6974
+  int pix = mbl.select_x_index(current_position[X_AXIS] - home_offset[X_AXIS]);
6975
+  int piy = mbl.select_y_index(current_position[Y_AXIS] - home_offset[Y_AXIS]);
6976
+  int ix = mbl.select_x_index(x - home_offset[X_AXIS]);
6977
+  int iy = mbl.select_y_index(y - home_offset[Y_AXIS]);
6969 6978
   pix = min(pix, MESH_NUM_X_POINTS - 2);
6970 6979
   piy = min(piy, MESH_NUM_Y_POINTS - 2);
6971 6980
   ix = min(ix, MESH_NUM_X_POINTS - 2);
@@ -6978,7 +6987,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
6978 6987
   }
6979 6988
   float nx, ny, nz, ne, normalized_dist;
6980 6989
   if (ix > pix && TEST(x_splits, ix)) {
6981
-    nx = mbl.get_x(ix);
6990
+    nx = mbl.get_x(ix) + home_offset[X_AXIS];
6982 6991
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6983 6992
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6984 6993
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
@@ -6986,7 +6995,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
6986 6995
     CBI(x_splits, ix);
6987 6996
   }
6988 6997
   else if (ix < pix && TEST(x_splits, pix)) {
6989
-    nx = mbl.get_x(pix);
6998
+    nx = mbl.get_x(pix) + home_offset[X_AXIS];
6990 6999
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6991 7000
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6992 7001
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
@@ -6994,7 +7003,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
6994 7003
     CBI(x_splits, pix);
6995 7004
   }
6996 7005
   else if (iy > piy && TEST(y_splits, iy)) {
6997
-    ny = mbl.get_y(iy);
7006
+    ny = mbl.get_y(iy) + home_offset[Y_AXIS];
6998 7007
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
6999 7008
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7000 7009
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
@@ -7002,7 +7011,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
7002 7011
     CBI(y_splits, iy);
7003 7012
   }
7004 7013
   else if (iy < piy && TEST(y_splits, piy)) {
7005
-    ny = mbl.get_y(piy);
7014
+    ny = mbl.get_y(piy) + home_offset[Y_AXIS];
7006 7015
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7007 7016
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7008 7017
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;

+ 2
- 2
Marlin/planner.cpp View File

@@ -568,7 +568,7 @@ float junction_deviation = 0.1;
568 568
   while (block_buffer_tail == next_buffer_head) idle();
569 569
 
570 570
   #if ENABLED(MESH_BED_LEVELING)
571
-    if (mbl.active) z += mbl.get_z(x, y);
571
+    if (mbl.active) z += mbl.get_z(x - home_offset[X_AXIS], y - home_offset[Y_AXIS]);
572 572
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
573 573
     apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
574 574
   #endif
@@ -1111,7 +1111,7 @@ float junction_deviation = 0.1;
1111 1111
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1112 1112
   {
1113 1113
     #if ENABLED(MESH_BED_LEVELING)
1114
-      if (mbl.active) z += mbl.get_z(x, y);
1114
+      if (mbl.active) z += mbl.get_z(x - home_offset[X_AXIS], y - home_offset[Y_AXIS]);
1115 1115
     #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
1116 1116
       apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
1117 1117
     #endif

Loading…
Cancel
Save