diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index e6a0760d5..348124460 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2561,6 +2561,7 @@ inline void gcode_G28() { double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations eqnBVector[abl2], // "B" vector of Z points mean = 0.0; + int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points]; #endif // !DELTA int probePointCounter = 0; @@ -2625,7 +2626,7 @@ inline void gcode_G28() { bed_level[xCount][yCount] = measured_z + z_offset; #endif - probePointCounter++; + indexIntoAB[xCount][yCount] = probePointCounter++; idle(); @@ -2679,7 +2680,7 @@ inline void gcode_G28() { for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) { for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) { - int ind = yy * auto_bed_leveling_grid_points + xx; + int ind = indexIntoAB[xx][yy]; float diff = eqnBVector[ind] - mean; float x_tmp = eqnAMatrix[ind + 0 * abl2], @@ -2705,7 +2706,7 @@ inline void gcode_G28() { for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) { for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) { - int ind = yy * auto_bed_leveling_grid_points + xx; + int ind = indexIntoAB[xx][yy]; float x_tmp = eqnAMatrix[ind + 0 * abl2], y_tmp = eqnAMatrix[ind + 1 * abl2], z_tmp = 0;