Browse Source

Merge pull request #5452 from thinkyhead/rc_save_your_mesh

Save Bed Leveling to EEPROM
Scott Lahteine 7 years ago
parent
commit
78d6d6e076
28 changed files with 451 additions and 236 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 7
    1
      Marlin/Marlin.h
  3. 185
    93
      Marlin/Marlin_main.cpp
  4. 7
    5
      Marlin/SanityCheck.h
  5. 203
    89
      Marlin/configuration_store.cpp
  6. 2
    2
      Marlin/example_configurations/Cartesio/Configuration.h
  7. 2
    2
      Marlin/example_configurations/Felix/Configuration.h
  8. 2
    2
      Marlin/example_configurations/Felix/DUAL/Configuration.h
  9. 2
    2
      Marlin/example_configurations/Hephestos/Configuration.h
  10. 2
    2
      Marlin/example_configurations/Hephestos_2/Configuration.h
  11. 2
    2
      Marlin/example_configurations/K8200/Configuration.h
  12. 2
    2
      Marlin/example_configurations/K8400/Configuration.h
  13. 2
    2
      Marlin/example_configurations/K8400/Dual-head/Configuration.h
  14. 2
    2
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  15. 2
    2
      Marlin/example_configurations/RigidBot/Configuration.h
  16. 2
    2
      Marlin/example_configurations/SCARA/Configuration.h
  17. 2
    2
      Marlin/example_configurations/TAZ4/Configuration.h
  18. 2
    2
      Marlin/example_configurations/WITBOX/Configuration.h
  19. 2
    2
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  20. 2
    2
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  21. 2
    2
      Marlin/example_configurations/delta/generic/Configuration.h
  22. 2
    2
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  23. 2
    2
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  24. 2
    2
      Marlin/example_configurations/delta/kossel_xl/Configuration.h
  25. 2
    2
      Marlin/example_configurations/makibox/Configuration.h
  26. 2
    2
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  27. 3
    2
      Marlin/language.h
  28. 2
    2
      Marlin/planner.h

+ 2
- 2
Marlin/Configuration.h View File

@@ -805,8 +805,8 @@
805 805
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
806 806
 
807 807
   // Set the number of grid points per dimension.
808
-  #define ABL_GRID_POINTS_X 3
809
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
808
+  #define ABL_GRID_MAX_POINTS_X 3
809
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
810 810
 
811 811
   // Set the boundaries for probing (where the probe can reach).
812 812
   #define LEFT_PROBE_BED_POSITION 15

+ 7
- 1
Marlin/Marlin.h View File

@@ -330,8 +330,14 @@ float code_value_temp_diff();
330 330
 #endif
331 331
 
332 332
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
333
-  extern int bilinear_grid_spacing[2];
333
+  extern int bilinear_grid_spacing[2], bilinear_start[2];
334
+  extern float bed_level_grid[ABL_GRID_MAX_POINTS_X][ABL_GRID_MAX_POINTS_Y];
334 335
   float bilinear_z_offset(float logical[XYZ]);
336
+  void set_bed_leveling_enabled(bool enable=true);
337
+#endif
338
+
339
+#if PLANNER_LEVELING
340
+  void reset_bed_level();
335 341
 #endif
336 342
 
337 343
 #if ENABLED(Z_DUAL_ENDSTOPS)

+ 185
- 93
Marlin/Marlin_main.cpp View File

@@ -575,8 +575,9 @@ static uint8_t target_extruder;
575 575
 #endif
576 576
 
577 577
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
578
-  int bilinear_grid_spacing[2] = { 0 }, bilinear_start[2] = { 0 };
579
-  float bed_level_grid[ABL_GRID_POINTS_X][ABL_GRID_POINTS_Y];
578
+  #define UNPROBED 9999.0f
579
+  int bilinear_grid_spacing[2], bilinear_start[2];
580
+  float bed_level_grid[ABL_GRID_MAX_POINTS_X][ABL_GRID_MAX_POINTS_Y];
580 581
 #endif
581 582
 
582 583
 #if IS_SCARA
@@ -2228,7 +2229,7 @@ static void clean_up_after_endstop_or_probe_move() {
2228 2229
    * Disable: Current position = physical position
2229 2230
    *  Enable: Current position = "unleveled" physical position
2230 2231
    */
2231
-  void set_bed_leveling_enabled(bool enable=true) {
2232
+  void set_bed_leveling_enabled(bool enable/*=true*/) {
2232 2233
     #if ENABLED(MESH_BED_LEVELING)
2233 2234
 
2234 2235
       if (enable != mbl.active()) {
@@ -2243,7 +2244,13 @@ static void clean_up_after_endstop_or_probe_move() {
2243 2244
 
2244 2245
     #elif HAS_ABL
2245 2246
 
2246
-      if (enable != planner.abl_enabled) {
2247
+      #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
2248
+        const bool can_change = (!enable || (bilinear_grid_spacing[0] && bilinear_grid_spacing[1]));
2249
+      #else
2250
+        constexpr bool can_change = true;
2251
+      #endif
2252
+
2253
+      if (can_change && enable != planner.abl_enabled) {
2247 2254
         planner.abl_enabled = enable;
2248 2255
         if (!enable)
2249 2256
           set_current_from_steppers_for_axis(
@@ -2289,23 +2296,24 @@ static void clean_up_after_endstop_or_probe_move() {
2289 2296
    * Reset calibration results to zero.
2290 2297
    */
2291 2298
   void reset_bed_level() {
2299
+    set_bed_leveling_enabled(false);
2292 2300
     #if ENABLED(MESH_BED_LEVELING)
2293 2301
       if (mbl.has_mesh()) {
2294
-        set_bed_leveling_enabled(false);
2295 2302
         mbl.reset();
2296 2303
         mbl.set_has_mesh(false);
2297 2304
       }
2298 2305
     #else
2299
-      planner.abl_enabled = false;
2300 2306
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2301 2307
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
2302 2308
       #endif
2303 2309
       #if ABL_PLANAR
2304 2310
         planner.bed_level_matrix.set_to_identity();
2305 2311
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
2306
-        for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++)
2307
-          for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
2308
-            bed_level_grid[x][y] = 1000.0;
2312
+        bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
2313
+        bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
2314
+        for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
2315
+          for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
2316
+            bed_level_grid[x][y] = UNPROBED;
2309 2317
       #endif
2310 2318
     #endif
2311 2319
   }
@@ -2331,7 +2339,7 @@ static void clean_up_after_endstop_or_probe_move() {
2331 2339
         SERIAL_CHAR(']');
2332 2340
       }
2333 2341
     #endif
2334
-    if (bed_level_grid[x][y] < 999.0) {
2342
+    if (bed_level_grid[x][y] != UNPROBED) {
2335 2343
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2336 2344
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" (done)");
2337 2345
       #endif
@@ -2345,13 +2353,13 @@ static void clean_up_after_endstop_or_probe_move() {
2345 2353
           c1 = bed_level_grid[x + xdir][y + ydir], c2 = bed_level_grid[x + xdir * 2][y + ydir * 2];
2346 2354
 
2347 2355
     // Treat far unprobed points as zero, near as equal to far
2348
-    if (a2 > 999.0) a2 = 0.0; if (a1 > 999.0) a1 = a2;
2349
-    if (b2 > 999.0) b2 = 0.0; if (b1 > 999.0) b1 = b2;
2350
-    if (c2 > 999.0) c2 = 0.0; if (c1 > 999.0) c1 = c2;
2356
+    if (a2 == UNPROBED) a2 = 0.0; if (a1 == UNPROBED) a1 = a2;
2357
+    if (b2 == UNPROBED) b2 = 0.0; if (b1 == UNPROBED) b1 = b2;
2358
+    if (c2 == UNPROBED) c2 = 0.0; if (c1 == UNPROBED) c1 = c2;
2351 2359
 
2352 2360
     float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
2353 2361
 
2354
-    // Take the average intstead of the median
2362
+    // Take the average instead of the median
2355 2363
     bed_level_grid[x][y] = (a + b + c) / 3.0;
2356 2364
 
2357 2365
     // Median is robust (ignores outliers).
@@ -2363,9 +2371,9 @@ static void clean_up_after_endstop_or_probe_move() {
2363 2371
   //#define EXTRAPOLATE_FROM_EDGE
2364 2372
 
2365 2373
   #if ENABLED(EXTRAPOLATE_FROM_EDGE)
2366
-    #if ABL_GRID_POINTS_X < ABL_GRID_POINTS_Y
2374
+    #if ABL_GRID_MAX_POINTS_X < ABL_GRID_MAX_POINTS_Y
2367 2375
       #define HALF_IN_X
2368
-    #elif ABL_GRID_POINTS_Y < ABL_GRID_POINTS_X
2376
+    #elif ABL_GRID_MAX_POINTS_Y < ABL_GRID_MAX_POINTS_X
2369 2377
       #define HALF_IN_Y
2370 2378
     #endif
2371 2379
   #endif
@@ -2376,18 +2384,18 @@ static void clean_up_after_endstop_or_probe_move() {
2376 2384
    */
2377 2385
   static void extrapolate_unprobed_bed_level() {
2378 2386
     #ifdef HALF_IN_X
2379
-      const uint8_t ctrx2 = 0, xlen = ABL_GRID_POINTS_X - 1;
2387
+      const uint8_t ctrx2 = 0, xlen = ABL_GRID_MAX_POINTS_X - 1;
2380 2388
     #else
2381
-      const uint8_t ctrx1 = (ABL_GRID_POINTS_X - 1) / 2, // left-of-center
2382
-                    ctrx2 = ABL_GRID_POINTS_X / 2,       // right-of-center
2389
+      const uint8_t ctrx1 = (ABL_GRID_MAX_POINTS_X - 1) / 2, // left-of-center
2390
+                    ctrx2 = ABL_GRID_MAX_POINTS_X / 2,       // right-of-center
2383 2391
                     xlen = ctrx1;
2384 2392
     #endif
2385 2393
 
2386 2394
     #ifdef HALF_IN_Y
2387
-      const uint8_t ctry2 = 0, ylen = ABL_GRID_POINTS_Y - 1;
2395
+      const uint8_t ctry2 = 0, ylen = ABL_GRID_MAX_POINTS_Y - 1;
2388 2396
     #else
2389
-      const uint8_t ctry1 = (ABL_GRID_POINTS_Y - 1) / 2, // top-of-center
2390
-                    ctry2 = ABL_GRID_POINTS_Y / 2,       // bottom-of-center
2397
+      const uint8_t ctry1 = (ABL_GRID_MAX_POINTS_Y - 1) / 2, // top-of-center
2398
+                    ctry2 = ABL_GRID_MAX_POINTS_Y / 2,       // bottom-of-center
2391 2399
                     ylen = ctry1;
2392 2400
     #endif
2393 2401
 
@@ -2415,21 +2423,21 @@ static void clean_up_after_endstop_or_probe_move() {
2415 2423
   /**
2416 2424
    * Print calibration results for plotting or manual frame adjustment.
2417 2425
    */
2418
-  static void print_bed_level() {
2426
+  static void print_bilinear_leveling_grid() {
2419 2427
     SERIAL_ECHOPGM("Bilinear Leveling Grid:\n ");
2420
-    for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++) {
2428
+    for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
2421 2429
       SERIAL_PROTOCOLPGM("    ");
2422 2430
       if (x < 10) SERIAL_PROTOCOLCHAR(' ');
2423 2431
       SERIAL_PROTOCOL((int)x);
2424 2432
     }
2425 2433
     SERIAL_EOL;
2426
-    for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++) {
2434
+    for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++) {
2427 2435
       if (y < 10) SERIAL_PROTOCOLCHAR(' ');
2428 2436
       SERIAL_PROTOCOL((int)y);
2429
-      for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++) {
2437
+      for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
2430 2438
         SERIAL_PROTOCOLCHAR(' ');
2431 2439
         float offset = bed_level_grid[x][y];
2432
-        if (offset < 999.0) {
2440
+        if (offset != UNPROBED) {
2433 2441
           if (offset > 0) SERIAL_CHAR('+');
2434 2442
           SERIAL_PROTOCOL_F(offset, 2);
2435 2443
         }
@@ -2442,10 +2450,10 @@ static void clean_up_after_endstop_or_probe_move() {
2442 2450
   }
2443 2451
 
2444 2452
   #if ENABLED(ABL_BILINEAR_SUBDIVISION)
2445
-    #define ABL_GRID_POINTS_VIRT_X (ABL_GRID_POINTS_X - 1) * (BILINEAR_SUBDIVISIONS) + 1
2446
-    #define ABL_GRID_POINTS_VIRT_Y (ABL_GRID_POINTS_Y - 1) * (BILINEAR_SUBDIVISIONS) + 1
2453
+    #define ABL_GRID_POINTS_VIRT_X (ABL_GRID_MAX_POINTS_X - 1) * (BILINEAR_SUBDIVISIONS) + 1
2454
+    #define ABL_GRID_POINTS_VIRT_Y (ABL_GRID_MAX_POINTS_Y - 1) * (BILINEAR_SUBDIVISIONS) + 1
2447 2455
     float bed_level_grid_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y];
2448
-    float bed_level_grid_virt_temp[ABL_GRID_POINTS_X + 2][ABL_GRID_POINTS_Y + 2]; //temporary for calculation (maybe dynamical?)
2456
+    float bed_level_grid_virt_temp[ABL_GRID_MAX_POINTS_X + 2][ABL_GRID_MAX_POINTS_Y + 2]; //temporary for calculation (maybe dynamical?)
2449 2457
     int bilinear_grid_spacing_virt[2] = { 0 };
2450 2458
 
2451 2459
     static void bed_level_virt_print() {
@@ -2462,7 +2470,7 @@ static void clean_up_after_endstop_or_probe_move() {
2462 2470
         for (uint8_t x = 0; x < ABL_GRID_POINTS_VIRT_X; x++) {
2463 2471
           SERIAL_PROTOCOLCHAR(' ');
2464 2472
           float offset = bed_level_grid_virt[x][y];
2465
-          if (offset < 999.0) {
2473
+          if (offset != UNPROBED) {
2466 2474
             if (offset > 0) SERIAL_CHAR('+');
2467 2475
             SERIAL_PROTOCOL_F(offset, 5);
2468 2476
           }
@@ -2474,10 +2482,10 @@ static void clean_up_after_endstop_or_probe_move() {
2474 2482
       SERIAL_EOL;
2475 2483
     }
2476 2484
     #define LINEAR_EXTRAPOLATION(E, I) (E * 2 - I)
2477
-    static void bed_level_virt_prepare() {
2478
-      for (uint8_t y = 1; y <= ABL_GRID_POINTS_Y; y++) {
2485
+    void bed_level_virt_prepare() {
2486
+      for (uint8_t y = 1; y <= ABL_GRID_MAX_POINTS_Y; y++) {
2479 2487
 
2480
-        for (uint8_t x = 1; x <= ABL_GRID_POINTS_X; x++)
2488
+        for (uint8_t x = 1; x <= ABL_GRID_MAX_POINTS_X; x++)
2481 2489
           bed_level_grid_virt_temp[x][y] = bed_level_grid[x - 1][y - 1];
2482 2490
 
2483 2491
         bed_level_grid_virt_temp[0][y] = LINEAR_EXTRAPOLATION(
@@ -2485,21 +2493,21 @@ static void clean_up_after_endstop_or_probe_move() {
2485 2493
           bed_level_grid_virt_temp[2][y]
2486 2494
         );
2487 2495
 
2488
-        bed_level_grid_virt_temp[(ABL_GRID_POINTS_X + 2) - 1][y] =
2496
+        bed_level_grid_virt_temp[(ABL_GRID_MAX_POINTS_X + 2) - 1][y] =
2489 2497
           LINEAR_EXTRAPOLATION(
2490
-            bed_level_grid_virt_temp[(ABL_GRID_POINTS_X + 2) - 2][y],
2491
-            bed_level_grid_virt_temp[(ABL_GRID_POINTS_X + 2) - 3][y]
2498
+            bed_level_grid_virt_temp[(ABL_GRID_MAX_POINTS_X + 2) - 2][y],
2499
+            bed_level_grid_virt_temp[(ABL_GRID_MAX_POINTS_X + 2) - 3][y]
2492 2500
           );
2493 2501
       }
2494
-      for (uint8_t x = 0; x < ABL_GRID_POINTS_X + 2; x++) {
2502
+      for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X + 2; x++) {
2495 2503
         bed_level_grid_virt_temp[x][0] = LINEAR_EXTRAPOLATION(
2496 2504
           bed_level_grid_virt_temp[x][1],
2497 2505
           bed_level_grid_virt_temp[x][2]
2498 2506
         );
2499
-        bed_level_grid_virt_temp[x][(ABL_GRID_POINTS_Y + 2) - 1] =
2507
+        bed_level_grid_virt_temp[x][(ABL_GRID_MAX_POINTS_Y + 2) - 1] =
2500 2508
           LINEAR_EXTRAPOLATION(
2501
-            bed_level_grid_virt_temp[x][(ABL_GRID_POINTS_Y + 2) - 2],
2502
-            bed_level_grid_virt_temp[x][(ABL_GRID_POINTS_Y + 2) - 3]
2509
+            bed_level_grid_virt_temp[x][(ABL_GRID_MAX_POINTS_Y + 2) - 2],
2510
+            bed_level_grid_virt_temp[x][(ABL_GRID_MAX_POINTS_Y + 2) - 3]
2503 2511
           );
2504 2512
       }
2505 2513
     }
@@ -2520,12 +2528,12 @@ static void clean_up_after_endstop_or_probe_move() {
2520 2528
       }
2521 2529
       return bed_level_virt_cmr(row, 1, tx);
2522 2530
     }
2523
-    static void bed_level_virt_interpolate() {
2524
-      for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
2525
-        for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++)
2531
+    void bed_level_virt_interpolate() {
2532
+      for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
2533
+        for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
2526 2534
           for (uint8_t ty = 0; ty < BILINEAR_SUBDIVISIONS; ty++)
2527 2535
             for (uint8_t tx = 0; tx < BILINEAR_SUBDIVISIONS; tx++) {
2528
-              if ((ty && y == ABL_GRID_POINTS_Y - 1) || (tx && x == ABL_GRID_POINTS_X - 1))
2536
+              if ((ty && y == ABL_GRID_MAX_POINTS_Y - 1) || (tx && x == ABL_GRID_MAX_POINTS_X - 1))
2529 2537
                 continue;
2530 2538
               bed_level_grid_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
2531 2539
                 bed_level_virt_2cmr(
@@ -3422,9 +3430,9 @@ inline void gcode_G28() {
3422 3430
   // Wait for planner moves to finish!
3423 3431
   stepper.synchronize();
3424 3432
 
3425
-  // For auto bed leveling, clear the level matrix
3426
-  #if HAS_ABL
3427
-    reset_bed_level();
3433
+  // Disable the leveling matrix before homing
3434
+  #if PLANNER_LEVELING
3435
+    set_bed_leveling_enabled(false);
3428 3436
   #endif
3429 3437
 
3430 3438
   // Always home with tool 0 active
@@ -3693,6 +3701,20 @@ inline void gcode_G28() {
3693 3701
   // Save 130 bytes with non-duplication of PSTR
3694 3702
   void say_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
3695 3703
 
3704
+  void mbl_mesh_report() {
3705
+    SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(MESH_NUM_X_POINTS) "," STRINGIFY(MESH_NUM_Y_POINTS));
3706
+    SERIAL_PROTOCOLLNPGM("Z search height: " STRINGIFY(MESH_HOME_SEARCH_Z));
3707
+    SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
3708
+    SERIAL_PROTOCOLLNPGM("\nMeasured points:");
3709
+    for (uint8_t py = 0; py < MESH_NUM_Y_POINTS; py++) {
3710
+      for (uint8_t px = 0; px < MESH_NUM_X_POINTS; px++) {
3711
+        SERIAL_PROTOCOLPGM("  ");
3712
+        SERIAL_PROTOCOL_F(mbl.z_values[py][px], 5);
3713
+      }
3714
+      SERIAL_EOL;
3715
+    }
3716
+  }
3717
+
3696 3718
   /**
3697 3719
    * G29: Mesh-based Z probe, probes a grid and produces a
3698 3720
    *      mesh to compensate for variable bed height
@@ -3728,21 +3750,11 @@ inline void gcode_G28() {
3728 3750
     switch (state) {
3729 3751
       case MeshReport:
3730 3752
         if (mbl.has_mesh()) {
3731
-          SERIAL_PROTOCOLPAIR("State: ", mbl.active() ? MSG_ON : MSG_OFF);
3732
-          SERIAL_PROTOCOLLNPGM("\nNum X,Y: " STRINGIFY(MESH_NUM_X_POINTS) "," STRINGIFY(MESH_NUM_Y_POINTS));
3733
-          SERIAL_PROTOCOLLNPGM("Z search height: " STRINGIFY(MESH_HOME_SEARCH_Z));
3734
-          SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
3735
-          SERIAL_PROTOCOLLNPGM("\nMeasured points:");
3736
-          for (py = 0; py < MESH_NUM_Y_POINTS; py++) {
3737
-            for (px = 0; px < MESH_NUM_X_POINTS; px++) {
3738
-              SERIAL_PROTOCOLPGM("  ");
3739
-              SERIAL_PROTOCOL_F(mbl.z_values[py][px], 5);
3740
-            }
3741
-            SERIAL_EOL;
3742
-          }
3753
+          SERIAL_PROTOCOLLNPAIR("State: ", mbl.active() ? MSG_ON : MSG_OFF);
3754
+          mbl_mesh_report();
3743 3755
         }
3744 3756
         else
3745
-          SERIAL_PROTOCOLLNPGM("Mesh bed leveling not active.");
3757
+          SERIAL_PROTOCOLLNPGM("Mesh bed leveling has no data.");
3746 3758
         break;
3747 3759
 
3748 3760
       case MeshStart:
@@ -3863,7 +3875,7 @@ inline void gcode_G28() {
3863 3875
    *
3864 3876
    * Enhanced G29 Auto Bed Leveling Probe Routine
3865 3877
    *
3866
-   * Parameters With ABL_GRID:
3878
+   * Parameters With LINEAR and BILINEAR:
3867 3879
    *
3868 3880
    *  P  Set the size of the grid that will be probed (P x P points).
3869 3881
    *     Not supported by non-linear delta printer bed leveling.
@@ -3887,6 +3899,10 @@ inline void gcode_G28() {
3887 3899
    *  L  Set the Left limit of the probing grid
3888 3900
    *  R  Set the Right limit of the probing grid
3889 3901
    *
3902
+   * Parameters with BILINEAR only:
3903
+   * 
3904
+   *  Z  Supply an additional Z probe offset
3905
+   *
3890 3906
    * Global Parameters:
3891 3907
    *
3892 3908
    * E/e By default G29 will engage the Z probe, test the bed, then disengage.
@@ -3934,8 +3950,8 @@ inline void gcode_G28() {
3934 3950
 
3935 3951
         // X and Y specify points in each direction, overriding the default
3936 3952
         // These values may be saved with the completed mesh
3937
-        int abl_grid_points_x = code_seen('X') ? code_value_int() : ABL_GRID_POINTS_X,
3938
-            abl_grid_points_y = code_seen('Y') ? code_value_int() : ABL_GRID_POINTS_Y;
3953
+        int abl_grid_points_x = code_seen('X') ? code_value_int() : ABL_GRID_MAX_POINTS_X,
3954
+            abl_grid_points_y = code_seen('Y') ? code_value_int() : ABL_GRID_MAX_POINTS_Y;
3939 3955
 
3940 3956
         if (code_seen('P')) abl_grid_points_x = abl_grid_points_y = code_value_int();
3941 3957
 
@@ -3946,7 +3962,7 @@ inline void gcode_G28() {
3946 3962
 
3947 3963
       #else
3948 3964
 
3949
-         const int abl_grid_points_x = ABL_GRID_POINTS_X, abl_grid_points_y = ABL_GRID_POINTS_Y;
3965
+         const uint8_t abl_grid_points_x = ABL_GRID_MAX_POINTS_X, abl_grid_points_y = ABL_GRID_MAX_POINTS_Y;
3950 3966
 
3951 3967
       #endif
3952 3968
 
@@ -4030,7 +4046,11 @@ inline void gcode_G28() {
4030 4046
           || left_probe_bed_position != bilinear_start[X_AXIS]
4031 4047
           || front_probe_bed_position != bilinear_start[Y_AXIS]
4032 4048
         ) {
4049
+          // Before reset bed level, re-enable to correct the position
4050
+          planner.abl_enabled = abl_should_enable;
4051
+          // Reset grid to 0.0 or "not probed". (Also disables ABL)
4033 4052
           reset_bed_level();
4053
+
4034 4054
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
4035 4055
             bilinear_grid_spacing_virt[X_AXIS] = xGridSpacing / (BILINEAR_SUBDIVISIONS);
4036 4056
             bilinear_grid_spacing_virt[Y_AXIS] = yGridSpacing / (BILINEAR_SUBDIVISIONS);
@@ -4039,6 +4059,7 @@ inline void gcode_G28() {
4039 4059
           bilinear_grid_spacing[Y_AXIS] = yGridSpacing;
4040 4060
           bilinear_start[X_AXIS] = RAW_X_POSITION(left_probe_bed_position);
4041 4061
           bilinear_start[Y_AXIS] = RAW_Y_POSITION(front_probe_bed_position);
4062
+
4042 4063
           // Can't re-enable (on error) until the new grid is written
4043 4064
           abl_should_enable = false;
4044 4065
         }
@@ -4203,7 +4224,7 @@ inline void gcode_G28() {
4203 4224
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4204 4225
 
4205 4226
       if (!dryrun) extrapolate_unprobed_bed_level();
4206
-      print_bed_level();
4227
+      print_bilinear_leveling_grid();
4207 4228
 
4208 4229
       #if ENABLED(ABL_BILINEAR_SUBDIVISION)
4209 4230
         bed_level_virt_prepare();
@@ -4322,45 +4343,34 @@ inline void gcode_G28() {
4322 4343
         // Correct the current XYZ position based on the tilted plane.
4323 4344
         //
4324 4345
 
4325
-        // 1. Get the distance from the current position to the reference point.
4326
-        float x_dist = RAW_CURRENT_POSITION(X_AXIS) - X_TILT_FULCRUM,
4327
-              y_dist = RAW_CURRENT_POSITION(Y_AXIS) - Y_TILT_FULCRUM,
4328
-              z_real = current_position[Z_AXIS],
4329
-              z_zero = 0;
4330
-
4331 4346
         #if ENABLED(DEBUG_LEVELING_FEATURE)
4332 4347
           if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
4333 4348
         #endif
4334 4349
 
4335
-        matrix_3x3 inverse = matrix_3x3::transpose(planner.bed_level_matrix);
4336
-
4337
-        // 2. Apply the inverse matrix to the distance
4338
-        //    from the reference point to X, Y, and zero.
4339
-        apply_rotation_xyz(inverse, x_dist, y_dist, z_zero);
4350
+        float converted[XYZ];
4351
+        memcpy(converted, current_position, sizeof(converted));
4340 4352
 
4341
-        // 3. Get the matrix-based corrected Z.
4342
-        //    (Even if not used, get it for comparison.)
4343
-        float new_z = z_real + z_zero;
4353
+        planner.abl_enabled = true;
4354
+        planner.unapply_leveling(converted); // use conversion machinery
4355
+        planner.abl_enabled = false;
4344 4356
 
4345
-        // 4. Use the last measured distance to the bed, if possible
4357
+        // Use the last measured distance to the bed, if possible
4346 4358
         if ( NEAR(current_position[X_AXIS], xProbe - (X_PROBE_OFFSET_FROM_EXTRUDER))
4347 4359
           && NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
4348 4360
         ) {
4349
-          float simple_z = z_real - (measured_z - (-zprobe_zoffset));
4361
+          float simple_z = current_position[Z_AXIS] - (measured_z - (-zprobe_zoffset));
4350 4362
           #if ENABLED(DEBUG_LEVELING_FEATURE)
4351 4363
             if (DEBUGGING(LEVELING)) {
4352 4364
               SERIAL_ECHOPAIR("Z from Probe:", simple_z);
4353
-              SERIAL_ECHOPAIR("  Matrix:", new_z);
4354
-              SERIAL_ECHOLNPAIR("  Discrepancy:", simple_z - new_z);
4365
+              SERIAL_ECHOPAIR("  Matrix:", converted[Z_AXIS]);
4366
+              SERIAL_ECHOLNPAIR("  Discrepancy:", simple_z - converted[Z_AXIS]);
4355 4367
             }
4356 4368
           #endif
4357
-          new_z = simple_z;
4369
+          converted[Z_AXIS] = simple_z;
4358 4370
         }
4359 4371
 
4360
-        // 5. The rotated XY and corrected Z are now current_position
4361
-        current_position[X_AXIS] = LOGICAL_X_POSITION(x_dist) + X_TILT_FULCRUM;
4362
-        current_position[Y_AXIS] = LOGICAL_Y_POSITION(y_dist) + Y_TILT_FULCRUM;
4363
-        current_position[Z_AXIS] = new_z;
4372
+        // The rotated XY and corrected Z are now current_position
4373
+        memcpy(current_position, converted, sizeof(converted));
4364 4374
 
4365 4375
         #if ENABLED(DEBUG_LEVELING_FEATURE)
4366 4376
           if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
@@ -5041,7 +5051,8 @@ inline void gcode_M42() {
5041 5051
 
5042 5052
     // Disable bed level correction in M48 because we want the raw data when we probe
5043 5053
     #if HAS_ABL
5044
-      reset_bed_level();
5054
+      const bool abl_was_enabled = planner.abl_enabled;
5055
+      set_bed_leveling_enabled(false);
5045 5056
     #endif
5046 5057
 
5047 5058
     setup_for_endstop_or_probe_move();
@@ -5192,6 +5203,11 @@ inline void gcode_M42() {
5192 5203
 
5193 5204
     clean_up_after_endstop_or_probe_move();
5194 5205
 
5206
+    // Re-enable bed level correction if it has been on
5207
+    #if HAS_ABL
5208
+      set_bed_leveling_enabled(abl_was_enabled);
5209
+    #endif
5210
+
5195 5211
     report_current_position();
5196 5212
   }
5197 5213
 
@@ -7000,12 +7016,54 @@ void quickstop_stepper() {
7000 7016
    *
7001 7017
    *       S[bool]   Turns leveling on or off
7002 7018
    *       Z[height] Sets the Z fade height (0 or none to disable)
7019
+   *       V[bool]   Verbose - Print the levelng grid
7003 7020
    */
7004 7021
   inline void gcode_M420() {
7005
-    if (code_seen('S')) set_bed_leveling_enabled(code_value_bool());
7022
+    bool to_enable = false;
7023
+
7024
+    if (code_seen('S')) {
7025
+      to_enable = code_value_bool();
7026
+      set_bed_leveling_enabled(to_enable);
7027
+    }
7028
+
7006 7029
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
7007 7030
       if (code_seen('Z')) set_z_fade_height(code_value_linear_units());
7008 7031
     #endif
7032
+
7033
+    if (to_enable && !(
7034
+      #if ENABLED(MESH_BED_LEVELING)
7035
+        mbl.active()
7036
+      #else
7037
+        planner.abl_enabled
7038
+      #endif
7039
+    ) ) {
7040
+      to_enable = false;
7041
+      SERIAL_ERROR_START;
7042
+      SERIAL_ERRORLNPGM(MSG_ERR_M420_FAILED);
7043
+    }
7044
+
7045
+    SERIAL_ECHO_START;
7046
+    SERIAL_ECHOLNPAIR("Bed Leveling ", to_enable ? MSG_ON : MSG_OFF);
7047
+
7048
+    // V to print the matrix or mesh
7049
+    if (code_seen('V')) {
7050
+      #if ABL_PLANAR
7051
+        planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
7052
+      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7053
+        if (bilinear_grid_spacing[X_AXIS]) {
7054
+          print_bilinear_leveling_grid();
7055
+          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7056
+            bed_level_virt_print();
7057
+          #endif
7058
+        }
7059
+      #elif ENABLED(MESH_BED_LEVELING)
7060
+        if (mbl.has_mesh()) {
7061
+          SERIAL_ECHOLNPGM("Mesh Bed Level data:");
7062
+          mbl_mesh_report();
7063
+        }
7064
+      #endif
7065
+    }
7066
+
7009 7067
   }
7010 7068
 #endif
7011 7069
 
@@ -7048,6 +7106,40 @@ void quickstop_stepper() {
7048 7106
     }
7049 7107
   }
7050 7108
 
7109
+#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7110
+
7111
+  /**
7112
+   * M421: Set a single Mesh Bed Leveling Z coordinate
7113
+   *
7114
+   *   M421 I<xindex> J<yindex> Z<linear>
7115
+   */
7116
+  inline void gcode_M421() {
7117
+    int8_t px = 0, py = 0;
7118
+    float z = 0;
7119
+    bool hasI, hasJ, hasZ;
7120
+    if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS);
7121
+    if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS);
7122
+    if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
7123
+
7124
+    if (hasI && hasJ && hasZ) {
7125
+      if (px >= 0 && px < ABL_GRID_MAX_POINTS_X && py >= 0 && py < ABL_GRID_MAX_POINTS_X) {
7126
+        bed_level_grid[px][py] = z;
7127
+        #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7128
+          bed_level_virt_prepare();
7129
+          bed_level_virt_interpolate();
7130
+        #endif
7131
+      }
7132
+      else {
7133
+        SERIAL_ERROR_START;
7134
+        SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
7135
+      }
7136
+    }
7137
+    else {
7138
+      SERIAL_ERROR_START;
7139
+      SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
7140
+    }
7141
+  }
7142
+
7051 7143
 #endif
7052 7144
 
7053 7145
 /**
@@ -8757,8 +8849,8 @@ void ok_to_send() {
8757 8849
     #define ABL_BG_GRID(X,Y)  bed_level_grid_virt[X][Y]
8758 8850
   #else
8759 8851
     #define ABL_BG_SPACING(A) bilinear_grid_spacing[A]
8760
-    #define ABL_BG_POINTS_X   ABL_GRID_POINTS_X
8761
-    #define ABL_BG_POINTS_Y   ABL_GRID_POINTS_Y
8852
+    #define ABL_BG_POINTS_X   ABL_GRID_MAX_POINTS_X
8853
+    #define ABL_BG_POINTS_Y   ABL_GRID_MAX_POINTS_Y
8762 8854
     #define ABL_BG_GRID(X,Y)  bed_level_grid[X][Y]
8763 8855
   #endif
8764 8856
 

+ 7
- 5
Marlin/SanityCheck.h View File

@@ -142,7 +142,9 @@
142 142
 #elif defined(AUTO_BED_LEVELING_FEATURE)
143 143
   #error "AUTO_BED_LEVELING_FEATURE is deprecated. Specify AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_3POINT."
144 144
 #elif defined(ABL_GRID_POINTS)
145
-  #error "ABL_GRID_POINTS is now ABL_GRID_POINTS_X and ABL_GRID_POINTS_Y. Please update your configuration."
145
+  #error "ABL_GRID_POINTS is now ABL_GRID_MAX_POINTS_X and ABL_GRID_MAX_POINTS_Y. Please update your configuration."
146
+#elif defined(ABL_GRID_POINTS_X) || defined(ABL_GRID_POINTS_Y)
147
+  #error "ABL_GRID_POINTS_[XY] is now ABL_GRID_MAX_POINTS_[XY]. Please update your configuration."
146 148
 #elif defined(BEEPER)
147 149
   #error "BEEPER is now BEEPER_PIN. Please update your pins definitions."
148 150
 #elif defined(SDCARDDETECT)
@@ -212,10 +214,10 @@
212 214
     #error "You probably want to use Max Endstops for DELTA!"
213 215
   #endif
214 216
   #if ABL_GRID
215
-    #if (ABL_GRID_POINTS_X & 1) == 0 || (ABL_GRID_POINTS_Y & 1) == 0
216
-      #error "DELTA requires ABL_GRID_POINTS_X and ABL_GRID_POINTS_Y to be odd numbers."
217
-    #elif ABL_GRID_POINTS_X < 3
218
-      #error "DELTA requires ABL_GRID_POINTS_X and ABL_GRID_POINTS_Y to be 3 or higher."
217
+    #if (ABL_GRID_MAX_POINTS_X & 1) == 0 || (ABL_GRID_MAX_POINTS_Y & 1) == 0
218
+      #error "DELTA requires ABL_GRID_MAX_POINTS_X and ABL_GRID_MAX_POINTS_Y to be odd numbers."
219
+    #elif ABL_GRID_MAX_POINTS_X < 3
220
+      #error "DELTA requires ABL_GRID_MAX_POINTS_X and ABL_GRID_MAX_POINTS_Y to be 3 or higher."
219 221
     #endif
220 222
   #endif
221 223
 #endif

+ 203
- 89
Marlin/configuration_store.cpp View File

@@ -36,18 +36,18 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V28"
39
+#define EEPROM_VERSION "V29"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
43 43
 
44 44
 /**
45
- * V28 EEPROM Layout:
45
+ * V29 EEPROM Layout:
46 46
  *
47
- *  100  Version (char x4)
48
- *  104  EEPROM Checksum (uint16_t)
47
+ *  100  Version                                   (char x4)
48
+ *  104  EEPROM Checksum                           (uint16_t)
49 49
  *
50
- *  106  E_STEPPERS (uint8_t)
50
+ *  106            E_STEPPERS (uint8_t)
51 51
  *  107  M92 XYZE  planner.axis_steps_per_mm (float x4 ... x7)
52 52
  *  123  M203 XYZE planner.max_feedrate_mm_s (float x4 ... x7)
53 53
  *  139  M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4 ... x7)
@@ -65,60 +65,71 @@
65 65
  *  207  M218 XYZ  hotend_offset (float x3 per additional hotend)
66 66
  *
67 67
  * Mesh bed leveling:
68
- *  219  M420 S    status (uint8)
69
- *  220            z_offset (float)
70
- *  224            mesh_num_x (uint8 as set in firmware)
71
- *  225            mesh_num_y (uint8 as set in firmware)
72
- *  226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81)
68
+ *  219  M420 S    from mbl.status (bool)
69
+ *  220            mbl.z_offset (float)
70
+ *  224            MESH_NUM_X_POINTS (uint8 as set in firmware)
71
+ *  225            MESH_NUM_Y_POINTS (uint8 as set in firmware)
72
+ *  226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81) +288
73 73
  *
74 74
  * AUTO BED LEVELING
75 75
  *  262  M851      zprobe_zoffset (float)
76 76
  *
77
- * DELTA:
78
- *  266  M666 XYZ  endstop_adj (float x3)
79
- *  278  M665 R    delta_radius (float)
80
- *  282  M665 L    delta_diagonal_rod (float)
81
- *  286  M665 S    delta_segments_per_second (float)
82
- *  290  M665 A    delta_diagonal_rod_trim_tower_1 (float)
83
- *  294  M665 B    delta_diagonal_rod_trim_tower_2 (float)
84
- *  298  M665 C    delta_diagonal_rod_trim_tower_3 (float)
77
+ * ABL_PLANAR (or placeholder):                    36 bytes
78
+ *  266            planner.bed_level_matrix        (matrix_3x3 = float x9)
85 79
  *
86
- * Z_DUAL_ENDSTOPS:
87
- *  302  M666 Z    z_endstop_adj (float)
80
+ * AUTO_BED_LEVELING_BILINEAR (or placeholder):    47 bytes
81
+ *  302            ABL_GRID_MAX_POINTS_X           (uint8_t)
82
+ *  303            ABL_GRID_MAX_POINTS_Y           (uint8_t)
83
+ *  304            bilinear_grid_spacing           (int x2)   from G29: (B-F)/X, (R-L)/Y
84
+ *  308  G29 L F   bilinear_start                  (int x2)
85
+ *  312            bed_level_grid[][]              (float x9, up to float x256) +988
88 86
  *
89
- * ULTIPANEL:
90
- *  306  M145 S0 H lcd_preheat_hotend_temp (int x2)
91
- *  310  M145 S0 B lcd_preheat_bed_temp (int x2)
92
- *  314  M145 S0 F lcd_preheat_fan_speed (int x2)
87
+ * DELTA (if deltabot):                            36 bytes
88
+ *  348  M666 XYZ  endstop_adj                     (float x3)
89
+ *  360  M665 R    delta_radius                    (float)
90
+ *  364  M665 L    delta_diagonal_rod              (float)
91
+ *  368  M665 S    delta_segments_per_second       (float)
92
+ *  372  M665 A    delta_diagonal_rod_trim_tower_1 (float)
93
+ *  376  M665 B    delta_diagonal_rod_trim_tower_2 (float)
94
+ *  380  M665 C    delta_diagonal_rod_trim_tower_3 (float)
93 95
  *
94
- * PIDTEMP:
95
- *  318  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
96
- *  334  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
97
- *  350  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
98
- *  366  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
99
- *  382  M301 L        lpq_len (int)
96
+ * Z_DUAL_ENDSTOPS:                                4 bytes
97
+ *  384  M666 Z    z_endstop_adj                   (float)
98
+ *
99
+ * ULTIPANEL:                                      6 bytes
100
+ *  388  M145 S0 H lcd_preheat_hotend_temp         (int x2)
101
+ *  392  M145 S0 B lcd_preheat_bed_temp            (int x2)
102
+ *  396  M145 S0 F lcd_preheat_fan_speed           (int x2)
103
+ *
104
+ * PIDTEMP:                                        66 bytes
105
+ *  400  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0]  (float x4)
106
+ *  416  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1]  (float x4)
107
+ *  432  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2]  (float x4)
108
+ *  448  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3]  (float x4)
109
+ *  464  M301 L        lpq_len                     (int)
100 110
  *
101 111
  * PIDTEMPBED:
102
- *  384  M304 PID  thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
112
+ *  466  M304 PID  thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
103 113
  *
104
- * DOGLCD:
105
- *  396  M250 C    lcd_contrast (int)
114
+ * DOGLCD:                                          2 bytes
115
+ *  478  M250 C    lcd_contrast                     (int)
106 116
  *
107
- * FWRETRACT:
108
- *  398  M209 S    autoretract_enabled (bool)
109
- *  399  M207 S    retract_length (float)
110
- *  403  M207 W    retract_length_swap (float)
111
- *  407  M207 F    retract_feedrate_mm_s (float)
112
- *  411  M207 Z    retract_zlift (float)
113
- *  415  M208 S    retract_recover_length (float)
114
- *  419  M208 W    retract_recover_length_swap (float)
115
- *  423  M208 F    retract_recover_feedrate_mm_s (float)
117
+ * FWRETRACT:                                       29 bytes
118
+ *  480  M209 S    autoretract_enabled              (bool)
119
+ *  481  M207 S    retract_length                   (float)
120
+ *  485  M207 W    retract_length_swap              (float)
121
+ *  489  M207 F    retract_feedrate_mm_s            (float)
122
+ *  493  M207 Z    retract_zlift                    (float)
123
+ *  497  M208 S    retract_recover_length           (float)
124
+ *  501  M208 W    retract_recover_length_swap      (float)
125
+ *  505  M208 F    retract_recover_feedrate_mm_s    (float)
116 126
  *
117
- * Volumetric Extrusion:
118
- *  427  M200 D    volumetric_enabled (bool)
119
- *  428  M200 T D  filament_size (float x4) (T0..3)
127
+ * Volumetric Extrusion:                            17 bytes
128
+ *  509  M200 D    volumetric_enabled               (bool)
129
+ *  510  M200 T D  filament_size                    (float x4) (T0..3)
120 130
  *
121
- *  444  This Slot is Available!
131
+ *  526                                Minimum end-point
132
+ * 1847 (526 + 36 + 9 + 288 + 988)     Maximum end-point
122 133
  *
123 134
  */
124 135
 #include "Marlin.h"
@@ -133,6 +144,11 @@
133 144
   #include "mesh_bed_leveling.h"
134 145
 #endif
135 146
 
147
+#if ENABLED(ABL_BILINEAR_SUBDIVISION)
148
+  extern void bed_level_virt_prepare();
149
+  extern void bed_level_virt_interpolate();
150
+#endif
151
+
136 152
 /**
137 153
  * Post-process after Retrieve or Reset
138 154
  */
@@ -188,10 +204,11 @@ void Config_Postprocess() {
188 204
       value++;
189 205
     };
190 206
   }
207
+  bool eeprom_read_error;
191 208
   void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
192 209
     do {
193 210
       uint8_t c = eeprom_read_byte((unsigned char*)pos);
194
-      *value = c;
211
+      if (!eeprom_read_error) *value = c;
195 212
       eeprom_checksum += c;
196 213
       pos++;
197 214
       value++;
@@ -203,6 +220,7 @@ void Config_Postprocess() {
203 220
   #define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)
204 221
   #define EEPROM_WRITE(VAR) _EEPROM_writeData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
205 222
   #define EEPROM_READ(VAR) _EEPROM_readData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
223
+  #define EEPROM_ASSERT(TST,ERR) if () do{ SERIAL_ERROR_START; SERIAL_ERRORLNPGM(ERR); eeprom_read_error |= true; }while(0)
206 224
 
207 225
   /**
208 226
    * M500 - Store Configuration
@@ -241,28 +259,30 @@ void Config_Postprocess() {
241 259
         LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
242 260
     #endif
243 261
 
262
+    //
263
+    // Mesh Bed Leveling
264
+    //
265
+
244 266
     #if ENABLED(MESH_BED_LEVELING)
245 267
       // Compile time test that sizeof(mbl.z_values) is as expected
246 268
       typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1];
247
-      uint8_t mesh_num_x = MESH_NUM_X_POINTS,
248
-              mesh_num_y = MESH_NUM_Y_POINTS,
249
-              dummy_uint8 = mbl.status & _BV(MBL_STATUS_HAS_MESH_BIT);
250
-      EEPROM_WRITE(dummy_uint8);
269
+      const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
270
+      const uint8_t mesh_num_x = MESH_NUM_X_POINTS, mesh_num_y = MESH_NUM_Y_POINTS;
271
+      EEPROM_WRITE(leveling_is_on);
251 272
       EEPROM_WRITE(mbl.z_offset);
252 273
       EEPROM_WRITE(mesh_num_x);
253 274
       EEPROM_WRITE(mesh_num_y);
254 275
       EEPROM_WRITE(mbl.z_values);
255 276
     #else
256 277
       // For disabled MBL write a default mesh
257
-      uint8_t mesh_num_x = 3,
258
-              mesh_num_y = 3,
259
-              dummy_uint8 = 0;
278
+      const bool leveling_is_on = false;
260 279
       dummy = 0.0f;
261
-      EEPROM_WRITE(dummy_uint8);
262
-      EEPROM_WRITE(dummy);
280
+      const uint8_t mesh_num_x = 3, mesh_num_y = 3;
281
+      EEPROM_WRITE(leveling_is_on);
282
+      EEPROM_WRITE(dummy); // z_offset
263 283
       EEPROM_WRITE(mesh_num_x);
264 284
       EEPROM_WRITE(mesh_num_y);
265
-      for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_WRITE(dummy);
285
+      for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
266 286
     #endif // MESH_BED_LEVELING
267 287
 
268 288
     #if !HAS_BED_PROBE
@@ -270,6 +290,42 @@ void Config_Postprocess() {
270 290
     #endif
271 291
     EEPROM_WRITE(zprobe_zoffset);
272 292
 
293
+    //
294
+    // Planar Bed Leveling matrix
295
+    //
296
+
297
+    #if ABL_PLANAR
298
+      EEPROM_WRITE(planner.bed_level_matrix);
299
+    #else
300
+      dummy = 0.0;
301
+      for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
302
+    #endif
303
+
304
+    //
305
+    // Bilinear Auto Bed Leveling
306
+    //
307
+
308
+    #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
309
+      // Compile time test that sizeof(bed_level_grid) is as expected
310
+      typedef char c_assert[(sizeof(bed_level_grid) == (ABL_GRID_MAX_POINTS_X) * (ABL_GRID_MAX_POINTS_Y) * sizeof(dummy)) ? 1 : -1];
311
+      const uint8_t grid_max_x = ABL_GRID_MAX_POINTS_X, grid_max_y = ABL_GRID_MAX_POINTS_Y;
312
+      EEPROM_WRITE(grid_max_x);            // 1 byte
313
+      EEPROM_WRITE(grid_max_y);            // 1 byte
314
+      EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
315
+      EEPROM_WRITE(bilinear_start);        // 2 ints
316
+      EEPROM_WRITE(bed_level_grid);        // 9-256 floats
317
+    #else
318
+      // For disabled Bilinear Grid write an empty 3x3 grid
319
+      const uint8_t grid_max_x = 3, grid_max_y = 3;
320
+      const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
321
+      dummy = 0.0f;
322
+      EEPROM_WRITE(grid_max_x);
323
+      EEPROM_WRITE(grid_max_y);
324
+      EEPROM_WRITE(bilinear_grid_spacing);
325
+      EEPROM_WRITE(bilinear_start);
326
+      for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
327
+    #endif // AUTO_BED_LEVELING_BILINEAR
328
+
273 329
     // 9 floats for DELTA / Z_DUAL_ENDSTOPS
274 330
     #if ENABLED(DELTA)
275 331
       EEPROM_WRITE(endstop_adj);               // 3 floats
@@ -371,17 +427,21 @@ void Config_Postprocess() {
371 427
       EEPROM_WRITE(dummy);
372 428
     }
373 429
 
374
-    uint16_t final_checksum = eeprom_checksum,
375
-             eeprom_size = eeprom_index;
430
+    if (!eeprom_write_error) {
431
+
432
+      uint16_t final_checksum = eeprom_checksum,
433
+               eeprom_size = eeprom_index;
376 434
 
377
-    eeprom_index = EEPROM_OFFSET;
378
-    EEPROM_WRITE(version);
379
-    EEPROM_WRITE(final_checksum);
435
+      // Write the EEPROM header
436
+      eeprom_index = EEPROM_OFFSET;
437
+      EEPROM_WRITE(version);
438
+      EEPROM_WRITE(final_checksum);
380 439
 
381
-    // Report storage size
382
-    SERIAL_ECHO_START;
383
-    SERIAL_ECHOPAIR("Settings Stored (", eeprom_size);
384
-    SERIAL_ECHOLNPGM(" bytes)");
440
+      // Report storage size
441
+      SERIAL_ECHO_START;
442
+      SERIAL_ECHOPAIR("Settings Stored (", eeprom_size);
443
+      SERIAL_ECHOLNPGM(" bytes)");
444
+    }
385 445
   }
386 446
 
387 447
   /**
@@ -390,6 +450,7 @@ void Config_Postprocess() {
390 450
   void Config_RetrieveSettings() {
391 451
 
392 452
     EEPROM_START();
453
+    eeprom_read_error = false; // If set EEPROM_READ won't write into RAM
393 454
 
394 455
     char stored_ver[4];
395 456
     EEPROM_READ(stored_ver);
@@ -418,9 +479,9 @@ void Config_Postprocess() {
418 479
       // Get only the number of E stepper parameters previously stored
419 480
       // Any steppers added later are set to their defaults
420 481
       const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
421
-      const long def3[] = DEFAULT_MAX_ACCELERATION;
482
+      const uint32_t def3[] = DEFAULT_MAX_ACCELERATION;
422 483
       float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers];
423
-      long tmp3[XYZ + esteppers];
484
+      uint32_t tmp3[XYZ + esteppers];
424 485
       EEPROM_READ(tmp1);
425 486
       EEPROM_READ(tmp2);
426 487
       EEPROM_READ(tmp3);
@@ -445,13 +506,19 @@ void Config_Postprocess() {
445 506
           LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
446 507
       #endif
447 508
 
448
-      uint8_t dummy_uint8 = 0, mesh_num_x = 0, mesh_num_y = 0;
449
-      EEPROM_READ(dummy_uint8);
509
+      //
510
+      // Mesh (Manual) Bed Leveling
511
+      //
512
+
513
+      bool leveling_is_on;
514
+      uint8_t mesh_num_x, mesh_num_y;
515
+      EEPROM_READ(leveling_is_on);
450 516
       EEPROM_READ(dummy);
451 517
       EEPROM_READ(mesh_num_x);
452 518
       EEPROM_READ(mesh_num_y);
519
+
453 520
       #if ENABLED(MESH_BED_LEVELING)
454
-        mbl.status = dummy_uint8;
521
+        mbl.status = leveling_is_on ? _BV(MBL_STATUS_HAS_MESH_BIT) : 0;
455 522
         mbl.z_offset = dummy;
456 523
         if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
457 524
           // EEPROM data fits the current mesh
@@ -460,11 +527,11 @@ void Config_Postprocess() {
460 527
         else {
461 528
           // EEPROM data is stale
462 529
           mbl.reset();
463
-          for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ(dummy);
530
+          for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
464 531
         }
465 532
       #else
466 533
         // MBL is disabled - skip the stored data
467
-        for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ(dummy);
534
+        for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
468 535
       #endif // MESH_BED_LEVELING
469 536
 
470 537
       #if !HAS_BED_PROBE
@@ -472,6 +539,45 @@ void Config_Postprocess() {
472 539
       #endif
473 540
       EEPROM_READ(zprobe_zoffset);
474 541
 
542
+      //
543
+      // Planar Bed Leveling matrix
544
+      //
545
+
546
+      #if ABL_PLANAR
547
+        EEPROM_READ(planner.bed_level_matrix);
548
+      #else
549
+        for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
550
+      #endif
551
+
552
+      //
553
+      // Bilinear Auto Bed Leveling
554
+      //
555
+
556
+      uint8_t grid_max_x, grid_max_y;
557
+      EEPROM_READ(grid_max_x);                       // 1 byte
558
+      EEPROM_READ(grid_max_y);                       // 1 byte
559
+      #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
560
+        if (grid_max_x == ABL_GRID_MAX_POINTS_X && grid_max_y == ABL_GRID_MAX_POINTS_Y) {
561
+          set_bed_leveling_enabled(false);
562
+          EEPROM_READ(bilinear_grid_spacing);        // 2 ints
563
+          EEPROM_READ(bilinear_start);               // 2 ints
564
+          EEPROM_READ(bed_level_grid);               // 9 to 256 floats
565
+          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
566
+            bed_level_virt_prepare();
567
+            bed_level_virt_interpolate();
568
+          #endif
569
+          //set_bed_leveling_enabled(leveling_is_on);
570
+        }
571
+        else // EEPROM data is stale
572
+      #endif // AUTO_BED_LEVELING_BILINEAR
573
+        {
574
+          // Skip past disabled (or stale) Bilinear Grid data
575
+          int bgs[2], bs[2];
576
+          EEPROM_READ(bgs);
577
+          EEPROM_READ(bs);
578
+          for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
579
+        }
580
+
475 581
       #if ENABLED(DELTA)
476 582
         EEPROM_READ(endstop_adj);                // 3 floats
477 583
         EEPROM_READ(delta_radius);               // 1 float
@@ -568,11 +674,15 @@ void Config_Postprocess() {
568 674
       }
569 675
 
570 676
       if (eeprom_checksum == stored_checksum) {
571
-        Config_Postprocess();
572
-        SERIAL_ECHO_START;
573
-        SERIAL_ECHO(version);
574
-        SERIAL_ECHOPAIR(" stored settings retrieved (", eeprom_index);
575
-        SERIAL_ECHOLNPGM(" bytes)");
677
+        if (eeprom_read_error)
678
+          Config_ResetDefault();
679
+        else {
680
+          Config_Postprocess();
681
+          SERIAL_ECHO_START;
682
+          SERIAL_ECHO(version);
683
+          SERIAL_ECHOPAIR(" stored settings retrieved (", eeprom_index);
684
+          SERIAL_ECHOLNPGM(" bytes)");
685
+        }
576 686
       }
577 687
       else {
578 688
         SERIAL_ERROR_START;
@@ -600,7 +710,7 @@ void Config_Postprocess() {
600 710
  */
601 711
 void Config_ResetDefault() {
602 712
   const float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] = DEFAULT_MAX_FEEDRATE;
603
-  const long tmp3[] = DEFAULT_MAX_ACCELERATION;
713
+  const uint32_t tmp3[] = DEFAULT_MAX_ACCELERATION;
604 714
   LOOP_XYZE_N(i) {
605 715
     planner.axis_steps_per_mm[i]          = tmp1[i < COUNT(tmp1) ? i : COUNT(tmp1) - 1];
606 716
     planner.max_feedrate_mm_s[i]          = tmp2[i < COUNT(tmp2) ? i : COUNT(tmp2) - 1];
@@ -636,8 +746,9 @@ void Config_ResetDefault() {
636 746
     LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
637 747
   #endif
638 748
 
639
-  #if ENABLED(MESH_BED_LEVELING)
640
-    mbl.reset();
749
+  // Applies to all MBL and ABL
750
+  #if PLANNER_LEVELING
751
+    reset_bed_level();
641 752
   #endif
642 753
 
643 754
   #if HAS_BED_PROBE
@@ -649,9 +760,9 @@ void Config_ResetDefault() {
649 760
     endstop_adj[A_AXIS] = adj[A_AXIS];
650 761
     endstop_adj[B_AXIS] = adj[B_AXIS];
651 762
     endstop_adj[C_AXIS] = adj[C_AXIS];
652
-    delta_radius =  DELTA_RADIUS;
653
-    delta_diagonal_rod =  DELTA_DIAGONAL_ROD;
654
-    delta_segments_per_second =  DELTA_SEGMENTS_PER_SECOND;
763
+    delta_radius = DELTA_RADIUS;
764
+    delta_diagonal_rod = DELTA_DIAGONAL_ROD;
765
+    delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
655 766
     delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1;
656 767
     delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2;
657 768
     delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3;
@@ -852,13 +963,10 @@ void Config_ResetDefault() {
852 963
 
853 964
     #if ENABLED(MESH_BED_LEVELING)
854 965
       if (!forReplay) {
855
-        SERIAL_ECHOLNPGM("Mesh bed leveling:");
966
+        SERIAL_ECHOLNPGM("Mesh Bed Leveling:");
856 967
         CONFIG_ECHO_START;
857 968
       }
858
-      SERIAL_ECHOPAIR("  M420 S", mbl.has_mesh() ? 1 : 0);
859
-      SERIAL_ECHOPAIR(" X", MESH_NUM_X_POINTS);
860
-      SERIAL_ECHOPAIR(" Y", MESH_NUM_Y_POINTS);
861
-      SERIAL_EOL;
969
+      SERIAL_ECHOLNPAIR("  M420 S", mbl.has_mesh() ? 1 : 0);
862 970
       for (uint8_t py = 1; py <= MESH_NUM_Y_POINTS; py++) {
863 971
         for (uint8_t px = 1; px <= MESH_NUM_X_POINTS; px++) {
864 972
           CONFIG_ECHO_START;
@@ -869,6 +977,12 @@ void Config_ResetDefault() {
869 977
           SERIAL_EOL;
870 978
         }
871 979
       }
980
+    #elif HAS_ABL
981
+      if (!forReplay) {
982
+        SERIAL_ECHOLNPGM("Auto Bed Leveling:");
983
+        CONFIG_ECHO_START;
984
+      }
985
+      SERIAL_ECHOLNPAIR("  M420 S", planner.abl_enabled ? 1 : 0);
872 986
     #endif
873 987
 
874 988
     #if ENABLED(DELTA)

+ 2
- 2
Marlin/example_configurations/Cartesio/Configuration.h View File

@@ -805,8 +805,8 @@
805 805
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
806 806
 
807 807
   // Set the number of grid points per dimension.
808
-  #define ABL_GRID_POINTS_X 3
809
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
808
+  #define ABL_GRID_MAX_POINTS_X 3
809
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
810 810
 
811 811
   // Set the boundaries for probing (where the probe can reach).
812 812
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/Felix/Configuration.h View File

@@ -788,8 +788,8 @@
788 788
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
789 789
 
790 790
   // Set the number of grid points per dimension.
791
-  #define ABL_GRID_POINTS_X 3
792
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
791
+  #define ABL_GRID_MAX_POINTS_X 3
792
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
793 793
 
794 794
   // Set the boundaries for probing (where the probe can reach).
795 795
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/Felix/DUAL/Configuration.h View File

@@ -788,8 +788,8 @@
788 788
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
789 789
 
790 790
   // Set the number of grid points per dimension.
791
-  #define ABL_GRID_POINTS_X 3
792
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
791
+  #define ABL_GRID_MAX_POINTS_X 3
792
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
793 793
 
794 794
   // Set the boundaries for probing (where the probe can reach).
795 795
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -797,8 +797,8 @@
797 797
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
798 798
 
799 799
   // Set the number of grid points per dimension.
800
-  #define ABL_GRID_POINTS_X 3
801
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
800
+  #define ABL_GRID_MAX_POINTS_X 3
801
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
802 802
 
803 803
   // Set the boundaries for probing (where the probe can reach).
804 804
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/Hephestos_2/Configuration.h View File

@@ -799,8 +799,8 @@
799 799
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
800 800
 
801 801
   // Set the number of grid points per dimension.
802
-  #define ABL_GRID_POINTS_X 3
803
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
802
+  #define ABL_GRID_MAX_POINTS_X 3
803
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
804 804
 
805 805
   // Set the boundaries for probing (where the probe can reach).
806 806
   #define LEFT_PROBE_BED_POSITION  X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER

+ 2
- 2
Marlin/example_configurations/K8200/Configuration.h View File

@@ -834,8 +834,8 @@
834 834
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
835 835
 
836 836
   // Set the number of grid points per dimension.
837
-  #define ABL_GRID_POINTS_X 3
838
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
837
+  #define ABL_GRID_MAX_POINTS_X 3
838
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
839 839
 
840 840
   // Set the boundaries for probing (where the probe can reach).
841 841
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/K8400/Configuration.h View File

@@ -805,8 +805,8 @@
805 805
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
806 806
 
807 807
   // Set the number of grid points per dimension.
808
-  #define ABL_GRID_POINTS_X 3
809
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
808
+  #define ABL_GRID_MAX_POINTS_X 3
809
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
810 810
 
811 811
   // Set the boundaries for probing (where the probe can reach).
812 812
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/K8400/Dual-head/Configuration.h View File

@@ -805,8 +805,8 @@
805 805
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
806 806
 
807 807
   // Set the number of grid points per dimension.
808
-  #define ABL_GRID_POINTS_X 3
809
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
808
+  #define ABL_GRID_MAX_POINTS_X 3
809
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
810 810
 
811 811
   // Set the boundaries for probing (where the probe can reach).
812 812
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -805,8 +805,8 @@
805 805
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
806 806
 
807 807
   // Set the number of grid points per dimension.
808
-  #define ABL_GRID_POINTS_X 3
809
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
808
+  #define ABL_GRID_MAX_POINTS_X 3
809
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
810 810
 
811 811
   // Set the boundaries for probing (where the probe can reach).
812 812
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -804,8 +804,8 @@
804 804
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
805 805
 
806 806
   // Set the number of grid points per dimension.
807
-  #define ABL_GRID_POINTS_X 3
808
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
807
+  #define ABL_GRID_MAX_POINTS_X 3
808
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
809 809
 
810 810
   // Set the boundaries for probing (where the probe can reach).
811 811
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -820,8 +820,8 @@
820 820
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
821 821
 
822 822
   // Set the number of grid points per dimension.
823
-  #define ABL_GRID_POINTS_X 3
824
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
823
+  #define ABL_GRID_MAX_POINTS_X 3
824
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
825 825
 
826 826
   // Set the boundaries for probing (where the probe can reach).
827 827
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/TAZ4/Configuration.h View File

@@ -826,8 +826,8 @@
826 826
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
827 827
 
828 828
   // Set the number of grid points per dimension.
829
-  #define ABL_GRID_POINTS_X 3
830
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
829
+  #define ABL_GRID_MAX_POINTS_X 3
830
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
831 831
 
832 832
   // Set the boundaries for probing (where the probe can reach).
833 833
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -797,8 +797,8 @@
797 797
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
798 798
 
799 799
   // Set the number of grid points per dimension.
800
-  #define ABL_GRID_POINTS_X 3
801
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
800
+  #define ABL_GRID_MAX_POINTS_X 3
801
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
802 802
 
803 803
   // Set the boundaries for probing (where the probe can reach).
804 804
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -805,8 +805,8 @@
805 805
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
806 806
 
807 807
   // Set the number of grid points per dimension.
808
-  #define ABL_GRID_POINTS_X 3
809
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
808
+  #define ABL_GRID_MAX_POINTS_X 3
809
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
810 810
 
811 811
   // Set the boundaries for probing (where the probe can reach).
812 812
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -898,8 +898,8 @@
898 898
 
899 899
   // Set the number of grid points per dimension.
900 900
   // Works best with 5 or more points in each dimension.
901
-  #define ABL_GRID_POINTS_X 9
902
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
901
+  #define ABL_GRID_MAX_POINTS_X 9
902
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
903 903
 
904 904
   // Set the boundaries for probing (where the probe can reach).
905 905
   #define DELTA_PROBEABLE_RADIUS (DELTA_PRINTABLE_RADIUS - 10)

+ 2
- 2
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -892,8 +892,8 @@
892 892
 
893 893
   // Set the number of grid points per dimension.
894 894
   // Works best with 5 or more points in each dimension.
895
-  #define ABL_GRID_POINTS_X 9
896
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
895
+  #define ABL_GRID_MAX_POINTS_X 9
896
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
897 897
 
898 898
   // Set the boundaries for probing (where the probe can reach).
899 899
   #define DELTA_PROBEABLE_RADIUS (DELTA_PRINTABLE_RADIUS - 10)

+ 2
- 2
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -895,8 +895,8 @@
895 895
 
896 896
   // Set the number of grid points per dimension.
897 897
   // Works best with 5 or more points in each dimension.
898
-  #define ABL_GRID_POINTS_X 9
899
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
898
+  #define ABL_GRID_MAX_POINTS_X 9
899
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
900 900
 
901 901
   // Set the boundaries for probing (where the probe can reach).
902 902
   #define DELTA_PROBEABLE_RADIUS (DELTA_PRINTABLE_RADIUS - 10)

+ 2
- 2
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -894,8 +894,8 @@
894 894
 
895 895
   // Set the number of grid points per dimension.
896 896
   // Works best with 5 or more points in each dimension.
897
-  #define ABL_GRID_POINTS_X 7
898
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
897
+  #define ABL_GRID_MAX_POINTS_X 7
898
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
899 899
 
900 900
   // Set the boundaries for probing (where the probe can reach).
901 901
   #define DELTA_PROBEABLE_RADIUS (DELTA_PRINTABLE_RADIUS-25)

+ 2
- 2
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

@@ -898,8 +898,8 @@
898 898
 
899 899
   // Set the number of grid points per dimension.
900 900
   // Works best with 5 or more points in each dimension.
901
-  #define ABL_GRID_POINTS_X 5
902
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
901
+  #define ABL_GRID_MAX_POINTS_X 5
902
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
903 903
 
904 904
   // Set the boundaries for probing (where the probe can reach).
905 905
   #define DELTA_PROBEABLE_RADIUS (DELTA_PRINTABLE_RADIUS - 10)

+ 2
- 2
Marlin/example_configurations/makibox/Configuration.h View File

@@ -808,8 +808,8 @@
808 808
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
809 809
 
810 810
   // Set the number of grid points per dimension.
811
-  #define ABL_GRID_POINTS_X 3
812
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
811
+  #define ABL_GRID_MAX_POINTS_X 3
812
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
813 813
 
814 814
   // Set the boundaries for probing (where the probe can reach).
815 815
   #define LEFT_PROBE_BED_POSITION 15

+ 2
- 2
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -801,8 +801,8 @@
801 801
 #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
802 802
 
803 803
   // Set the number of grid points per dimension.
804
-  #define ABL_GRID_POINTS_X 3
805
-  #define ABL_GRID_POINTS_Y ABL_GRID_POINTS_X
804
+  #define ABL_GRID_MAX_POINTS_X 3
805
+  #define ABL_GRID_MAX_POINTS_Y ABL_GRID_MAX_POINTS_X
806 806
 
807 807
   // Set the boundaries for probing (where the probe can reach).
808 808
   #define LEFT_PROBE_BED_POSITION 15

+ 3
- 2
Marlin/language.h View File

@@ -153,10 +153,11 @@
153 153
 #define MSG_Z2_MAX                          "z2_max: "
154 154
 #define MSG_Z_PROBE                         "z_probe: "
155 155
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
156
-#define MSG_ERR_M421_PARAMETERS             "M421 requires XYZ or IJZ parameters"
157
-#define MSG_ERR_MESH_XY                     "Mesh XY or IJ cannot be resolved"
156
+#define MSG_ERR_M421_PARAMETERS             "M421 required parameters missing"
157
+#define MSG_ERR_MESH_XY                     "Mesh point cannot be resolved"
158 158
 #define MSG_ERR_ARC_ARGS                    "G2/G3 bad parameters"
159 159
 #define MSG_ERR_PROTECTED_PIN               "Protected Pin"
160
+#define MSG_ERR_M420_FAILED                 "Failed to enable Bed Leveling"
160 161
 #define MSG_ERR_M428_TOO_FAR                "Too far from reference point"
161 162
 #define MSG_ERR_M303_DISABLED               "PIDTEMP disabled"
162 163
 #define MSG_M119_REPORT                     "Reporting endstop status"

+ 2
- 2
Marlin/planner.h View File

@@ -148,8 +148,8 @@ class Planner {
148 148
     static float max_feedrate_mm_s[XYZE_N],     // Max speeds in mm per second
149 149
                  axis_steps_per_mm[XYZE_N],
150 150
                  steps_to_mm[XYZE_N];
151
-    static unsigned long max_acceleration_steps_per_s2[XYZE_N],
152
-                         max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
151
+    static uint32_t max_acceleration_steps_per_s2[XYZE_N],
152
+                    max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
153 153
 
154 154
     static millis_t min_segment_time;
155 155
     static float min_feedrate_mm_s,

Loading…
Cancel
Save