Browse Source

Merge pull request #5150 from thinkyhead/rc_bilinear_splits

Corrections to bilinear_line_to_destination
Scott Lahteine 8 years ago
parent
commit
2185973e39
1 changed files with 15 additions and 13 deletions
  1. 15
    13
      Marlin/Marlin_main.cpp

+ 15
- 13
Marlin/Marlin_main.cpp View File

8662
 
8662
 
8663
     #define MBL_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
8663
     #define MBL_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
8664
 
8664
 
8665
-    float normalized_dist, end[NUM_AXIS];
8665
+    float normalized_dist, end[XYZE];
8666
 
8666
 
8667
     // Split at the left/front border of the right/top square
8667
     // Split at the left/front border of the right/top square
8668
     int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
8668
     int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
8700
 
8700
 
8701
 #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
8701
 #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
8702
 
8702
 
8703
+  #define CELL_INDEX(A,V) ((RAW_##A##_POSITION(V) - bilinear_start[A##_AXIS]) / bilinear_grid_spacing[A##_AXIS])
8704
+
8703
   /**
8705
   /**
8704
-   * Prepare a mesh-leveled linear move in a Cartesian setup,
8705
-   * splitting the move where it crosses mesh borders.
8706
+   * Prepare a bilinear-leveled linear move on Cartesian,
8707
+   * splitting the move where it crosses grid borders.
8706
    */
8708
    */
8707
-  void bilinear_line_to_destination(float fr_mm_s, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
8708
-    int cx1 = RAW_CURRENT_POSITION(X_AXIS) / bilinear_grid_spacing[X_AXIS],
8709
-        cy1 = RAW_CURRENT_POSITION(Y_AXIS) / bilinear_grid_spacing[Y_AXIS],
8710
-        cx2 = RAW_X_POSITION(destination[X_AXIS]) / bilinear_grid_spacing[X_AXIS],
8711
-        cy2 = RAW_Y_POSITION(destination[Y_AXIS]) / bilinear_grid_spacing[Y_AXIS];
8712
-    NOMORE(cx1, ABL_GRID_POINTS_X - 2);
8713
-    NOMORE(cy1, ABL_GRID_POINTS_Y - 2);
8714
-    NOMORE(cx2, ABL_GRID_POINTS_X - 2);
8715
-    NOMORE(cy2, ABL_GRID_POINTS_Y - 2);
8709
+  void bilinear_line_to_destination(float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
8710
+    int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
8711
+        cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
8712
+        cx2 = CELL_INDEX(X, destination[X_AXIS]),
8713
+        cy2 = CELL_INDEX(Y, destination[Y_AXIS]);
8714
+    cx1 = constrain(cx1, 0, ABL_GRID_POINTS_X - 2);
8715
+    cy1 = constrain(cy1, 0, ABL_GRID_POINTS_Y - 2);
8716
+    cx2 = constrain(cx2, 0, ABL_GRID_POINTS_X - 2);
8717
+    cy2 = constrain(cy2, 0, ABL_GRID_POINTS_Y - 2);
8716
 
8718
 
8717
     if (cx1 == cx2 && cy1 == cy2) {
8719
     if (cx1 == cx2 && cy1 == cy2) {
8718
       // Start and end on same mesh square
8720
       // Start and end on same mesh square
8723
 
8725
 
8724
     #define LINE_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
8726
     #define LINE_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
8725
 
8727
 
8726
-    float normalized_dist, end[NUM_AXIS];
8728
+    float normalized_dist, end[XYZE];
8727
 
8729
 
8728
     // Split at the left/front border of the right/top square
8730
     // Split at the left/front border of the right/top square
8729
     int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
8731
     int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);

Loading…
Cancel
Save