Browse Source

A macro to normalize positions

Scott Lahteine 9 years ago
parent
commit
04a5b7b257
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      Marlin/Marlin_main.cpp

+ 6
- 4
Marlin/Marlin_main.cpp View File

@@ -7858,18 +7858,20 @@ void mesh_buffer_line(float x, float y, float z, const float e, float fr_mm_s, c
7858 7858
     return;
7859 7859
   }
7860 7860
 
7861
+  #define MBL_SEGMENT_END(axis,AXIS) (current_position[AXIS ##_AXIS] + (axis - current_position[AXIS ##_AXIS]) * normalized_dist)
7862
+
7861 7863
   float nx, ny, nz, ne, normalized_dist;
7862 7864
   int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
7863 7865
   if (cx2 != cx1 && TEST(x_splits, gcx)) {
7864 7866
     nx = mbl.get_probe_x(gcx) + home_offset[X_AXIS] + position_shift[X_AXIS];
7865 7867
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
7866
-    ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
7868
+    ny = MBL_SEGMENT_END(y, Y);
7867 7869
     CBI(x_splits, gcx);
7868 7870
   }
7869 7871
   else if (cy2 != cy1 && TEST(y_splits, gcy)) {
7870 7872
     ny = mbl.get_probe_y(gcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
7871 7873
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7872
-    nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7874
+    nx = MBL_SEGMENT_END(x, X);
7873 7875
     CBI(y_splits, gcy);
7874 7876
   }
7875 7877
   else {
@@ -7879,8 +7881,8 @@ void mesh_buffer_line(float x, float y, float z, const float e, float fr_mm_s, c
7879 7881
     return;
7880 7882
   }
7881 7883
 
7882
-  nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7883
-  ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7884
+  nz = MBL_SEGMENT_END(z, Z);
7885
+  ne = MBL_SEGMENT_END(e, E);
7884 7886
 
7885 7887
   // Do the split and look for more borders
7886 7888
   destination[X_AXIS] = nx;

Loading…
Cancel
Save