Browse Source

Account for home_offset in G29 handler

Scott Lahteine 9 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
         }
2841
         }
2842
         if (probe_point == 0) {
2842
         if (probe_point == 0) {
2843
           // Set Z to a positive value before recording the first Z.
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
           sync_plan_position();
2845
           sync_plan_position();
2846
         }
2846
         }
2847
         else {
2847
         else {
2850
           iy = (probe_point - 1) / (MESH_NUM_X_POINTS);
2850
           iy = (probe_point - 1) / (MESH_NUM_X_POINTS);
2851
           if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
2851
           if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
2852
           mbl.set_z(ix, iy, current_position[Z_AXIS]);
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
           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);
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
           st_synchronize();
2855
           st_synchronize();
2856
         }
2856
         }
2859
           ix = probe_point % (MESH_NUM_X_POINTS);
2859
           ix = probe_point % (MESH_NUM_X_POINTS);
2860
           iy = probe_point / (MESH_NUM_X_POINTS);
2860
           iy = probe_point / (MESH_NUM_X_POINTS);
2861
           if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
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
           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);
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
           st_synchronize();
2865
           st_synchronize();
2866
           probe_point++;
2866
           probe_point++;
3144
 
3144
 
3145
           // raise extruder
3145
           // raise extruder
3146
           float measured_z,
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
           if (probePointCounter) {
3149
           if (probePointCounter) {
3150
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3150
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3157
           else {
3157
           else {
3158
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3158
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3159
               if (DEBUGGING(LEVELING)) {
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
                 SERIAL_EOL;
3161
                 SERIAL_EOL;
3162
               }
3162
               }
3163
             #endif
3163
             #endif
3318
         p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
3318
         p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
3319
 
3319
 
3320
       // Probe at 3 arbitrary points
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
       clean_up_after_endstop_move();
3333
       clean_up_after_endstop_move();
3325
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
3334
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
3326
 
3335
 
6962
     set_current_to_destination();
6971
     set_current_to_destination();
6963
     return;
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
   pix = min(pix, MESH_NUM_X_POINTS - 2);
6978
   pix = min(pix, MESH_NUM_X_POINTS - 2);
6970
   piy = min(piy, MESH_NUM_Y_POINTS - 2);
6979
   piy = min(piy, MESH_NUM_Y_POINTS - 2);
6971
   ix = min(ix, MESH_NUM_X_POINTS - 2);
6980
   ix = min(ix, MESH_NUM_X_POINTS - 2);
6978
   }
6987
   }
6979
   float nx, ny, nz, ne, normalized_dist;
6988
   float nx, ny, nz, ne, normalized_dist;
6980
   if (ix > pix && TEST(x_splits, ix)) {
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
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6991
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6983
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6992
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6984
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
6993
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
6986
     CBI(x_splits, ix);
6995
     CBI(x_splits, ix);
6987
   }
6996
   }
6988
   else if (ix < pix && TEST(x_splits, pix)) {
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
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6999
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6991
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
7000
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6992
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7001
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
6994
     CBI(x_splits, pix);
7003
     CBI(x_splits, pix);
6995
   }
7004
   }
6996
   else if (iy > piy && TEST(y_splits, iy)) {
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
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7007
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
6999
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7008
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7000
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7009
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7002
     CBI(y_splits, iy);
7011
     CBI(y_splits, iy);
7003
   }
7012
   }
7004
   else if (iy < piy && TEST(y_splits, piy)) {
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
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7015
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7007
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7016
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7008
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7017
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;

+ 2
- 2
Marlin/planner.cpp View File

568
   while (block_buffer_tail == next_buffer_head) idle();
568
   while (block_buffer_tail == next_buffer_head) idle();
569
 
569
 
570
   #if ENABLED(MESH_BED_LEVELING)
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
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
572
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
573
     apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
573
     apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
574
   #endif
574
   #endif
1111
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1111
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1112
   {
1112
   {
1113
     #if ENABLED(MESH_BED_LEVELING)
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
     #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
1115
     #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
1116
       apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
1116
       apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
1117
     #endif
1117
     #endif

Loading…
Cancel
Save