Browse Source

Merge Zig-Zag Endpoint (PR#65)

Richard Wackerbarth 10 years ago
parent
commit
9531b154ea
1 changed files with 7 additions and 11 deletions
  1. 7
    11
      Marlin/Marlin_main.cpp

+ 7
- 11
Marlin/Marlin_main.cpp View File

@@ -2561,10 +2561,11 @@ inline void gcode_G28() {
2561 2561
         double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
2562 2562
                eqnBVector[abl2],     // "B" vector of Z points
2563 2563
                mean = 0.0;
2564
+        int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points];
2564 2565
       #endif // !DELTA
2565 2566
 
2566 2567
       int probePointCounter = 0;
2567
-      bool zig = true;
2568
+      bool zig = (auto_bed_leveling_grid_points & 1) ? true : false; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
2568 2569
 
2569 2570
       for (int yCount = 0; yCount < auto_bed_leveling_grid_points; yCount++) {
2570 2571
         double yProbe = front_probe_bed_position + yGridSpacing * yCount;
@@ -2581,13 +2582,7 @@ inline void gcode_G28() {
2581 2582
           xInc = -1;
2582 2583
         }
2583 2584
 
2584
-        #if DISABLED(DELTA)
2585
-          // If do_topography_map is set then don't zig-zag. Just scan in one direction.
2586
-          // This gets the probe points in more readable order.
2587
-          if (!do_topography_map) zig = !zig;
2588
-        #else
2589
-          zig = !zig;
2590
-        #endif
2585
+        zig = !zig;
2591 2586
 
2592 2587
         for (int xCount = xStart; xCount != xStop; xCount += xInc) {
2593 2588
           double xProbe = left_probe_bed_position + xGridSpacing * xCount;
@@ -2621,12 +2616,13 @@ inline void gcode_G28() {
2621 2616
             eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
2622 2617
             eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
2623 2618
             eqnAMatrix[probePointCounter + 2 * abl2] = 1;
2619
+            indexIntoAB[xCount][yCount] = probePointCounter;
2624 2620
           #else
2625 2621
             bed_level[xCount][yCount] = measured_z + z_offset;
2626 2622
           #endif
2627 2623
 
2628 2624
           probePointCounter++;
2629
-
2625
+  
2630 2626
           idle();
2631 2627
 
2632 2628
         } //xProbe
@@ -2679,7 +2675,7 @@ inline void gcode_G28() {
2679 2675
 
2680 2676
           for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
2681 2677
             for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
2682
-              int ind = yy * auto_bed_leveling_grid_points + xx;
2678
+              int ind = indexIntoAB[xx][yy];
2683 2679
               float diff = eqnBVector[ind] - mean;
2684 2680
 
2685 2681
               float x_tmp = eqnAMatrix[ind + 0 * abl2],
@@ -2705,7 +2701,7 @@ inline void gcode_G28() {
2705 2701
 
2706 2702
             for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
2707 2703
               for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
2708
-                int ind = yy * auto_bed_leveling_grid_points + xx;
2704
+                int ind = indexIntoAB[xx][yy];
2709 2705
                 float x_tmp = eqnAMatrix[ind + 0 * abl2],
2710 2706
                   y_tmp = eqnAMatrix[ind + 1 * abl2],
2711 2707
                   z_tmp = 0;

Loading…
Cancel
Save