Bläddra i källkod

Modify UBL mesh_is_valid and use in leveling_is_valid (#10746)

Scott Lahteine 7 år sedan
förälder
incheckning
eb2eb72720
Inget konto är kopplat till bidragsgivarens mejladress

+ 1
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp Visa fil

@@ -53,7 +53,7 @@ bool leveling_is_valid() {
53 53
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
54 54
       !!bilinear_grid_spacing[X_AXIS]
55 55
     #elif ENABLED(AUTO_BED_LEVELING_UBL)
56
-      true
56
+      ubl.mesh_is_valid()
57 57
     #else // 3POINT, LINEAR
58 58
       true
59 59
     #endif

+ 5
- 11
Marlin/src/feature/bedlevel/ubl/ubl.h Visa fil

@@ -363,17 +363,11 @@ class unified_bed_leveling {
363 363
       static void line_to_destination_cartesian(const float &fr, const uint8_t e);
364 364
     #endif
365 365
 
366
-    #define _CMPZ(a,b) (z_values[a][b] == z_values[a][b+1])
367
-    #define CMPZ(a) (_CMPZ(a, 0) && _CMPZ(a, 1))
368
-    #define ZZER(a) (z_values[a][0] == 0)
369
-
370
-    FORCE_INLINE bool mesh_is_valid() {
371
-      return !(
372
-        (    CMPZ(0) && CMPZ(1) && CMPZ(2) // adjacent z values all equal?
373
-          && ZZER(0) && ZZER(1) && ZZER(2) // all zero at the edge?
374
-        )
375
-        || isnan(z_values[0][0])
376
-      );
366
+    inline static bool mesh_is_valid() {
367
+      for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
368
+        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
369
+          if (isnan(z_values[x][y])) return false;
370
+      return true;
377 371
     }
378 372
 
379 373
 }; // class unified_bed_leveling

+ 3
- 2
Marlin/src/gcode/bedlevel/M420.cpp Visa fil

@@ -96,8 +96,9 @@ void GcodeSuite::M420() {
96 96
     // L or V display the map info
97 97
     if (parser.seen('L') || parser.seen('V')) {
98 98
       ubl.display_map(parser.byteval('T'));
99
-      SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid());
100
-      SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
99
+      SERIAL_ECHOPGM("Mesh is ");
100
+      if (!ubl.mesh_is_valid()) SERIAL_ECHOPGM("in");
101
+      SERIAL_ECHOLNPAIR("valid\nStorage slot: ", ubl.storage_slot);
101 102
     }
102 103
 
103 104
   #endif // AUTO_BED_LEVELING_UBL

Laddar…
Avbryt
Spara