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