Pārlūkot izejas kodu

Move MBL functions into the class

Scott Lahteine 7 gadus atpakaļ
vecāks
revīzija
86818c9a89

+ 1
- 4
Marlin/src/feature/bedlevel/bedlevel.cpp Parādīt failu

@@ -178,10 +178,7 @@ void reset_bed_level() {
178 178
   #endif
179 179
   set_bed_leveling_enabled(false);
180 180
   #if ENABLED(MESH_BED_LEVELING)
181
-    if (leveling_is_valid()) {
182
-      mbl.reset();
183
-      mbl.has_mesh = false;
184
-    }
181
+    mbl.reset();
185 182
   #elif ENABLED(AUTO_BED_LEVELING_UBL)
186 183
     ubl.reset();
187 184
   #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)

+ 14
- 14
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Parādīt failu

@@ -58,12 +58,12 @@
58 58
      * Prepare a mesh-leveled linear move in a Cartesian setup,
59 59
      * splitting the move where it crosses mesh borders.
60 60
      */
61
-    void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
61
+    void mesh_bed_leveling::line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
62 62
       // Get current and destination cells for this line
63
-      int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
64
-          cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
65
-          cx2 = mbl.cell_index_x(destination[X_AXIS]),
66
-          cy2 = mbl.cell_index_y(destination[Y_AXIS]);
63
+      int cx1 = cell_index_x(current_position[X_AXIS]),
64
+          cy1 = cell_index_y(current_position[Y_AXIS]),
65
+          cx2 = cell_index_x(destination[X_AXIS]),
66
+          cy2 = cell_index_y(destination[Y_AXIS]);
67 67
       NOMORE(cx1, GRID_MAX_POINTS_X - 2);
68 68
       NOMORE(cy1, GRID_MAX_POINTS_Y - 2);
69 69
       NOMORE(cx2, GRID_MAX_POINTS_X - 2);
@@ -71,7 +71,7 @@
71 71
 
72 72
       // Start and end in the same cell? No split needed.
73 73
       if (cx1 == cx2 && cy1 == cy2) {
74
-        buffer_line_to_destination(fr_mm_s);
74
+        line_to_destination(fr_mm_s);
75 75
         set_current_from_destination();
76 76
         return;
77 77
       }
@@ -87,7 +87,7 @@
87 87
         // Split on the X grid line
88 88
         CBI(x_splits, gcx);
89 89
         COPY(end, destination);
90
-        destination[X_AXIS] = mbl.index_to_xpos[gcx];
90
+        destination[X_AXIS] = index_to_xpos[gcx];
91 91
         normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
92 92
         destination[Y_AXIS] = MBL_SEGMENT_END(Y);
93 93
       }
@@ -96,14 +96,14 @@
96 96
         // Split on the Y grid line
97 97
         CBI(y_splits, gcy);
98 98
         COPY(end, destination);
99
-        destination[Y_AXIS] = mbl.index_to_ypos[gcy];
99
+        destination[Y_AXIS] = index_to_ypos[gcy];
100 100
         normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
101 101
         destination[X_AXIS] = MBL_SEGMENT_END(X);
102 102
       }
103 103
       else {
104 104
         // Must already have been split on these border(s)
105 105
         // This should be a rare case.
106
-        buffer_line_to_destination(fr_mm_s);
106
+        line_to_destination(fr_mm_s);
107 107
         set_current_from_destination();
108 108
         return;
109 109
       }
@@ -112,21 +112,21 @@
112 112
       destination[E_AXIS] = MBL_SEGMENT_END(E);
113 113
 
114 114
       // Do the split and look for more borders
115
-      mesh_line_to_destination(fr_mm_s, x_splits, y_splits);
115
+      line_to_destination(fr_mm_s, x_splits, y_splits);
116 116
 
117 117
       // Restore destination from stack
118 118
       COPY(destination, end);
119
-      mesh_line_to_destination(fr_mm_s, x_splits, y_splits);
119
+      line_to_destination(fr_mm_s, x_splits, y_splits);
120 120
     }
121 121
 
122 122
   #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES
123 123
 
124
-  void mbl_mesh_report() {
124
+  void mesh_bed_leveling::report_mesh() {
125 125
     SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
126
-    SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
126
+    SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(z_offset, 5);
127 127
     SERIAL_PROTOCOLLNPGM("\nMeasured points:");
128 128
     print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
129
-      [](const uint8_t ix, const uint8_t iy) { return mbl.z_values[ix][iy]; }
129
+      [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
130 130
     );
131 131
   }
132 132
 

+ 7
- 7
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h Parādīt failu

@@ -47,6 +47,8 @@ public:
47 47
 
48 48
   mesh_bed_leveling();
49 49
 
50
+  static void report_mesh();
51
+
50 52
   static void reset();
51 53
 
52 54
   static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
@@ -105,15 +107,13 @@ public:
105 107
       #endif
106 108
     ;
107 109
   }
110
+
111
+  // Support functions, which may be embedded in the class later
112
+  #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
113
+    void line_to_destination(const float fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF);
114
+  #endif
108 115
 };
109 116
 
110 117
 extern mesh_bed_leveling mbl;
111 118
 
112
-// Support functions, which may be embedded in the class later
113
-#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
114
-  void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF);
115
-#endif
116
-
117
-void mbl_mesh_report();
118
-
119 119
 #endif // _MESH_BED_LEVELING_H_

+ 1
- 1
Marlin/src/gcode/bedlevel/M420.cpp Parādīt failu

@@ -100,7 +100,7 @@ void GcodeSuite::M420() {
100 100
           #endif
101 101
         #elif ENABLED(MESH_BED_LEVELING)
102 102
           SERIAL_ECHOLNPGM("Mesh Bed Level data:");
103
-          mbl_mesh_report();
103
+          mbl.report_mesh();
104 104
         #endif
105 105
       }
106 106
     #endif

+ 1
- 1
Marlin/src/gcode/bedlevel/mbl/G29.cpp Parādīt failu

@@ -81,7 +81,7 @@ void GcodeSuite::G29() {
81 81
     case MeshReport:
82 82
       if (leveling_is_valid()) {
83 83
         SERIAL_PROTOCOLLNPAIR("State: ", planner.leveling_active ? MSG_ON : MSG_OFF);
84
-        mbl_mesh_report();
84
+        mbl.report_mesh();
85 85
       }
86 86
       else
87 87
         SERIAL_PROTOCOLLNPGM("Mesh bed leveling has no data.");

Notiek ielāde…
Atcelt
Saglabāt