Browse Source

Outdent UBL code

Scott Lahteine 3 years ago
parent
commit
bdb8c07bb2
3 changed files with 1863 additions and 1863 deletions
  1. 191
    191
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  2. 243
    243
      Marlin/src/feature/bedlevel/ubl/ubl.h
  3. 1429
    1429
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+ 191
- 191
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

@@ -24,234 +24,234 @@
24 24
 
25 25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26 26
 
27
-  #include "../bedlevel.h"
27
+#include "../bedlevel.h"
28 28
 
29
-  unified_bed_leveling ubl;
29
+unified_bed_leveling ubl;
30 30
 
31
-  #include "../../../MarlinCore.h"
32
-  #include "../../../gcode/gcode.h"
31
+#include "../../../MarlinCore.h"
32
+#include "../../../gcode/gcode.h"
33 33
 
34
-  #include "../../../module/settings.h"
35
-  #include "../../../module/planner.h"
36
-  #include "../../../module/motion.h"
37
-  #include "../../../module/probe.h"
34
+#include "../../../module/settings.h"
35
+#include "../../../module/planner.h"
36
+#include "../../../module/motion.h"
37
+#include "../../../module/probe.h"
38 38
 
39
-  #if ENABLED(EXTENSIBLE_UI)
40
-    #include "../../../lcd/extui/ui_api.h"
41
-  #endif
42
-
43
-  #include "math.h"
39
+#if ENABLED(EXTENSIBLE_UI)
40
+  #include "../../../lcd/extui/ui_api.h"
41
+#endif
44 42
 
45
-  void unified_bed_leveling::echo_name() { SERIAL_ECHOPGM("Unified Bed Leveling"); }
43
+#include "math.h"
46 44
 
47
-  void unified_bed_leveling::report_current_mesh() {
48
-    if (!leveling_is_valid()) return;
49
-    SERIAL_ECHO_MSG("  G29 I999");
50
-    GRID_LOOP(x, y)
51
-      if (!isnan(z_values[x][y])) {
52
-        SERIAL_ECHO_START();
53
-        SERIAL_ECHOPAIR("  M421 I", x, " J", y);
54
-        SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
55
-        serial_delay(75); // Prevent Printrun from exploding
56
-      }
57
-  }
45
+void unified_bed_leveling::echo_name() { SERIAL_ECHOPGM("Unified Bed Leveling"); }
58 46
 
59
-  void unified_bed_leveling::report_state() {
60
-    echo_name();
61
-    SERIAL_ECHO_TERNARY(planner.leveling_active, " System v" UBL_VERSION " ", "", "in", "active\n");
62
-    serial_delay(50);
47
+void unified_bed_leveling::report_current_mesh() {
48
+  if (!leveling_is_valid()) return;
49
+  SERIAL_ECHO_MSG("  G29 I999");
50
+  GRID_LOOP(x, y)
51
+    if (!isnan(z_values[x][y])) {
52
+      SERIAL_ECHO_START();
53
+      SERIAL_ECHOPAIR("  M421 I", x, " J", y);
54
+      SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
55
+      serial_delay(75); // Prevent Printrun from exploding
56
+    }
57
+}
58
+
59
+void unified_bed_leveling::report_state() {
60
+  echo_name();
61
+  SERIAL_ECHO_TERNARY(planner.leveling_active, " System v" UBL_VERSION " ", "", "in", "active\n");
62
+  serial_delay(50);
63
+}
64
+
65
+int8_t unified_bed_leveling::storage_slot;
66
+
67
+float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
68
+
69
+#define _GRIDPOS(A,N) (MESH_MIN_##A + N * (MESH_##A##_DIST))
70
+
71
+const float
72
+unified_bed_leveling::_mesh_index_to_xpos[GRID_MAX_POINTS_X] PROGMEM = ARRAY_N(GRID_MAX_POINTS_X,
73
+  _GRIDPOS(X,  0), _GRIDPOS(X,  1), _GRIDPOS(X,  2), _GRIDPOS(X,  3),
74
+  _GRIDPOS(X,  4), _GRIDPOS(X,  5), _GRIDPOS(X,  6), _GRIDPOS(X,  7),
75
+  _GRIDPOS(X,  8), _GRIDPOS(X,  9), _GRIDPOS(X, 10), _GRIDPOS(X, 11),
76
+  _GRIDPOS(X, 12), _GRIDPOS(X, 13), _GRIDPOS(X, 14), _GRIDPOS(X, 15)
77
+),
78
+unified_bed_leveling::_mesh_index_to_ypos[GRID_MAX_POINTS_Y] PROGMEM = ARRAY_N(GRID_MAX_POINTS_Y,
79
+  _GRIDPOS(Y,  0), _GRIDPOS(Y,  1), _GRIDPOS(Y,  2), _GRIDPOS(Y,  3),
80
+  _GRIDPOS(Y,  4), _GRIDPOS(Y,  5), _GRIDPOS(Y,  6), _GRIDPOS(Y,  7),
81
+  _GRIDPOS(Y,  8), _GRIDPOS(Y,  9), _GRIDPOS(Y, 10), _GRIDPOS(Y, 11),
82
+  _GRIDPOS(Y, 12), _GRIDPOS(Y, 13), _GRIDPOS(Y, 14), _GRIDPOS(Y, 15)
83
+);
84
+
85
+volatile int16_t unified_bed_leveling::encoder_diff;
86
+
87
+unified_bed_leveling::unified_bed_leveling() { reset(); }
88
+
89
+void unified_bed_leveling::reset() {
90
+  const bool was_enabled = planner.leveling_active;
91
+  set_bed_leveling_enabled(false);
92
+  storage_slot = -1;
93
+  ZERO(z_values);
94
+  #if ENABLED(EXTENSIBLE_UI)
95
+    GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, 0);
96
+  #endif
97
+  if (was_enabled) report_current_position();
98
+}
99
+
100
+void unified_bed_leveling::invalidate() {
101
+  set_bed_leveling_enabled(false);
102
+  set_all_mesh_points_to_value(NAN);
103
+}
104
+
105
+void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
106
+  GRID_LOOP(x, y) {
107
+    z_values[x][y] = value;
108
+    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, value));
63 109
   }
64
-
65
-  int8_t unified_bed_leveling::storage_slot;
66
-
67
-  float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
68
-
69
-  #define _GRIDPOS(A,N) (MESH_MIN_##A + N * (MESH_##A##_DIST))
70
-
71
-  const float
72
-  unified_bed_leveling::_mesh_index_to_xpos[GRID_MAX_POINTS_X] PROGMEM = ARRAY_N(GRID_MAX_POINTS_X,
73
-    _GRIDPOS(X,  0), _GRIDPOS(X,  1), _GRIDPOS(X,  2), _GRIDPOS(X,  3),
74
-    _GRIDPOS(X,  4), _GRIDPOS(X,  5), _GRIDPOS(X,  6), _GRIDPOS(X,  7),
75
-    _GRIDPOS(X,  8), _GRIDPOS(X,  9), _GRIDPOS(X, 10), _GRIDPOS(X, 11),
76
-    _GRIDPOS(X, 12), _GRIDPOS(X, 13), _GRIDPOS(X, 14), _GRIDPOS(X, 15)
77
-  ),
78
-  unified_bed_leveling::_mesh_index_to_ypos[GRID_MAX_POINTS_Y] PROGMEM = ARRAY_N(GRID_MAX_POINTS_Y,
79
-    _GRIDPOS(Y,  0), _GRIDPOS(Y,  1), _GRIDPOS(Y,  2), _GRIDPOS(Y,  3),
80
-    _GRIDPOS(Y,  4), _GRIDPOS(Y,  5), _GRIDPOS(Y,  6), _GRIDPOS(Y,  7),
81
-    _GRIDPOS(Y,  8), _GRIDPOS(Y,  9), _GRIDPOS(Y, 10), _GRIDPOS(Y, 11),
82
-    _GRIDPOS(Y, 12), _GRIDPOS(Y, 13), _GRIDPOS(Y, 14), _GRIDPOS(Y, 15)
83
-  );
84
-
85
-  volatile int16_t unified_bed_leveling::encoder_diff;
86
-
87
-  unified_bed_leveling::unified_bed_leveling() { reset(); }
88
-
89
-  void unified_bed_leveling::reset() {
90
-    const bool was_enabled = planner.leveling_active;
91
-    set_bed_leveling_enabled(false);
92
-    storage_slot = -1;
93
-    ZERO(z_values);
94
-    #if ENABLED(EXTENSIBLE_UI)
95
-      GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, 0);
96
-    #endif
97
-    if (was_enabled) report_current_position();
110
+}
111
+
112
+#if ENABLED(OPTIMIZED_MESH_STORAGE)
113
+
114
+  constexpr float mesh_store_scaling = 1000;
115
+  constexpr int16_t Z_STEPS_NAN = INT16_MAX;
116
+
117
+  void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
118
+    auto z_to_store = [](const float &z) {
119
+      if (isnan(z)) return Z_STEPS_NAN;
120
+      const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
121
+      if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
122
+        return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN'
123
+      return int16_t(z_scaled);
124
+    };
125
+    GRID_LOOP(x, y) stored_values[x][y] = z_to_store(in_values[x][y]);
98 126
   }
99 127
 
100
-  void unified_bed_leveling::invalidate() {
101
-    set_bed_leveling_enabled(false);
102
-    set_all_mesh_points_to_value(NAN);
128
+  void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
129
+    auto store_to_z = [](const int16_t z_scaled) {
130
+      return z_scaled == Z_STEPS_NAN ? NAN : z_scaled / mesh_store_scaling;
131
+    };
132
+    GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
103 133
   }
104 134
 
105
-  void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
106
-    GRID_LOOP(x, y) {
107
-      z_values[x][y] = value;
108
-      TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, value));
109
-    }
135
+#endif // OPTIMIZED_MESH_STORAGE
136
+
137
+static void serial_echo_xy(const uint8_t sp, const int16_t x, const int16_t y) {
138
+  SERIAL_ECHO_SP(sp);
139
+  SERIAL_CHAR('(');
140
+  if (x < 100) { SERIAL_CHAR(' '); if (x < 10) SERIAL_CHAR(' '); }
141
+  SERIAL_ECHO(x);
142
+  SERIAL_CHAR(',');
143
+  if (y < 100) { SERIAL_CHAR(' '); if (y < 10) SERIAL_CHAR(' '); }
144
+  SERIAL_ECHO(y);
145
+  SERIAL_CHAR(')');
146
+  serial_delay(5);
147
+}
148
+
149
+static void serial_echo_column_labels(const uint8_t sp) {
150
+  SERIAL_ECHO_SP(7);
151
+  LOOP_L_N(i, GRID_MAX_POINTS_X) {
152
+    if (i < 10) SERIAL_CHAR(' ');
153
+    SERIAL_ECHO(i);
154
+    SERIAL_ECHO_SP(sp);
110 155
   }
156
+  serial_delay(10);
157
+}
111 158
 
112
-  #if ENABLED(OPTIMIZED_MESH_STORAGE)
113
-
114
-    constexpr float mesh_store_scaling = 1000;
115
-    constexpr int16_t Z_STEPS_NAN = INT16_MAX;
116
-
117
-    void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
118
-      auto z_to_store = [](const float &z) {
119
-        if (isnan(z)) return Z_STEPS_NAN;
120
-        const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
121
-        if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
122
-          return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN'
123
-        return int16_t(z_scaled);
124
-      };
125
-      GRID_LOOP(x, y) stored_values[x][y] = z_to_store(in_values[x][y]);
126
-    }
159
+/**
160
+ * Produce one of these mesh maps:
161
+ *   0: Human-readable
162
+ *   1: CSV format for spreadsheet import
163
+ *   2: TODO: Display on Graphical LCD
164
+ *   4: Compact Human-Readable
165
+ */
166
+void unified_bed_leveling::display_map(const int map_type) {
167
+  const bool was = gcode.set_autoreport_paused(true);
127 168
 
128
-    void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
129
-      auto store_to_z = [](const int16_t z_scaled) {
130
-        return z_scaled == Z_STEPS_NAN ? NAN : z_scaled / mesh_store_scaling;
131
-      };
132
-      GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
133
-    }
169
+  constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
170
+                    twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
134 171
 
135
-  #endif // OPTIMIZED_MESH_STORAGE
172
+  const bool human = !(map_type & 0x3), csv = map_type == 1, lcd = map_type == 2, comp = map_type & 0x4;
136 173
 
137
-  static void serial_echo_xy(const uint8_t sp, const int16_t x, const int16_t y) {
138
-    SERIAL_ECHO_SP(sp);
139
-    SERIAL_CHAR('(');
140
-    if (x < 100) { SERIAL_CHAR(' '); if (x < 10) SERIAL_CHAR(' '); }
141
-    SERIAL_ECHO(x);
142
-    SERIAL_CHAR(',');
143
-    if (y < 100) { SERIAL_CHAR(' '); if (y < 10) SERIAL_CHAR(' '); }
144
-    SERIAL_ECHO(y);
145
-    SERIAL_CHAR(')');
146
-    serial_delay(5);
174
+  SERIAL_ECHOPGM("\nBed Topography Report");
175
+  if (human) {
176
+    SERIAL_ECHOLNPGM(":\n");
177
+    serial_echo_xy(4, MESH_MIN_X, MESH_MAX_Y);
178
+    serial_echo_xy(twixt, MESH_MAX_X, MESH_MAX_Y);
179
+    SERIAL_EOL();
180
+    serial_echo_column_labels(eachsp - 2);
147 181
   }
148
-
149
-  static void serial_echo_column_labels(const uint8_t sp) {
150
-    SERIAL_ECHO_SP(7);
151
-    LOOP_L_N(i, GRID_MAX_POINTS_X) {
152
-      if (i < 10) SERIAL_CHAR(' ');
153
-      SERIAL_ECHO(i);
154
-      SERIAL_ECHO_SP(sp);
155
-    }
156
-    serial_delay(10);
182
+  else {
183
+    SERIAL_ECHOPGM(" for ");
184
+    serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
157 185
   }
158 186
 
159
-  /**
160
-   * Produce one of these mesh maps:
161
-   *   0: Human-readable
162
-   *   1: CSV format for spreadsheet import
163
-   *   2: TODO: Display on Graphical LCD
164
-   *   4: Compact Human-Readable
165
-   */
166
-  void unified_bed_leveling::display_map(const int map_type) {
167
-    const bool was = gcode.set_autoreport_paused(true);
187
+  // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when
188
+  // moving to the XY position to be measured. This ensures better agreement between
189
+  // the current Z position after G28 and the mesh values.
190
+  const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe.offset_xy);
168 191
 
169
-    constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
170
-                      twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
192
+  if (!lcd) SERIAL_EOL();
193
+  for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
171 194
 
172
-    const bool human = !(map_type & 0x3), csv = map_type == 1, lcd = map_type == 2, comp = map_type & 0x4;
173
-
174
-    SERIAL_ECHOPGM("\nBed Topography Report");
195
+    // Row Label (J index)
175 196
     if (human) {
176
-      SERIAL_ECHOLNPGM(":\n");
177
-      serial_echo_xy(4, MESH_MIN_X, MESH_MAX_Y);
178
-      serial_echo_xy(twixt, MESH_MAX_X, MESH_MAX_Y);
179
-      SERIAL_EOL();
180
-      serial_echo_column_labels(eachsp - 2);
181
-    }
182
-    else {
183
-      SERIAL_ECHOPGM(" for ");
184
-      serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
197
+      if (j < 10) SERIAL_CHAR(' ');
198
+      SERIAL_ECHO(j);
199
+      SERIAL_ECHOPGM(" |");
185 200
     }
186 201
 
187
-    // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when
188
-    // moving to the XY position to be measured. This ensures better agreement between
189
-    // the current Z position after G28 and the mesh values.
190
-    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe.offset_xy);
202
+    // Row Values (I indexes)
203
+    LOOP_L_N(i, GRID_MAX_POINTS_X) {
191 204
 
192
-    if (!lcd) SERIAL_EOL();
193
-    for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
205
+      // Opening Brace or Space
206
+      const bool is_current = i == curr.x && j == curr.y;
207
+      if (human) SERIAL_CHAR(is_current ? '[' : ' ');
194 208
 
195
-      // Row Label (J index)
196
-      if (human) {
197
-        if (j < 10) SERIAL_CHAR(' ');
198
-        SERIAL_ECHO(j);
199
-        SERIAL_ECHOPGM(" |");
209
+      // Z Value at current I, J
210
+      const float f = z_values[i][j];
211
+      if (lcd) {
212
+        // TODO: Display on Graphical LCD
200 213
       }
201
-
202
-      // Row Values (I indexes)
203
-      LOOP_L_N(i, GRID_MAX_POINTS_X) {
204
-
205
-        // Opening Brace or Space
206
-        const bool is_current = i == curr.x && j == curr.y;
207
-        if (human) SERIAL_CHAR(is_current ? '[' : ' ');
208
-
209
-        // Z Value at current I, J
210
-        const float f = z_values[i][j];
211
-        if (lcd) {
212
-          // TODO: Display on Graphical LCD
213
-        }
214
-        else if (isnan(f))
215
-          serialprintPGM(human ? PSTR("  .   ") : PSTR("NAN"));
216
-        else if (human || csv) {
217
-          if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' ');  // Display sign also for positive numbers (' ' for 0)
218
-          SERIAL_ECHO_F(f, 3);                                    // Positive: 5 digits, Negative: 6 digits
219
-        }
220
-        if (csv && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR('\t');
221
-
222
-        // Closing Brace or Space
223
-        if (human) SERIAL_CHAR(is_current ? ']' : ' ');
224
-
225
-        SERIAL_FLUSHTX();
226
-        idle_no_sleep();
214
+      else if (isnan(f))
215
+        serialprintPGM(human ? PSTR("  .   ") : PSTR("NAN"));
216
+      else if (human || csv) {
217
+        if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' ');  // Display sign also for positive numbers (' ' for 0)
218
+        SERIAL_ECHO_F(f, 3);                                    // Positive: 5 digits, Negative: 6 digits
227 219
       }
228
-      if (!lcd) SERIAL_EOL();
220
+      if (csv && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR('\t');
229 221
 
230
-      // A blank line between rows (unless compact)
231
-      if (j && human && !comp) SERIAL_ECHOLNPGM("   |");
232
-    }
222
+      // Closing Brace or Space
223
+      if (human) SERIAL_CHAR(is_current ? ']' : ' ');
233 224
 
234
-    if (human) {
235
-      serial_echo_column_labels(eachsp - 2);
236
-      SERIAL_EOL();
237
-      serial_echo_xy(4, MESH_MIN_X, MESH_MIN_Y);
238
-      serial_echo_xy(twixt, MESH_MAX_X, MESH_MIN_Y);
239
-      SERIAL_EOL();
240
-      SERIAL_EOL();
225
+      SERIAL_FLUSHTX();
226
+      idle_no_sleep();
241 227
     }
228
+    if (!lcd) SERIAL_EOL();
242 229
 
243
-    gcode.set_autoreport_paused(was);
230
+    // A blank line between rows (unless compact)
231
+    if (j && human && !comp) SERIAL_ECHOLNPGM("   |");
244 232
   }
245 233
 
246
-  bool unified_bed_leveling::sanity_check() {
247
-    uint8_t error_flag = 0;
234
+  if (human) {
235
+    serial_echo_column_labels(eachsp - 2);
236
+    SERIAL_EOL();
237
+    serial_echo_xy(4, MESH_MIN_X, MESH_MIN_Y);
238
+    serial_echo_xy(twixt, MESH_MAX_X, MESH_MIN_Y);
239
+    SERIAL_EOL();
240
+    SERIAL_EOL();
241
+  }
248 242
 
249
-    if (settings.calc_num_meshes() < 1) {
250
-      SERIAL_ECHOLNPGM("?Mesh too big for EEPROM.");
251
-      error_flag++;
252
-    }
243
+  gcode.set_autoreport_paused(was);
244
+}
253 245
 
254
-    return !!error_flag;
246
+bool unified_bed_leveling::sanity_check() {
247
+  uint8_t error_flag = 0;
248
+
249
+  if (settings.calc_num_meshes() < 1) {
250
+    SERIAL_ECHOLNPGM("?Mesh too big for EEPROM.");
251
+    error_flag++;
255 252
   }
256 253
 
254
+  return !!error_flag;
255
+}
256
+
257 257
 #endif // AUTO_BED_LEVELING_UBL

+ 243
- 243
Marlin/src/feature/bedlevel/ubl/ubl.h View File

@@ -46,275 +46,275 @@ struct mesh_index_pair;
46 46
 #endif
47 47
 
48 48
 class unified_bed_leveling {
49
-  private:
50
-
51
-    static int    g29_verbose_level,
52
-                  g29_phase_value,
53
-                  g29_repetition_cnt,
54
-                  g29_storage_slot,
55
-                  g29_map_type;
56
-    static bool   g29_c_flag;
57
-    static float  g29_card_thickness,
58
-                  g29_constant;
59
-    static xy_pos_t g29_pos;
60
-    static xy_bool_t xy_seen;
61
-
62
-    #if HAS_BED_PROBE
63
-      static int  g29_grid_size;
64
-    #endif
65
-
66
-    #if IS_NEWPANEL
67
-      static void move_z_with_encoder(const float &multiplier);
68
-      static float measure_point_with_encoder();
69
-      static float measure_business_card_thickness();
70
-      static void manually_probe_remaining_mesh(const xy_pos_t&, const float&, const float&, const bool) _O0;
71
-      static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) _O0;
72
-    #endif
49
+private:
50
+
51
+  static int    g29_verbose_level,
52
+                g29_phase_value,
53
+                g29_repetition_cnt,
54
+                g29_storage_slot,
55
+                g29_map_type;
56
+  static bool   g29_c_flag;
57
+  static float  g29_card_thickness,
58
+                g29_constant;
59
+  static xy_pos_t g29_pos;
60
+  static xy_bool_t xy_seen;
61
+
62
+  #if HAS_BED_PROBE
63
+    static int  g29_grid_size;
64
+  #endif
65
+
66
+  #if IS_NEWPANEL
67
+    static void move_z_with_encoder(const float &multiplier);
68
+    static float measure_point_with_encoder();
69
+    static float measure_business_card_thickness();
70
+    static void manually_probe_remaining_mesh(const xy_pos_t&, const float&, const float&, const bool) _O0;
71
+    static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) _O0;
72
+  #endif
73
+
74
+  static bool g29_parameter_parsing() _O0;
75
+  static void shift_mesh_height();
76
+  static void probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) _O0;
77
+  static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
78
+  static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
79
+  static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
80
+  static inline bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) {
81
+    return smart_fill_one(pos.x, pos.y, dir.x, dir.y);
82
+  }
83
+  static void smart_fill_mesh();
84
+
85
+  #if ENABLED(UBL_DEVEL_DEBUGGING)
86
+    static void g29_what_command();
87
+    static void g29_eeprom_dump();
88
+    static void g29_compare_current_mesh_to_stored_mesh();
89
+  #endif
90
+
91
+public:
92
+
93
+  static void echo_name();
94
+  static void report_current_mesh();
95
+  static void report_state();
96
+  static void save_ubl_active_state_and_disable();
97
+  static void restore_ubl_active_state_and_leave();
98
+  static void display_map(const int) _O0;
99
+  static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0;
100
+  static mesh_index_pair find_furthest_invalid_mesh_point() _O0;
101
+  static void reset();
102
+  static void invalidate();
103
+  static void set_all_mesh_points_to_value(const float value);
104
+  static void adjust_mesh_to_mean(const bool cflag, const float value);
105
+  static bool sanity_check();
106
+
107
+  static void G29() _O0;                          // O0 for no optimization
108
+  static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
109
+
110
+  static int8_t storage_slot;
111
+
112
+  static bed_mesh_t z_values;
113
+  #if ENABLED(OPTIMIZED_MESH_STORAGE)
114
+    static void set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values);
115
+    static void set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values);
116
+  #endif
117
+  static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X],
118
+                     _mesh_index_to_ypos[GRID_MAX_POINTS_Y];
119
+
120
+  #if HAS_LCD_MENU
121
+    static bool lcd_map_control;
122
+    static void steppers_were_disabled();
123
+  #else
124
+    static inline void steppers_were_disabled() {}
125
+  #endif
126
+
127
+  static volatile int16_t encoder_diff; // Volatile because buttons may changed it at interrupt time
128
+
129
+  unified_bed_leveling();
130
+
131
+  FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
132
+
133
+  static int8_t cell_index_x_raw(const float &x) {
134
+    return FLOOR((x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST));
135
+  }
136
+
137
+  static int8_t cell_index_y_raw(const float &y) {
138
+    return FLOOR((y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST));
139
+  }
140
+
141
+  static int8_t cell_index_x_valid(const float &x) {
142
+    return WITHIN(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X - 2));
143
+  }
144
+
145
+  static int8_t cell_index_y_valid(const float &y) {
146
+    return WITHIN(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y - 2));
147
+  }
148
+
149
+  static int8_t cell_index_x(const float &x) {
150
+    return constrain(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X) - 2);
151
+  }
152
+
153
+  static int8_t cell_index_y(const float &y) {
154
+    return constrain(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y) - 2);
155
+  }
156
+
157
+  static inline xy_int8_t cell_indexes(const float &x, const float &y) {
158
+    return { cell_index_x(x), cell_index_y(y) };
159
+  }
160
+  static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); }
161
+
162
+  static int8_t closest_x_index(const float &x) {
163
+    const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST);
164
+    return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
165
+  }
166
+  static int8_t closest_y_index(const float &y) {
167
+    const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST);
168
+    return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
169
+  }
170
+  static inline xy_int8_t closest_indexes(const xy_pos_t &xy) {
171
+    return { closest_x_index(xy.x), closest_y_index(xy.y) };
172
+  }
173
+
174
+  /**
175
+   *                           z2   --|
176
+   *                 z0        |      |
177
+   *                  |        |      + (z2-z1)
178
+   *   z1             |        |      |
179
+   * ---+-------------+--------+--  --|
180
+   *   a1            a0        a2
181
+   *    |<---delta_a---------->|
182
+   *
183
+   *  calc_z0 is the basis for all the Mesh Based correction. It is used to
184
+   *  find the expected Z Height at a position between two known Z-Height locations.
185
+   *
186
+   *  It is fairly expensive with its 4 floating point additions and 2 floating point
187
+   *  multiplications.
188
+   */
189
+  FORCE_INLINE static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
190
+    return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
191
+  }
192
+
193
+  #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
194
+    #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
195
+  #else
196
+    #define _UBL_OUTER_Z_RAISE NAN
197
+  #endif
198
+
199
+  /**
200
+   * z_correction_for_x_on_horizontal_mesh_line is an optimization for
201
+   * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
202
+   */
203
+  static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
204
+    if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
205
+
206
+      if (DEBUGGING(LEVELING)) {
207
+        if (WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("yi"); else DEBUG_ECHOPGM("x1_i");
208
+        DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")");
209
+      }
73 210
 
74
-    static bool g29_parameter_parsing() _O0;
75
-    static void shift_mesh_height();
76
-    static void probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) _O0;
77
-    static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
78
-    static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
79
-    static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
80
-    static inline bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) {
81
-      return smart_fill_one(pos.x, pos.y, dir.x, dir.y);
211
+      // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
212
+      return _UBL_OUTER_Z_RAISE;
82 213
     }
83
-    static void smart_fill_mesh();
84
-
85
-    #if ENABLED(UBL_DEVEL_DEBUGGING)
86
-      static void g29_what_command();
87
-      static void g29_eeprom_dump();
88
-      static void g29_compare_current_mesh_to_stored_mesh();
89
-    #endif
90 214
 
91
-  public:
92
-
93
-    static void echo_name();
94
-    static void report_current_mesh();
95
-    static void report_state();
96
-    static void save_ubl_active_state_and_disable();
97
-    static void restore_ubl_active_state_and_leave();
98
-    static void display_map(const int) _O0;
99
-    static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0;
100
-    static mesh_index_pair find_furthest_invalid_mesh_point() _O0;
101
-    static void reset();
102
-    static void invalidate();
103
-    static void set_all_mesh_points_to_value(const float value);
104
-    static void adjust_mesh_to_mean(const bool cflag, const float value);
105
-    static bool sanity_check();
106
-
107
-    static void G29() _O0;                          // O0 for no optimization
108
-    static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
109
-
110
-    static int8_t storage_slot;
111
-
112
-    static bed_mesh_t z_values;
113
-    #if ENABLED(OPTIMIZED_MESH_STORAGE)
114
-      static void set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values);
115
-      static void set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values);
116
-    #endif
117
-    static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X],
118
-                       _mesh_index_to_ypos[GRID_MAX_POINTS_Y];
119
-
120
-    #if HAS_LCD_MENU
121
-      static bool lcd_map_control;
122
-      static void steppers_were_disabled();
123
-    #else
124
-      static inline void steppers_were_disabled() {}
125
-    #endif
126
-
127
-    static volatile int16_t encoder_diff; // Volatile because buttons may changed it at interrupt time
215
+    const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * RECIPROCAL(MESH_X_DIST),
216
+                z1 = z_values[x1_i][yi];
128 217
 
129
-    unified_bed_leveling();
218
+    return z1 + xratio * (z_values[_MIN(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array
219
+                                                                                    // If it is, it is clamped to the last element of the
220
+                                                                                    // z_values[][] array and no correction is applied.
221
+  }
130 222
 
131
-    FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
223
+  //
224
+  // See comments above for z_correction_for_x_on_horizontal_mesh_line
225
+  //
226
+  static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
227
+    if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
132 228
 
133
-    static int8_t cell_index_x_raw(const float &x) {
134
-      return FLOOR((x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST));
135
-    }
136
-
137
-    static int8_t cell_index_y_raw(const float &y) {
138
-      return FLOOR((y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST));
139
-    }
140
-
141
-    static int8_t cell_index_x_valid(const float &x) {
142
-      return WITHIN(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X - 2));
143
-    }
229
+      if (DEBUGGING(LEVELING)) {
230
+        if (WITHIN(xi, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("y1_i"); else DEBUG_ECHOPGM("xi");
231
+        DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")");
232
+      }
144 233
 
145
-    static int8_t cell_index_y_valid(const float &y) {
146
-      return WITHIN(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y - 2));
234
+      // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
235
+      return _UBL_OUTER_Z_RAISE;
147 236
     }
148 237
 
149
-    static int8_t cell_index_x(const float &x) {
150
-      return constrain(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X) - 2);
151
-    }
238
+    const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * RECIPROCAL(MESH_Y_DIST),
239
+                z1 = z_values[xi][y1_i];
152 240
 
153
-    static int8_t cell_index_y(const float &y) {
154
-      return constrain(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y) - 2);
155
-    }
241
+    return z1 + yratio * (z_values[xi][_MIN(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array
242
+                                                                                    // If it is, it is clamped to the last element of the
243
+                                                                                    // z_values[][] array and no correction is applied.
244
+  }
156 245
 
157
-    static inline xy_int8_t cell_indexes(const float &x, const float &y) {
158
-      return { cell_index_x(x), cell_index_y(y) };
159
-    }
160
-    static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); }
161
-
162
-    static int8_t closest_x_index(const float &x) {
163
-      const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST);
164
-      return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
165
-    }
166
-    static int8_t closest_y_index(const float &y) {
167
-      const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST);
168
-      return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
169
-    }
170
-    static inline xy_int8_t closest_indexes(const xy_pos_t &xy) {
171
-      return { closest_x_index(xy.x), closest_y_index(xy.y) };
172
-    }
246
+  /**
247
+   * This is the generic Z-Correction. It works anywhere within a Mesh Cell. It first
248
+   * does a linear interpolation along both of the bounding X-Mesh-Lines to find the
249
+   * Z-Height at both ends. Then it does a linear interpolation of these heights based
250
+   * on the Y position within the cell.
251
+   */
252
+  static float get_z_correction(const float &rx0, const float &ry0) {
253
+    const int8_t cx = cell_index_x(rx0), cy = cell_index_y(ry0); // return values are clamped
173 254
 
174 255
     /**
175
-     *                           z2   --|
176
-     *                 z0        |      |
177
-     *                  |        |      + (z2-z1)
178
-     *   z1             |        |      |
179
-     * ---+-------------+--------+--  --|
180
-     *   a1            a0        a2
181
-     *    |<---delta_a---------->|
182
-     *
183
-     *  calc_z0 is the basis for all the Mesh Based correction. It is used to
184
-     *  find the expected Z Height at a position between two known Z-Height locations.
185
-     *
186
-     *  It is fairly expensive with its 4 floating point additions and 2 floating point
187
-     *  multiplications.
256
+     * Check if the requested location is off the mesh.  If so, and
257
+     * UBL_Z_RAISE_WHEN_OFF_MESH is specified, that value is returned.
188 258
      */
189
-    FORCE_INLINE static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
190
-      return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
191
-    }
192
-
193 259
     #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
194
-      #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
195
-    #else
196
-      #define _UBL_OUTER_Z_RAISE NAN
260
+      if (!WITHIN(rx0, MESH_MIN_X, MESH_MAX_X) || !WITHIN(ry0, MESH_MIN_Y, MESH_MAX_Y))
261
+        return UBL_Z_RAISE_WHEN_OFF_MESH;
197 262
     #endif
198 263
 
199
-    /**
200
-     * z_correction_for_x_on_horizontal_mesh_line is an optimization for
201
-     * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
202
-     */
203
-    static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
204
-      if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
205
-
206
-        if (DEBUGGING(LEVELING)) {
207
-          if (WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("yi"); else DEBUG_ECHOPGM("x1_i");
208
-          DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")");
209
-        }
264
+    const float z1 = calc_z0(rx0,
265
+                             mesh_index_to_xpos(cx), z_values[cx][cy],
266
+                             mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][cy]);
210 267
 
211
-        // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
212
-        return _UBL_OUTER_Z_RAISE;
213
-      }
268
+    const float z2 = calc_z0(rx0,
269
+                             mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1],
270
+                             mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1]);
214 271
 
215
-      const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * RECIPROCAL(MESH_X_DIST),
216
-                  z1 = z_values[x1_i][yi];
272
+    float z0 = calc_z0(ry0,
273
+                       mesh_index_to_ypos(cy), z1,
274
+                       mesh_index_to_ypos(cy + 1), z2);
217 275
 
218
-      return z1 + xratio * (z_values[_MIN(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array
219
-                                                                                      // If it is, it is clamped to the last element of the
220
-                                                                                      // z_values[][] array and no correction is applied.
276
+    if (DEBUGGING(MESH_ADJUST)) {
277
+      DEBUG_ECHOPAIR(" raw get_z_correction(", rx0);
278
+      DEBUG_CHAR(','); DEBUG_ECHO(ry0);
279
+      DEBUG_ECHOPAIR_F(") = ", z0, 6);
280
+      DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6);
221 281
     }
222 282
 
223
-    //
224
-    // See comments above for z_correction_for_x_on_horizontal_mesh_line
225
-    //
226
-    static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
227
-      if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
228
-
229
-        if (DEBUGGING(LEVELING)) {
230
-          if (WITHIN(xi, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("y1_i"); else DEBUG_ECHOPGM("xi");
231
-          DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")");
232
-        }
233
-
234
-        // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
235
-        return _UBL_OUTER_Z_RAISE;
236
-      }
237
-
238
-      const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * RECIPROCAL(MESH_Y_DIST),
239
-                  z1 = z_values[xi][y1_i];
240
-
241
-      return z1 + yratio * (z_values[xi][_MIN(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array
242
-                                                                                      // If it is, it is clamped to the last element of the
243
-                                                                                      // z_values[][] array and no correction is applied.
244
-    }
245
-
246
-    /**
247
-     * This is the generic Z-Correction. It works anywhere within a Mesh Cell. It first
248
-     * does a linear interpolation along both of the bounding X-Mesh-Lines to find the
249
-     * Z-Height at both ends. Then it does a linear interpolation of these heights based
250
-     * on the Y position within the cell.
251
-     */
252
-    static float get_z_correction(const float &rx0, const float &ry0) {
253
-      const int8_t cx = cell_index_x(rx0), cy = cell_index_y(ry0); // return values are clamped
254
-
255
-      /**
256
-       * Check if the requested location is off the mesh.  If so, and
257
-       * UBL_Z_RAISE_WHEN_OFF_MESH is specified, that value is returned.
258
-       */
259
-      #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
260
-        if (!WITHIN(rx0, MESH_MIN_X, MESH_MAX_X) || !WITHIN(ry0, MESH_MIN_Y, MESH_MAX_Y))
261
-          return UBL_Z_RAISE_WHEN_OFF_MESH;
262
-      #endif
263
-
264
-      const float z1 = calc_z0(rx0,
265
-                               mesh_index_to_xpos(cx), z_values[cx][cy],
266
-                               mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][cy]);
267
-
268
-      const float z2 = calc_z0(rx0,
269
-                               mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1],
270
-                               mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1]);
271
-
272
-      float z0 = calc_z0(ry0,
273
-                         mesh_index_to_ypos(cy), z1,
274
-                         mesh_index_to_ypos(cy + 1), z2);
283
+    if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
284
+      z0 = 0.0;      // in ubl.z_values[][] and propagate through the
285
+                     // calculations. If our correction is NAN, we throw it out
286
+                     // because part of the Mesh is undefined and we don't have the
287
+                     // information we need to complete the height correction.
275 288
 
276 289
       if (DEBUGGING(MESH_ADJUST)) {
277
-        DEBUG_ECHOPAIR(" raw get_z_correction(", rx0);
278
-        DEBUG_CHAR(','); DEBUG_ECHO(ry0);
279
-        DEBUG_ECHOPAIR_F(") = ", z0, 6);
280
-        DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6);
281
-      }
282
-
283
-      if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
284
-        z0 = 0.0;      // in ubl.z_values[][] and propagate through the
285
-                       // calculations. If our correction is NAN, we throw it out
286
-                       // because part of the Mesh is undefined and we don't have the
287
-                       // information we need to complete the height correction.
288
-
289
-        if (DEBUGGING(MESH_ADJUST)) {
290
-          DEBUG_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", rx0);
291
-          DEBUG_CHAR(',');
292
-          DEBUG_ECHO(ry0);
293
-          DEBUG_CHAR(')');
294
-          DEBUG_EOL();
295
-        }
290
+        DEBUG_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", rx0);
291
+        DEBUG_CHAR(',');
292
+        DEBUG_ECHO(ry0);
293
+        DEBUG_CHAR(')');
294
+        DEBUG_EOL();
296 295
       }
297
-      return z0;
298
-    }
299
-    static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
300
-
301
-    static inline float mesh_index_to_xpos(const uint8_t i) {
302
-      return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST);
303
-    }
304
-    static inline float mesh_index_to_ypos(const uint8_t i) {
305
-      return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
306
-    }
307
-
308
-    #if UBL_SEGMENTED
309
-      static bool line_to_destination_segmented(const feedRate_t &scaled_fr_mm_s);
310
-    #else
311
-      static void line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t e);
312
-    #endif
313
-
314
-    static inline bool mesh_is_valid() {
315
-      GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
316
-      return true;
317 296
     }
297
+    return z0;
298
+  }
299
+  static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
300
+
301
+  static inline float mesh_index_to_xpos(const uint8_t i) {
302
+    return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST);
303
+  }
304
+  static inline float mesh_index_to_ypos(const uint8_t i) {
305
+    return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
306
+  }
307
+
308
+  #if UBL_SEGMENTED
309
+    static bool line_to_destination_segmented(const feedRate_t &scaled_fr_mm_s);
310
+  #else
311
+    static void line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t e);
312
+  #endif
313
+
314
+  static inline bool mesh_is_valid() {
315
+    GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
316
+    return true;
317
+  }
318 318
 
319 319
 }; // class unified_bed_leveling
320 320
 

+ 1429
- 1429
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save