|
@@ -494,7 +494,7 @@ static uint8_t target_extruder;
|
494
|
494
|
|
495
|
495
|
#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
496
|
496
|
int nonlinear_grid_spacing[2] = { 0 };
|
497
|
|
- float bed_level_grid[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
|
|
497
|
+ float bed_level_grid[ABL_GRID_POINTS_X][ABL_GRID_POINTS_Y];
|
498
|
498
|
#endif
|
499
|
499
|
|
500
|
500
|
#if IS_SCARA
|
|
@@ -2122,14 +2122,15 @@ static void clean_up_after_endstop_or_probe_move() {
|
2122
|
2122
|
* using linear extrapolation, away from the center.
|
2123
|
2123
|
*/
|
2124
|
2124
|
static void extrapolate_unprobed_bed_level() {
|
2125
|
|
- uint8_t half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
|
2126
|
|
- for (uint8_t y = 0; y <= half; y++) {
|
2127
|
|
- for (uint8_t x = 0; x <= half; x++) {
|
|
2125
|
+ int half_x = (ABL_GRID_POINTS_X - 1) / 2,
|
|
2126
|
+ half_y = (ABL_GRID_POINTS_Y - 1) / 2;
|
|
2127
|
+ for (uint8_t y = 0; y <= half_y; y++) {
|
|
2128
|
+ for (uint8_t x = 0; x <= half_x; x++) {
|
2128
|
2129
|
if (x + y < 3) continue;
|
2129
|
|
- extrapolate_one_point(half - x, half - y, x > 1 ? +1 : 0, y > 1 ? +1 : 0);
|
2130
|
|
- extrapolate_one_point(half + x, half - y, x > 1 ? -1 : 0, y > 1 ? +1 : 0);
|
2131
|
|
- extrapolate_one_point(half - x, half + y, x > 1 ? +1 : 0, y > 1 ? -1 : 0);
|
2132
|
|
- extrapolate_one_point(half + x, half + y, x > 1 ? -1 : 0, y > 1 ? -1 : 0);
|
|
2130
|
+ extrapolate_one_point(half_x - x, half_y - y, x > 1 ? +1 : 0, y > 1 ? +1 : 0);
|
|
2131
|
+ extrapolate_one_point(half_x + x, half_y - y, x > 1 ? -1 : 0, y > 1 ? +1 : 0);
|
|
2132
|
+ extrapolate_one_point(half_x - x, half_y + y, x > 1 ? +1 : 0, y > 1 ? -1 : 0);
|
|
2133
|
+ extrapolate_one_point(half_x + x, half_y + y, x > 1 ? -1 : 0, y > 1 ? -1 : 0);
|
2133
|
2134
|
}
|
2134
|
2135
|
}
|
2135
|
2136
|
}
|
|
@@ -2138,8 +2139,8 @@ static void clean_up_after_endstop_or_probe_move() {
|
2138
|
2139
|
* Print calibration results for plotting or manual frame adjustment.
|
2139
|
2140
|
*/
|
2140
|
2141
|
static void print_bed_level() {
|
2141
|
|
- for (uint8_t y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
|
2142
|
|
- for (uint8_t x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
|
|
2142
|
+ for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++) {
|
|
2143
|
+ for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++) {
|
2143
|
2144
|
SERIAL_PROTOCOL_F(bed_level_grid[x][y], 2);
|
2144
|
2145
|
SERIAL_PROTOCOLCHAR(' ');
|
2145
|
2146
|
}
|
|
@@ -3308,11 +3309,12 @@ inline void gcode_G28() {
|
3308
|
3309
|
if (dryrun) SERIAL_PROTOCOLLNPGM("Running in DRY-RUN mode");
|
3309
|
3310
|
}
|
3310
|
3311
|
|
3311
|
|
- int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
|
|
3312
|
+ int abl_grid_points_x = ABL_GRID_POINTS_X,
|
|
3313
|
+ abl_grid_points_y = ABL_GRID_POINTS_Y;
|
3312
|
3314
|
|
3313
|
3315
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
3314
|
|
- if (code_seen('P')) auto_bed_leveling_grid_points = code_value_int();
|
3315
|
|
- if (auto_bed_leveling_grid_points < 2) {
|
|
3316
|
+ if (code_seen('P')) abl_grid_points_x = abl_grid_points_y = code_value_int();
|
|
3317
|
+ if (abl_grid_points_x < 2) {
|
3316
|
3318
|
SERIAL_PROTOCOLLNPGM("?Number of probed (P)oints is implausible (2 minimum).");
|
3317
|
3319
|
return;
|
3318
|
3320
|
}
|
|
@@ -3400,8 +3402,8 @@ inline void gcode_G28() {
|
3400
|
3402
|
#if ENABLED(AUTO_BED_LEVELING_GRID)
|
3401
|
3403
|
|
3402
|
3404
|
// probe at the points of a lattice grid
|
3403
|
|
- const float xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1),
|
3404
|
|
- yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
|
|
3405
|
+ const float xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (abl_grid_points_x - 1),
|
|
3406
|
+ yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (abl_grid_points_y - 1);
|
3405
|
3407
|
|
3406
|
3408
|
#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
3407
|
3409
|
|
|
@@ -3421,30 +3423,31 @@ inline void gcode_G28() {
|
3421
|
3423
|
* so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
3422
|
3424
|
*/
|
3423
|
3425
|
|
3424
|
|
- int abl2 = sq(auto_bed_leveling_grid_points);
|
|
3426
|
+ int abl2 = abl_grid_points_x * abl_grid_points_y;
|
3425
|
3427
|
|
3426
|
3428
|
double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
|
3427
|
3429
|
eqnBVector[abl2], // "B" vector of Z points
|
3428
|
3430
|
mean = 0.0;
|
3429
|
|
- int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points];
|
|
3431
|
+ int indexIntoAB[abl_grid_points_x][abl_grid_points_y];
|
3430
|
3432
|
|
3431
|
3433
|
#endif // AUTO_BED_LEVELING_LINEAR
|
3432
|
3434
|
|
3433
|
3435
|
int probePointCounter = 0;
|
3434
|
|
- bool zig = auto_bed_leveling_grid_points & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
|
|
3436
|
+ bool zig = abl_grid_points_y & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
|
3435
|
3437
|
|
3436
|
|
- for (uint8_t yCount = 0; yCount < auto_bed_leveling_grid_points; yCount++) {
|
|
3438
|
+ for (uint8_t yCount = 0; yCount < abl_grid_points_y; yCount++) {
|
3437
|
3439
|
float yBase = front_probe_bed_position + yGridSpacing * yCount;
|
3438
|
3440
|
yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
|
|
3441
|
+
|
3439
|
3442
|
int8_t xStart, xStop, xInc;
|
3440
|
3443
|
|
3441
|
3444
|
if (zig) {
|
3442
|
3445
|
xStart = 0;
|
3443
|
|
- xStop = auto_bed_leveling_grid_points;
|
|
3446
|
+ xStop = abl_grid_points_x;
|
3444
|
3447
|
xInc = 1;
|
3445
|
3448
|
}
|
3446
|
3449
|
else {
|
3447
|
|
- xStart = auto_bed_leveling_grid_points - 1;
|
|
3450
|
+ xStart = abl_grid_points_x - 1;
|
3448
|
3451
|
xStop = -1;
|
3449
|
3452
|
xInc = -1;
|
3450
|
3453
|
}
|
|
@@ -3579,8 +3582,8 @@ inline void gcode_G28() {
|
3579
|
3582
|
|
3580
|
3583
|
float min_diff = 999;
|
3581
|
3584
|
|
3582
|
|
- for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
|
3583
|
|
- for (uint8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
|
|
3585
|
+ for (int8_t yy = abl_grid_points_y - 1; yy >= 0; yy--) {
|
|
3586
|
+ for (uint8_t xx = 0; xx < abl_grid_points_x; xx++) {
|
3584
|
3587
|
int ind = indexIntoAB[xx][yy];
|
3585
|
3588
|
float diff = eqnBVector[ind] - mean,
|
3586
|
3589
|
x_tmp = eqnAMatrix[ind + 0 * abl2],
|
|
@@ -3604,8 +3607,8 @@ inline void gcode_G28() {
|
3604
|
3607
|
if (verbose_level > 3) {
|
3605
|
3608
|
SERIAL_PROTOCOLLNPGM("\nCorrected Bed Height vs. Bed Topology:");
|
3606
|
3609
|
|
3607
|
|
- for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
|
3608
|
|
- for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
|
|
3610
|
+ for (int8_t yy = abl_grid_points_y - 1; yy >= 0; yy--) {
|
|
3611
|
+ for (uint8_t xx = 0; xx < abl_grid_points_x; xx++) {
|
3609
|
3612
|
int ind = indexIntoAB[xx][yy];
|
3610
|
3613
|
float x_tmp = eqnAMatrix[ind + 0 * abl2],
|
3611
|
3614
|
y_tmp = eqnAMatrix[ind + 1 * abl2],
|
|
@@ -7796,16 +7799,18 @@ void ok_to_send() {
|
7796
|
7799
|
void adjust_delta(float cartesian[XYZ]) {
|
7797
|
7800
|
if (nonlinear_grid_spacing[X_AXIS] == 0 || nonlinear_grid_spacing[Y_AXIS] == 0) return; // G29 not done!
|
7798
|
7801
|
|
7799
|
|
- int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
|
7800
|
|
- float h1 = 0.001 - half, h2 = half - 0.001,
|
7801
|
|
- grid_x = max(h1, min(h2, RAW_X_POSITION(cartesian[X_AXIS]) / nonlinear_grid_spacing[X_AXIS])),
|
7802
|
|
- grid_y = max(h1, min(h2, RAW_Y_POSITION(cartesian[Y_AXIS]) / nonlinear_grid_spacing[Y_AXIS]));
|
7803
|
|
- int floor_x = floor(grid_x), floor_y = floor(grid_y);
|
|
7802
|
+ int half_x = (ABL_GRID_POINTS_X - 1) / 2,
|
|
7803
|
+ half_y = (ABL_GRID_POINTS_Y - 1) / 2;
|
|
7804
|
+ float hx2 = half_x - 0.001, hx1 = -hx2,
|
|
7805
|
+ hy2 = half_y - 0.001, hy1 = -hy2,
|
|
7806
|
+ grid_x = max(hx1, min(hx2, RAW_X_POSITION(cartesian[X_AXIS]) / nonlinear_grid_spacing[X_AXIS])),
|
|
7807
|
+ grid_y = max(hy1, min(hy2, RAW_Y_POSITION(cartesian[Y_AXIS]) / nonlinear_grid_spacing[Y_AXIS]));
|
|
7808
|
+ int floor_x = floor(grid_x), floor_y = floor(grid_y);
|
7804
|
7809
|
float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
|
7805
|
|
- z1 = bed_level_grid[floor_x + half][floor_y + half],
|
7806
|
|
- z2 = bed_level_grid[floor_x + half][floor_y + half + 1],
|
7807
|
|
- z3 = bed_level_grid[floor_x + half + 1][floor_y + half],
|
7808
|
|
- z4 = bed_level_grid[floor_x + half + 1][floor_y + half + 1],
|
|
7810
|
+ z1 = bed_level_grid[floor_x + half_x][floor_y + half_y],
|
|
7811
|
+ z2 = bed_level_grid[floor_x + half_x][floor_y + half_y + 1],
|
|
7812
|
+ z3 = bed_level_grid[floor_x + half_x + 1][floor_y + half_y],
|
|
7813
|
+ z4 = bed_level_grid[floor_x + half_x + 1][floor_y + half_y + 1],
|
7809
|
7814
|
left = (1 - ratio_y) * z1 + ratio_y * z2,
|
7810
|
7815
|
right = (1 - ratio_y) * z3 + ratio_y * z4,
|
7811
|
7816
|
offset = (1 - ratio_x) * left + ratio_x * right;
|