|
@@ -2092,23 +2092,14 @@ static void clean_up_after_endstop_or_probe_move() {
|
2092
|
2092
|
/**
|
2093
|
2093
|
* All DELTA leveling in the Marlin uses NONLINEAR_BED_LEVELING
|
2094
|
2094
|
*/
|
2095
|
|
- static void extrapolate_one_point(int x, int y, int xdir, int ydir) {
|
2096
|
|
- if (bed_level_grid[x][y] != 0.0) {
|
2097
|
|
- return; // Don't overwrite good values.
|
2098
|
|
- }
|
2099
|
|
- float a = 2 * bed_level_grid[x + xdir][y] - bed_level_grid[x + xdir * 2][y]; // Left to right.
|
2100
|
|
- float b = 2 * bed_level_grid[x][y + ydir] - bed_level_grid[x][y + ydir * 2]; // Front to back.
|
2101
|
|
- float c = 2 * bed_level_grid[x + xdir][y + ydir] - bed_level_grid[x + xdir * 2][y + ydir * 2]; // Diagonal.
|
2102
|
|
- float median = c; // Median is robust (ignores outliers).
|
2103
|
|
- if (a < b) {
|
2104
|
|
- if (b < c) median = b;
|
2105
|
|
- if (c < a) median = a;
|
2106
|
|
- }
|
2107
|
|
- else { // b <= a
|
2108
|
|
- if (c < b) median = b;
|
2109
|
|
- if (a < c) median = a;
|
2110
|
|
- }
|
2111
|
|
- bed_level_grid[x][y] = median;
|
|
2095
|
+ static void extrapolate_one_point(uint8_t x, uint8_t y, int xdir, int ydir) {
|
|
2096
|
+ if (bed_level_grid[x][y]) return; // Don't overwrite good values.
|
|
2097
|
+ float a = 2 * bed_level_grid[x + xdir][y] - bed_level_grid[x + xdir * 2][y], // Left to right.
|
|
2098
|
+ b = 2 * bed_level_grid[x][y + ydir] - bed_level_grid[x][y + ydir * 2], // Front to back.
|
|
2099
|
+ c = 2 * bed_level_grid[x + xdir][y + ydir] - bed_level_grid[x + xdir * 2][y + ydir * 2]; // Diagonal.
|
|
2100
|
+ // Median is robust (ignores outliers).
|
|
2101
|
+ bed_level_grid[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c)
|
|
2102
|
+ : ((c < b) ? b : (a < c) ? a : c);
|
2112
|
2103
|
}
|
2113
|
2104
|
|
2114
|
2105
|
/**
|
|
@@ -2116,9 +2107,9 @@ static void clean_up_after_endstop_or_probe_move() {
|
2116
|
2107
|
* using linear extrapolation, away from the center.
|
2117
|
2108
|
*/
|
2118
|
2109
|
static void extrapolate_unprobed_bed_level() {
|
2119
|
|
- int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
|
2120
|
|
- for (int y = 0; y <= half; y++) {
|
2121
|
|
- for (int x = 0; x <= half; x++) {
|
|
2110
|
+ uint8_t half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
|
|
2111
|
+ for (uint8_t y = 0; y <= half; y++) {
|
|
2112
|
+ for (uint8_t x = 0; x <= half; x++) {
|
2122
|
2113
|
if (x + y < 3) continue;
|
2123
|
2114
|
extrapolate_one_point(half - x, half - y, x > 1 ? +1 : 0, y > 1 ? +1 : 0);
|
2124
|
2115
|
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() {
|
2132
|
2123
|
* Print calibration results for plotting or manual frame adjustment.
|
2133
|
2124
|
*/
|
2134
|
2125
|
static void print_bed_level() {
|
2135
|
|
- for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
|
2136
|
|
- for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
|
|
2126
|
+ for (uint8_t y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
|
|
2127
|
+ for (uint8_t x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
|
2137
|
2128
|
SERIAL_PROTOCOL_F(bed_level_grid[x][y], 2);
|
2138
|
2129
|
SERIAL_PROTOCOLCHAR(' ');
|
2139
|
2130
|
}
|