Browse Source

Use "UNPROBED" for un-probed bed_level_grid points

Scott Lahteine 8 years ago
parent
commit
55722c09da
1 changed files with 9 additions and 8 deletions
  1. 9
    8
      Marlin/Marlin_main.cpp

+ 9
- 8
Marlin/Marlin_main.cpp View File

@@ -575,6 +575,7 @@ static uint8_t target_extruder;
575 575
 #endif
576 576
 
577 577
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
578
+  #define UNPROBED 9999.0f
578 579
   int bilinear_grid_spacing[2], bilinear_start[2];
579 580
   float bed_level_grid[ABL_GRID_MAX_POINTS_X][ABL_GRID_MAX_POINTS_Y];
580 581
 #endif
@@ -2312,7 +2313,7 @@ static void clean_up_after_endstop_or_probe_move() {
2312 2313
         bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
2313 2314
         for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
2314 2315
           for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
2315
-            bed_level_grid[x][y] = 1000.0;
2316
+            bed_level_grid[x][y] = UNPROBED;
2316 2317
       #endif
2317 2318
     #endif
2318 2319
   }
@@ -2338,7 +2339,7 @@ static void clean_up_after_endstop_or_probe_move() {
2338 2339
         SERIAL_CHAR(']');
2339 2340
       }
2340 2341
     #endif
2341
-    if (bed_level_grid[x][y] < 999.0) {
2342
+    if (bed_level_grid[x][y] != UNPROBED) {
2342 2343
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2343 2344
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" (done)");
2344 2345
       #endif
@@ -2352,13 +2353,13 @@ static void clean_up_after_endstop_or_probe_move() {
2352 2353
           c1 = bed_level_grid[x + xdir][y + ydir], c2 = bed_level_grid[x + xdir * 2][y + ydir * 2];
2353 2354
 
2354 2355
     // Treat far unprobed points as zero, near as equal to far
2355
-    if (a2 > 999.0) a2 = 0.0; if (a1 > 999.0) a1 = a2;
2356
-    if (b2 > 999.0) b2 = 0.0; if (b1 > 999.0) b1 = b2;
2357
-    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;
2358 2359
 
2359 2360
     float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
2360 2361
 
2361
-    // Take the average intstead of the median
2362
+    // Take the average instead of the median
2362 2363
     bed_level_grid[x][y] = (a + b + c) / 3.0;
2363 2364
 
2364 2365
     // Median is robust (ignores outliers).
@@ -2436,7 +2437,7 @@ static void clean_up_after_endstop_or_probe_move() {
2436 2437
       for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
2437 2438
         SERIAL_PROTOCOLCHAR(' ');
2438 2439
         float offset = bed_level_grid[x][y];
2439
-        if (offset < 999.0) {
2440
+        if (offset != UNPROBED) {
2440 2441
           if (offset > 0) SERIAL_CHAR('+');
2441 2442
           SERIAL_PROTOCOL_F(offset, 2);
2442 2443
         }
@@ -2469,7 +2470,7 @@ static void clean_up_after_endstop_or_probe_move() {
2469 2470
         for (uint8_t x = 0; x < ABL_GRID_POINTS_VIRT_X; x++) {
2470 2471
           SERIAL_PROTOCOLCHAR(' ');
2471 2472
           float offset = bed_level_grid_virt[x][y];
2472
-          if (offset < 999.0) {
2473
+          if (offset != UNPROBED) {
2473 2474
             if (offset > 0) SERIAL_CHAR('+');
2474 2475
             SERIAL_PROTOCOL_F(offset, 5);
2475 2476
           }

Loading…
Cancel
Save