|
@@ -2432,33 +2432,41 @@ static void clean_up_after_endstop_or_probe_move() {
|
2432
|
2432
|
/**
|
2433
|
2433
|
* Print calibration results for plotting or manual frame adjustment.
|
2434
|
2434
|
*/
|
2435
|
|
- static void print_bilinear_leveling_grid() {
|
2436
|
|
- SERIAL_ECHOPGM("Bilinear Leveling Grid:\n ");
|
2437
|
|
- for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
|
2438
|
|
- SERIAL_PROTOCOLPGM(" ");
|
2439
|
|
- if (x < 10) SERIAL_PROTOCOLCHAR(' ');
|
|
2435
|
+ static void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, float (*fn)(const uint8_t, const uint8_t)) {
|
|
2436
|
+ for (uint8_t x = 0; x < sx; x++) {
|
|
2437
|
+ for (uint8_t i = 0; i < precision + 2 + (x < 10 ? 1 : 0); i++)
|
|
2438
|
+ SERIAL_PROTOCOLCHAR(' ');
|
2440
|
2439
|
SERIAL_PROTOCOL((int)x);
|
2441
|
2440
|
}
|
2442
|
2441
|
SERIAL_EOL;
|
2443
|
|
- for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++) {
|
|
2442
|
+ for (uint8_t y = 0; y < sy; y++) {
|
2444
|
2443
|
if (y < 10) SERIAL_PROTOCOLCHAR(' ');
|
2445
|
2444
|
SERIAL_PROTOCOL((int)y);
|
2446
|
|
- for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
|
|
2445
|
+ for (uint8_t x = 0; x < sx; x++) {
|
2447
|
2446
|
SERIAL_PROTOCOLCHAR(' ');
|
2448
|
|
- float offset = bed_level_grid[x][y];
|
|
2447
|
+ float offset = fn(x, y);
|
2449
|
2448
|
if (offset != UNPROBED) {
|
2450
|
|
- if (offset > 0) SERIAL_CHAR('+');
|
2451
|
|
- SERIAL_PROTOCOL_F(offset, 2);
|
|
2449
|
+ if (offset >= 0) SERIAL_CHAR('+');
|
|
2450
|
+ SERIAL_PROTOCOL_F(offset, precision);
|
2452
|
2451
|
}
|
2453
|
2452
|
else
|
2454
|
|
- SERIAL_PROTOCOLPGM(" ====");
|
|
2453
|
+ for (uint8_t i = 0; i < precision + 3; i++)
|
|
2454
|
+ SERIAL_PROTOCOLCHAR(i ? '=' : ' ');
|
2455
|
2455
|
}
|
2456
|
2456
|
SERIAL_EOL;
|
2457
|
2457
|
}
|
2458
|
2458
|
SERIAL_EOL;
|
2459
|
2459
|
}
|
2460
|
2460
|
|
|
2461
|
+ static void print_bilinear_leveling_grid() {
|
|
2462
|
+ SERIAL_ECHOLNPGM("Bilinear Leveling Grid:");
|
|
2463
|
+ print_2d_array(ABL_GRID_MAX_POINTS_X, ABL_GRID_MAX_POINTS_Y, 2,
|
|
2464
|
+ [](const uint8_t x, const uint8_t y) { return bed_level_grid[x][y]; }
|
|
2465
|
+ );
|
|
2466
|
+ }
|
|
2467
|
+
|
2461
|
2468
|
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
|
2469
|
+
|
2462
|
2470
|
#define ABL_GRID_POINTS_VIRT_X (ABL_GRID_MAX_POINTS_X - 1) * (BILINEAR_SUBDIVISIONS) + 1
|
2463
|
2471
|
#define ABL_GRID_POINTS_VIRT_Y (ABL_GRID_MAX_POINTS_Y - 1) * (BILINEAR_SUBDIVISIONS) + 1
|
2464
|
2472
|
#define ABL_TEMP_POINTS_X (ABL_GRID_MAX_POINTS_X + 2)
|
|
@@ -2468,29 +2476,11 @@ static void clean_up_after_endstop_or_probe_move() {
|
2468
|
2476
|
|
2469
|
2477
|
static void bed_level_virt_print() {
|
2470
|
2478
|
SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:");
|
2471
|
|
- for (uint8_t x = 0; x < ABL_GRID_POINTS_VIRT_X; x++) {
|
2472
|
|
- SERIAL_PROTOCOLPGM(" ");
|
2473
|
|
- if (x < 10) SERIAL_PROTOCOLCHAR(' ');
|
2474
|
|
- SERIAL_PROTOCOL((int)x);
|
2475
|
|
- }
|
2476
|
|
- SERIAL_EOL;
|
2477
|
|
- for (uint8_t y = 0; y < ABL_GRID_POINTS_VIRT_Y; y++) {
|
2478
|
|
- if (y < 10) SERIAL_PROTOCOLCHAR(' ');
|
2479
|
|
- SERIAL_PROTOCOL((int)y);
|
2480
|
|
- for (uint8_t x = 0; x < ABL_GRID_POINTS_VIRT_X; x++) {
|
2481
|
|
- SERIAL_PROTOCOLCHAR(' ');
|
2482
|
|
- float offset = bed_level_grid_virt[x][y];
|
2483
|
|
- if (offset != UNPROBED) {
|
2484
|
|
- if (offset >= 0) SERIAL_CHAR('+');
|
2485
|
|
- SERIAL_PROTOCOL_F(offset, 5);
|
2486
|
|
- }
|
2487
|
|
- else
|
2488
|
|
- SERIAL_PROTOCOLPGM(" ====");
|
2489
|
|
- }
|
2490
|
|
- SERIAL_EOL;
|
2491
|
|
- }
|
2492
|
|
- SERIAL_EOL;
|
|
2479
|
+ print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5,
|
|
2480
|
+ [](const uint8_t x, const uint8_t y) { return bed_level_grid_virt[x][y]; }
|
|
2481
|
+ );
|
2493
|
2482
|
}
|
|
2483
|
+
|
2494
|
2484
|
#define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I))
|
2495
|
2485
|
float bed_level_virt_coord(const uint8_t x, const uint8_t y) {
|
2496
|
2486
|
uint8_t ep = 0, ip = 1;
|
|
@@ -2528,6 +2518,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2528
|
2518
|
}
|
2529
|
2519
|
return bed_level_grid[x - 1][y - 1];
|
2530
|
2520
|
}
|
|
2521
|
+
|
2531
|
2522
|
static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) {
|
2532
|
2523
|
return (
|
2533
|
2524
|
p[i-1] * -t * sq(1 - t)
|
|
@@ -2536,6 +2527,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2536
|
2527
|
- p[i+2] * sq(t) * (1 - t)
|
2537
|
2528
|
) * 0.5;
|
2538
|
2529
|
}
|
|
2530
|
+
|
2539
|
2531
|
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const float &tx, const float &ty) {
|
2540
|
2532
|
float row[4], column[4];
|
2541
|
2533
|
for (uint8_t i = 0; i < 4; i++) {
|
|
@@ -2546,6 +2538,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2546
|
2538
|
}
|
2547
|
2539
|
return bed_level_virt_cmr(row, 1, tx);
|
2548
|
2540
|
}
|
|
2541
|
+
|
2549
|
2542
|
void bed_level_virt_interpolate() {
|
2550
|
2543
|
for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
|
2551
|
2544
|
for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
|
|
@@ -2565,7 +2558,6 @@ static void clean_up_after_endstop_or_probe_move() {
|
2565
|
2558
|
#endif // ABL_BILINEAR_SUBDIVISION
|
2566
|
2559
|
#endif // AUTO_BED_LEVELING_BILINEAR
|
2567
|
2560
|
|
2568
|
|
-
|
2569
|
2561
|
/**
|
2570
|
2562
|
* Home an individual linear axis
|
2571
|
2563
|
*/
|