|
@ -2092,23 +2092,14 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
/**
|
|
|
/**
|
|
|
* All DELTA leveling in the Marlin uses NONLINEAR_BED_LEVELING |
|
|
* All DELTA leveling in the Marlin uses NONLINEAR_BED_LEVELING |
|
|
*/ |
|
|
*/ |
|
|
static void extrapolate_one_point(int x, int y, int xdir, int ydir) { |
|
|
static void extrapolate_one_point(uint8_t x, uint8_t y, int xdir, int ydir) { |
|
|
if (bed_level_grid[x][y] != 0.0) { |
|
|
if (bed_level_grid[x][y]) return; // Don't overwrite good values.
|
|
|
return; // Don't overwrite good values.
|
|
|
float a = 2 * bed_level_grid[x + xdir][y] - bed_level_grid[x + xdir * 2][y], // Left to right.
|
|
|
} |
|
|
b = 2 * bed_level_grid[x][y + ydir] - bed_level_grid[x][y + ydir * 2], // Front to back.
|
|
|
float a = 2 * bed_level_grid[x + xdir][y] - bed_level_grid[x + xdir * 2][y]; // Left to right.
|
|
|
c = 2 * bed_level_grid[x + xdir][y + ydir] - bed_level_grid[x + xdir * 2][y + ydir * 2]; // Diagonal.
|
|
|
float b = 2 * bed_level_grid[x][y + ydir] - bed_level_grid[x][y + ydir * 2]; // Front to back.
|
|
|
// Median is robust (ignores outliers).
|
|
|
float c = 2 * bed_level_grid[x + xdir][y + ydir] - bed_level_grid[x + xdir * 2][y + ydir * 2]; // Diagonal.
|
|
|
bed_level_grid[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c) |
|
|
float median = c; // Median is robust (ignores outliers).
|
|
|
: ((c < b) ? b : (a < c) ? a : c); |
|
|
if (a < b) { |
|
|
|
|
|
if (b < c) median = b; |
|
|
|
|
|
if (c < a) median = a; |
|
|
|
|
|
} |
|
|
|
|
|
else { // b <= a
|
|
|
|
|
|
if (c < b) median = b; |
|
|
|
|
|
if (a < c) median = a; |
|
|
|
|
|
} |
|
|
|
|
|
bed_level_grid[x][y] = median; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
@ -2116,9 +2107,9 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
* using linear extrapolation, away from the center. |
|
|
* using linear extrapolation, away from the center. |
|
|
*/ |
|
|
*/ |
|
|
static void extrapolate_unprobed_bed_level() { |
|
|
static void extrapolate_unprobed_bed_level() { |
|
|
int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2; |
|
|
uint8_t half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2; |
|
|
for (int y = 0; y <= half; y++) { |
|
|
for (uint8_t y = 0; y <= half; y++) { |
|
|
for (int x = 0; x <= half; x++) { |
|
|
for (uint8_t x = 0; x <= half; x++) { |
|
|
if (x + y < 3) continue; |
|
|
if (x + y < 3) continue; |
|
|
extrapolate_one_point(half - x, half - y, x > 1 ? +1 : 0, y > 1 ? +1 : 0); |
|
|
extrapolate_one_point(half - x, half - y, x > 1 ? +1 : 0, y > 1 ? +1 : 0); |
|
|
extrapolate_one_point(half + x, half - y, x > 1 ? -1 : 0, y > 1 ? +1 : 0); |
|
|
extrapolate_one_point(half + x, half - y, x > 1 ? -1 : 0, y > 1 ? +1 : 0); |
|
@ -2132,8 +2123,8 @@ static void clean_up_after_endstop_or_probe_move() { |
|
|
* Print calibration results for plotting or manual frame adjustment. |
|
|
* Print calibration results for plotting or manual frame adjustment. |
|
|
*/ |
|
|
*/ |
|
|
static void print_bed_level() { |
|
|
static void print_bed_level() { |
|
|
for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) { |
|
|
for (uint8_t y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) { |
|
|
for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) { |
|
|
for (uint8_t x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) { |
|
|
SERIAL_PROTOCOL_F(bed_level_grid[x][y], 2); |
|
|
SERIAL_PROTOCOL_F(bed_level_grid[x][y], 2); |
|
|
SERIAL_PROTOCOLCHAR(' '); |
|
|
SERIAL_PROTOCOLCHAR(' '); |
|
|
} |
|
|
} |
|
|