Bläddra i källkod

Make mbl.has_mesh() a method

Scott Lahteine 7 år sedan
förälder
incheckning
60d07f20e7

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

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

+ 0
- 3
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Visa fil

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

+ 7
- 1
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h Visa fil

39
 
39
 
40
 class mesh_bed_leveling {
40
 class mesh_bed_leveling {
41
 public:
41
 public:
42
-  static bool has_mesh;
43
   static float z_offset,
42
   static float z_offset,
44
                z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
43
                z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
45
                index_to_xpos[GRID_MAX_POINTS_X],
44
                index_to_xpos[GRID_MAX_POINTS_X],
51
 
50
 
52
   static void reset();
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
   static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
60
   static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
55
 
61
 
56
   static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {
62
   static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {

+ 0
- 4
Marlin/src/gcode/bedlevel/mbl/G29.cpp Visa fil

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

+ 2
- 12
Marlin/src/module/configuration_store.cpp Visa fil

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

Laddar…
Avbryt
Spara