Quellcode durchsuchen

bed_level_grid => z_values (also *_virt array)

Scott Lahteine vor 8 Jahren
Ursprung
Commit
091179d960
3 geänderte Dateien mit 30 neuen und 30 gelöschten Zeilen
  1. 1
    1
      Marlin/Marlin.h
  2. 24
    24
      Marlin/Marlin_main.cpp
  3. 5
    5
      Marlin/configuration_store.cpp

+ 1
- 1
Marlin/Marlin.h Datei anzeigen

313
 
313
 
314
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
314
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
315
   extern int bilinear_grid_spacing[2], bilinear_start[2];
315
   extern int bilinear_grid_spacing[2], bilinear_start[2];
316
-  extern float bed_level_grid[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
316
+  extern float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
317
   float bilinear_z_offset(float logical[XYZ]);
317
   float bilinear_z_offset(float logical[XYZ]);
318
   void set_bed_leveling_enabled(bool enable=true);
318
   void set_bed_leveling_enabled(bool enable=true);
319
 #endif
319
 #endif

+ 24
- 24
Marlin/Marlin_main.cpp Datei anzeigen

599
 
599
 
600
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
600
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
601
   int bilinear_grid_spacing[2], bilinear_start[2];
601
   int bilinear_grid_spacing[2], bilinear_start[2];
602
-  float bed_level_grid[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
602
+  float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
603
 #endif
603
 #endif
604
 
604
 
605
 #if IS_SCARA
605
 #if IS_SCARA
2435
         bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
2435
         bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
2436
         for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
2436
         for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
2437
           for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
2437
           for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
2438
-            bed_level_grid[x][y] = NAN;
2438
+            z_values[x][y] = NAN;
2439
       #elif ENABLED(AUTO_BED_LEVELING_UBL)
2439
       #elif ENABLED(AUTO_BED_LEVELING_UBL)
2440
         ubl.reset();
2440
         ubl.reset();
2441
       #endif
2441
       #endif
2533
         SERIAL_CHAR(']');
2533
         SERIAL_CHAR(']');
2534
       }
2534
       }
2535
     #endif
2535
     #endif
2536
-    if (!isnan(bed_level_grid[x][y])) {
2536
+    if (!isnan(z_values[x][y])) {
2537
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2537
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2538
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" (done)");
2538
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" (done)");
2539
       #endif
2539
       #endif
2542
     SERIAL_EOL;
2542
     SERIAL_EOL;
2543
 
2543
 
2544
     // Get X neighbors, Y neighbors, and XY neighbors
2544
     // Get X neighbors, Y neighbors, and XY neighbors
2545
-    float a1 = bed_level_grid[x + xdir][y], a2 = bed_level_grid[x + xdir * 2][y],
2546
-          b1 = bed_level_grid[x][y + ydir], b2 = bed_level_grid[x][y + ydir * 2],
2547
-          c1 = bed_level_grid[x + xdir][y + ydir], c2 = bed_level_grid[x + xdir * 2][y + ydir * 2];
2545
+    float a1 = z_values[x + xdir][y], a2 = z_values[x + xdir * 2][y],
2546
+          b1 = z_values[x][y + ydir], b2 = z_values[x][y + ydir * 2],
2547
+          c1 = z_values[x + xdir][y + ydir], c2 = z_values[x + xdir * 2][y + ydir * 2];
2548
 
2548
 
2549
     // Treat far unprobed points as zero, near as equal to far
2549
     // Treat far unprobed points as zero, near as equal to far
2550
     if (isnan(a2)) a2 = 0.0; if (isnan(a1)) a1 = a2;
2550
     if (isnan(a2)) a2 = 0.0; if (isnan(a1)) a1 = a2;
2554
     const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
2554
     const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
2555
 
2555
 
2556
     // Take the average instead of the median
2556
     // Take the average instead of the median
2557
-    bed_level_grid[x][y] = (a + b + c) / 3.0;
2557
+    z_values[x][y] = (a + b + c) / 3.0;
2558
 
2558
 
2559
     // Median is robust (ignores outliers).
2559
     // Median is robust (ignores outliers).
2560
-    // bed_level_grid[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c)
2560
+    // z_values[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c)
2561
     //                                : ((c < b) ? b : (a < c) ? a : c);
2561
     //                                : ((c < b) ? b : (a < c) ? a : c);
2562
   }
2562
   }
2563
 
2563
 
2617
   static void print_bilinear_leveling_grid() {
2617
   static void print_bilinear_leveling_grid() {
2618
     SERIAL_ECHOLNPGM("Bilinear Leveling Grid:");
2618
     SERIAL_ECHOLNPGM("Bilinear Leveling Grid:");
2619
     print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3,
2619
     print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3,
2620
-      [](const uint8_t ix, const uint8_t iy) { return bed_level_grid[ix][iy]; }
2620
+      [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
2621
     );
2621
     );
2622
   }
2622
   }
2623
 
2623
 
2627
     #define ABL_GRID_POINTS_VIRT_Y (GRID_MAX_POINTS_Y - 1) * (BILINEAR_SUBDIVISIONS) + 1
2627
     #define ABL_GRID_POINTS_VIRT_Y (GRID_MAX_POINTS_Y - 1) * (BILINEAR_SUBDIVISIONS) + 1
2628
     #define ABL_TEMP_POINTS_X (GRID_MAX_POINTS_X + 2)
2628
     #define ABL_TEMP_POINTS_X (GRID_MAX_POINTS_X + 2)
2629
     #define ABL_TEMP_POINTS_Y (GRID_MAX_POINTS_Y + 2)
2629
     #define ABL_TEMP_POINTS_Y (GRID_MAX_POINTS_Y + 2)
2630
-    float bed_level_grid_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y];
2630
+    float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y];
2631
     int bilinear_grid_spacing_virt[2] = { 0 };
2631
     int bilinear_grid_spacing_virt[2] = { 0 };
2632
 
2632
 
2633
     static void bed_level_virt_print() {
2633
     static void bed_level_virt_print() {
2634
       SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:");
2634
       SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:");
2635
       print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5,
2635
       print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5,
2636
-        [](const uint8_t ix, const uint8_t iy) { return bed_level_grid_virt[ix][iy]; }
2636
+        [](const uint8_t ix, const uint8_t iy) { return z_values_virt[ix][iy]; }
2637
       );
2637
       );
2638
     }
2638
     }
2639
 
2639
 
2647
         }
2647
         }
2648
         if (WITHIN(y, 1, ABL_TEMP_POINTS_Y - 2))
2648
         if (WITHIN(y, 1, ABL_TEMP_POINTS_Y - 2))
2649
           return LINEAR_EXTRAPOLATION(
2649
           return LINEAR_EXTRAPOLATION(
2650
-            bed_level_grid[ep][y - 1],
2651
-            bed_level_grid[ip][y - 1]
2650
+            z_values[ep][y - 1],
2651
+            z_values[ip][y - 1]
2652
           );
2652
           );
2653
         else
2653
         else
2654
           return LINEAR_EXTRAPOLATION(
2654
           return LINEAR_EXTRAPOLATION(
2663
         }
2663
         }
2664
         if (WITHIN(x, 1, ABL_TEMP_POINTS_X - 2))
2664
         if (WITHIN(x, 1, ABL_TEMP_POINTS_X - 2))
2665
           return LINEAR_EXTRAPOLATION(
2665
           return LINEAR_EXTRAPOLATION(
2666
-            bed_level_grid[x - 1][ep],
2667
-            bed_level_grid[x - 1][ip]
2666
+            z_values[x - 1][ep],
2667
+            z_values[x - 1][ip]
2668
           );
2668
           );
2669
         else
2669
         else
2670
           return LINEAR_EXTRAPOLATION(
2670
           return LINEAR_EXTRAPOLATION(
2672
             bed_level_virt_coord(x, ip + 1)
2672
             bed_level_virt_coord(x, ip + 1)
2673
           );
2673
           );
2674
       }
2674
       }
2675
-      return bed_level_grid[x - 1][y - 1];
2675
+      return z_values[x - 1][y - 1];
2676
     }
2676
     }
2677
 
2677
 
2678
     static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) {
2678
     static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) {
2704
             for (uint8_t tx = 0; tx < BILINEAR_SUBDIVISIONS; tx++) {
2704
             for (uint8_t tx = 0; tx < BILINEAR_SUBDIVISIONS; tx++) {
2705
               if ((ty && y == GRID_MAX_POINTS_Y - 1) || (tx && x == GRID_MAX_POINTS_X - 1))
2705
               if ((ty && y == GRID_MAX_POINTS_Y - 1) || (tx && x == GRID_MAX_POINTS_X - 1))
2706
                 continue;
2706
                 continue;
2707
-              bed_level_grid_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
2707
+              z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
2708
                 bed_level_virt_2cmr(
2708
                 bed_level_virt_2cmr(
2709
                   x + 1,
2709
                   x + 1,
2710
                   y + 1,
2710
                   y + 1,
4281
           }
4281
           }
4282
           if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
4282
           if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
4283
             set_bed_leveling_enabled(false);
4283
             set_bed_leveling_enabled(false);
4284
-            bed_level_grid[i][j] = z;
4284
+            z_values[i][j] = z;
4285
             #if ENABLED(ABL_BILINEAR_SUBDIVISION)
4285
             #if ENABLED(ABL_BILINEAR_SUBDIVISION)
4286
               bed_level_virt_interpolate();
4286
               bed_level_virt_interpolate();
4287
             #endif
4287
             #endif
4499
 
4499
 
4500
         #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4500
         #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4501
 
4501
 
4502
-          bed_level_grid[xCount][yCount] = measured_z + zoffset;
4502
+          z_values[xCount][yCount] = measured_z + zoffset;
4503
 
4503
 
4504
         #elif ENABLED(AUTO_BED_LEVELING_3POINT)
4504
         #elif ENABLED(AUTO_BED_LEVELING_3POINT)
4505
 
4505
 
4669
 
4669
 
4670
             #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4670
             #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4671
 
4671
 
4672
-              bed_level_grid[xCount][yCount] = measured_z + zoffset;
4672
+              z_values[xCount][yCount] = measured_z + zoffset;
4673
 
4673
 
4674
             #endif
4674
             #endif
4675
 
4675
 
8390
         #if ENABLED(AUTO_BED_LEVELING_UBL)
8390
         #if ENABLED(AUTO_BED_LEVELING_UBL)
8391
           ubl.z_values[px][py] = z;
8391
           ubl.z_values[px][py] = z;
8392
         #else
8392
         #else
8393
-          bed_level_grid[px][py] = z;
8393
+          z_values[px][py] = z;
8394
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8394
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8395
             bed_level_virt_interpolate();
8395
             bed_level_virt_interpolate();
8396
           #endif
8396
           #endif
8508
         if (diff) {
8508
         if (diff) {
8509
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
8509
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
8510
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
8510
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
8511
-              bed_level_grid[x][y] -= diff;
8511
+              z_values[x][y] -= diff;
8512
         }
8512
         }
8513
         #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8513
         #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8514
           bed_level_virt_interpolate();
8514
           bed_level_virt_interpolate();
10486
     #define ABL_BG_SPACING(A) bilinear_grid_spacing_virt[A]
10486
     #define ABL_BG_SPACING(A) bilinear_grid_spacing_virt[A]
10487
     #define ABL_BG_POINTS_X   ABL_GRID_POINTS_VIRT_X
10487
     #define ABL_BG_POINTS_X   ABL_GRID_POINTS_VIRT_X
10488
     #define ABL_BG_POINTS_Y   ABL_GRID_POINTS_VIRT_Y
10488
     #define ABL_BG_POINTS_Y   ABL_GRID_POINTS_VIRT_Y
10489
-    #define ABL_BG_GRID(X,Y)  bed_level_grid_virt[X][Y]
10489
+    #define ABL_BG_GRID(X,Y)  z_values_virt[X][Y]
10490
   #else
10490
   #else
10491
     #define ABL_BG_SPACING(A) bilinear_grid_spacing[A]
10491
     #define ABL_BG_SPACING(A) bilinear_grid_spacing[A]
10492
     #define ABL_BG_POINTS_X   GRID_MAX_POINTS_X
10492
     #define ABL_BG_POINTS_X   GRID_MAX_POINTS_X
10493
     #define ABL_BG_POINTS_Y   GRID_MAX_POINTS_Y
10493
     #define ABL_BG_POINTS_Y   GRID_MAX_POINTS_Y
10494
-    #define ABL_BG_GRID(X,Y)  bed_level_grid[X][Y]
10494
+    #define ABL_BG_GRID(X,Y)  z_values[X][Y]
10495
   #endif
10495
   #endif
10496
 
10496
 
10497
   // Get the Z adjustment for non-linear bed leveling
10497
   // Get the Z adjustment for non-linear bed leveling

+ 5
- 5
Marlin/configuration_store.cpp Datei anzeigen

85
  *  307            GRID_MAX_POINTS_Y                (uint8_t)
85
  *  307            GRID_MAX_POINTS_Y                (uint8_t)
86
  *  308            bilinear_grid_spacing            (int x2)
86
  *  308            bilinear_grid_spacing            (int x2)
87
  *  312  G29 L F   bilinear_start                   (int x2)
87
  *  312  G29 L F   bilinear_start                   (int x2)
88
- *  316            bed_level_grid[][]               (float x9, up to float x256) +988
88
+ *  316            z_values[][]                     (float x9, up to float x256) +988
89
  *
89
  *
90
  * DELTA:                                           48 bytes
90
  * DELTA:                                           48 bytes
91
  *  348  M666 XYZ  endstop_adj                      (float x3)
91
  *  348  M666 XYZ  endstop_adj                      (float x3)
382
     //
382
     //
383
 
383
 
384
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
384
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
385
-      // Compile time test that sizeof(bed_level_grid) is as expected
385
+      // Compile time test that sizeof(z_values) is as expected
386
       static_assert(
386
       static_assert(
387
-        sizeof(bed_level_grid) == (GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y) * sizeof(bed_level_grid[0][0]),
387
+        sizeof(z_values) == (GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y) * sizeof(z_values[0][0]),
388
         "Bilinear Z array is the wrong size."
388
         "Bilinear Z array is the wrong size."
389
       );
389
       );
390
       const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
390
       const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
392
       EEPROM_WRITE(grid_max_y);            // 1 byte
392
       EEPROM_WRITE(grid_max_y);            // 1 byte
393
       EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
393
       EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
394
       EEPROM_WRITE(bilinear_start);        // 2 ints
394
       EEPROM_WRITE(bilinear_start);        // 2 ints
395
-      EEPROM_WRITE(bed_level_grid);        // 9-256 floats
395
+      EEPROM_WRITE(z_values);              // 9-256 floats
396
     #else
396
     #else
397
       // For disabled Bilinear Grid write an empty 3x3 grid
397
       // For disabled Bilinear Grid write an empty 3x3 grid
398
       const uint8_t grid_max_x = 3, grid_max_y = 3;
398
       const uint8_t grid_max_x = 3, grid_max_y = 3;
757
           set_bed_leveling_enabled(false);
757
           set_bed_leveling_enabled(false);
758
           EEPROM_READ(bilinear_grid_spacing);        // 2 ints
758
           EEPROM_READ(bilinear_grid_spacing);        // 2 ints
759
           EEPROM_READ(bilinear_start);               // 2 ints
759
           EEPROM_READ(bilinear_start);               // 2 ints
760
-          EEPROM_READ(bed_level_grid);               // 9 to 256 floats
760
+          EEPROM_READ(z_values);                     // 9 to 256 floats
761
         }
761
         }
762
         else // EEPROM data is stale
762
         else // EEPROM data is stale
763
       #endif // AUTO_BED_LEVELING_BILINEAR
763
       #endif // AUTO_BED_LEVELING_BILINEAR

Laden…
Abbrechen
Speichern