Scott Lahteine преди 5 години
родител
ревизия
2b9d2dce16
променени са 2 файла, в които са добавени 19 реда и са изтрити 24 реда
  1. 7
    8
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  2. 12
    16
      Marlin/src/gcode/bedlevel/M420.cpp

+ 7
- 8
Marlin/src/feature/bedlevel/ubl/ubl.cpp Целия файл

@@ -49,14 +49,13 @@
49 49
   void unified_bed_leveling::report_current_mesh() {
50 50
     if (!leveling_is_valid()) return;
51 51
     SERIAL_ECHO_MSG("  G29 I99");
52
-    LOOP_L_N(x, GRID_MAX_POINTS_X)
53
-      for (uint8_t y = 0;  y < GRID_MAX_POINTS_Y; y++)
54
-        if (!isnan(z_values[x][y])) {
55
-          SERIAL_ECHO_START();
56
-          SERIAL_ECHOPAIR("  M421 I", int(x), " J", int(y));
57
-          SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
58
-          serial_delay(75); // Prevent Printrun from exploding
59
-        }
52
+    GRID_LOOP(x, y)
53
+      if (!isnan(z_values[x][y])) {
54
+        SERIAL_ECHO_START();
55
+        SERIAL_ECHOPAIR("  M421 I", int(x), " J", int(y));
56
+        SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
57
+        serial_delay(75); // Prevent Printrun from exploding
58
+      }
60 59
   }
61 60
 
62 61
   void unified_bed_leveling::report_state() {

+ 12
- 16
Marlin/src/gcode/bedlevel/M420.cpp Целия файл

@@ -155,21 +155,18 @@ void GcodeSuite::M420() {
155 155
 
156 156
             // Get the sum and average of all mesh values
157 157
             float mesh_sum = 0;
158
-            for (uint8_t x = GRID_MAX_POINTS_X; x--;)
159
-              for (uint8_t y = GRID_MAX_POINTS_Y; y--;)
160
-                mesh_sum += Z_VALUES(x, y);
158
+            GRID_LOOP(x, y) mesh_sum += Z_VALUES(x, y);
161 159
             const float zmean = mesh_sum / float(GRID_MAX_POINTS);
162 160
 
163 161
           #else
164 162
 
165 163
             // Find the low and high mesh values
166 164
             float lo_val = 100, hi_val = -100;
167
-            for (uint8_t x = GRID_MAX_POINTS_X; x--;)
168
-              for (uint8_t y = GRID_MAX_POINTS_Y; y--;) {
169
-                const float z = Z_VALUES(x, y);
170
-                NOMORE(lo_val, z);
171
-                NOLESS(hi_val, z);
172
-              }
165
+            GRID_LOOP(x, y) {
166
+              const float z = Z_VALUES(x, y);
167
+              NOMORE(lo_val, z);
168
+              NOLESS(hi_val, z);
169
+            }
173 170
             // Take the mean of the lowest and highest
174 171
             const float zmean = (lo_val + hi_val) / 2.0 + cval;
175 172
 
@@ -179,13 +176,12 @@ void GcodeSuite::M420() {
179 176
           if (!NEAR_ZERO(zmean)) {
180 177
             set_bed_leveling_enabled(false);
181 178
             // Subtract the mean from all values
182
-            for (uint8_t x = GRID_MAX_POINTS_X; x--;)
183
-              for (uint8_t y = GRID_MAX_POINTS_Y; y--;) {
184
-                Z_VALUES(x, y) -= zmean;
185
-                #if ENABLED(EXTENSIBLE_UI)
186
-                  ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
187
-                #endif
188
-              }
179
+            GRID_LOOP(x, y) {
180
+              Z_VALUES(x, y) -= zmean;
181
+              #if ENABLED(EXTENSIBLE_UI)
182
+                ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
183
+              #endif
184
+            }
189 185
             #if ENABLED(ABL_BILINEAR_SUBDIVISION)
190 186
               bed_level_virt_interpolate();
191 187
             #endif

Loading…
Отказ
Запис