Kaynağa Gözat

Make mbl.has_mesh() a method

Scott Lahteine 7 yıl önce
ebeveyn
işleme
60d07f20e7

+ 1
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp Dosyayı Görüntüle

@@ -49,7 +49,7 @@
49 49
 bool leveling_is_valid() {
50 50
   return
51 51
     #if ENABLED(MESH_BED_LEVELING)
52
-      mbl.has_mesh
52
+      mbl.has_mesh()
53 53
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
54 54
       !!bilinear_grid_spacing[X_AXIS]
55 55
     #elif ENABLED(AUTO_BED_LEVELING_UBL)

+ 0
- 3
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Dosyayı Görüntüle

@@ -31,8 +31,6 @@
31 31
 
32 32
   mesh_bed_leveling mbl;
33 33
 
34
-  bool mesh_bed_leveling::has_mesh;
35
-
36 34
   float mesh_bed_leveling::z_offset,
37 35
         mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
38 36
         mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
@@ -47,7 +45,6 @@
47 45
   }
48 46
 
49 47
   void mesh_bed_leveling::reset() {
50
-    has_mesh = false;
51 48
     z_offset = 0;
52 49
     ZERO(z_values);
53 50
   }

+ 7
- 1
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h Dosyayı Görüntüle

@@ -39,7 +39,6 @@ enum MeshLevelingState {
39 39
 
40 40
 class mesh_bed_leveling {
41 41
 public:
42
-  static bool has_mesh;
43 42
   static float z_offset,
44 43
                z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
45 44
                index_to_xpos[GRID_MAX_POINTS_X],
@@ -51,6 +50,13 @@ public:
51 50
 
52 51
   static void reset();
53 52
 
53
+  FORCE_INLINE static bool has_mesh() {
54
+    for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
55
+      for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
56
+        if (z_values[x][y]) return true;
57
+    return false;
58
+  }
59
+
54 60
   static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
55 61
 
56 62
   static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {

+ 0
- 4
Marlin/src/gcode/bedlevel/mbl/G29.cpp Dosyayı Görüntüle

@@ -136,7 +136,6 @@ void GcodeSuite::G29() {
136 136
         SERIAL_PROTOCOLLNPGM("Mesh probing done.");
137 137
         BUZZ(100, 659);
138 138
         BUZZ(100, 698);
139
-        mbl.has_mesh = true;
140 139
 
141 140
         gcode.home_all_axes();
142 141
         set_bed_leveling_enabled(true);
@@ -185,9 +184,6 @@ void GcodeSuite::G29() {
185 184
         SERIAL_CHAR('Z'); echo_not_entered();
186 185
         return;
187 186
       }
188
-
189
-      mbl.has_mesh = true; // set since user manually entered a mesh point
190
-
191 187
       break;
192 188
 
193 189
     case MeshSetZOffset:

+ 2
- 12
Marlin/src/module/configuration_store.cpp Dosyayı Görüntüle

@@ -37,7 +37,7 @@
37 37
  */
38 38
 
39 39
 // Change EEPROM version if the structure changes
40
-#define EEPROM_VERSION "V48"
40
+#define EEPROM_VERSION "V49"
41 41
 #define EEPROM_OFFSET 100
42 42
 
43 43
 // Check the integrity of data offsets.
@@ -114,7 +114,6 @@ typedef struct SettingsDataStruct {
114 114
   //
115 115
   // MESH_BED_LEVELING
116 116
   //
117
-  bool mbl_has_mesh;                                    // mbl.has_mesh
118 117
   float mbl_z_offset;                                   // mbl.z_offset
119 118
   uint8_t mesh_num_x, mesh_num_y;                       // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
120 119
   #if ENABLED(MESH_BED_LEVELING)
@@ -297,7 +296,6 @@ void MarlinSettings::postprocess() {
297 296
 
298 297
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
299 298
     refresh_bed_level();
300
-    //set_bed_leveling_enabled(leveling_is_on);
301 299
   #endif
302 300
 
303 301
   #if HAS_MOTOR_CURRENT_PWM
@@ -425,16 +423,13 @@ void MarlinSettings::postprocess() {
425 423
         "MBL Z array is the wrong size."
426 424
       );
427 425
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
428
-      EEPROM_WRITE(mbl.has_mesh);
429 426
       EEPROM_WRITE(mbl.z_offset);
430 427
       EEPROM_WRITE(mesh_num_x);
431 428
       EEPROM_WRITE(mesh_num_y);
432 429
       EEPROM_WRITE(mbl.z_values);
433 430
     #else // For disabled MBL write a default mesh
434
-      const bool leveling_is_on = false;
435 431
       dummy = 0.0f;
436 432
       const uint8_t mesh_num_x = 3, mesh_num_y = 3;
437
-      EEPROM_WRITE(leveling_is_on);
438 433
       EEPROM_WRITE(dummy); // z_offset
439 434
       EEPROM_WRITE(mesh_num_x);
440 435
       EEPROM_WRITE(mesh_num_y);
@@ -925,18 +920,13 @@ void MarlinSettings::postprocess() {
925 920
       // Mesh (Manual) Bed Leveling
926 921
       //
927 922
 
928
-      bool leveling_is_on;
929 923
       uint8_t mesh_num_x, mesh_num_y;
930
-      EEPROM_READ_ALWAYS(leveling_is_on);
931 924
       EEPROM_READ(dummy);
932 925
       EEPROM_READ_ALWAYS(mesh_num_x);
933 926
       EEPROM_READ_ALWAYS(mesh_num_y);
934 927
 
935 928
       #if ENABLED(MESH_BED_LEVELING)
936
-        if (!validating) {
937
-          mbl.has_mesh = leveling_is_on;
938
-          mbl.z_offset = dummy;
939
-        }
929
+        if (!validating) mbl.z_offset = dummy;
940 930
         if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
941 931
           // EEPROM data fits the current mesh
942 932
           EEPROM_READ(mbl.z_values);

Loading…
İptal
Kaydet