@@ -215,7 +215,7 @@ class unified_bed_leveling {
215
215
return _UBL_OUTER_Z_RAISE;
216
216
}
217
217
218
- const float xratio = (rx0 - mesh_index_to_xpos (x1_i)) * RECIPROCAL (MESH_X_DIST),
218
+ const float xratio = (rx0 - get_mesh_x (x1_i)) * RECIPROCAL (MESH_X_DIST),
219
219
z1 = z_values[x1_i][yi];
220
220
221
221
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
@@ -238,7 +238,7 @@ class unified_bed_leveling {
238
238
return _UBL_OUTER_Z_RAISE;
239
239
}
240
240
241
- const float yratio = (ry0 - mesh_index_to_ypos (y1_i)) * RECIPROCAL (MESH_Y_DIST),
241
+ const float yratio = (ry0 - get_mesh_y (y1_i)) * RECIPROCAL (MESH_Y_DIST),
242
242
z1 = z_values[xi][y1_i];
243
243
244
244
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
@@ -264,16 +264,17 @@ class unified_bed_leveling {
264
264
return UBL_Z_RAISE_WHEN_OFF_MESH;
265
265
#endif
266
266
267
- const uint8_t mx = _MIN (cx, (GRID_MAX_POINTS_X) - 2 ) + 1 , my = _MIN (cy, (GRID_MAX_POINTS_Y) - 2 ) + 1 ;
268
- const float z1 = calc_z0 (rx0, mesh_index_to_xpos (cx), z_values[cx][cy], mesh_index_to_xpos (cx + 1 ), z_values[mx][cy]);
269
- const float z2 = calc_z0 (rx0, mesh_index_to_xpos (cx), z_values[cx][my], mesh_index_to_xpos (cx + 1 ), z_values[mx][my]);
270
- float z0 = calc_z0 (ry0, mesh_index_to_ypos (cy), z1, mesh_index_to_ypos (cy + 1 ), z2);
267
+ const uint8_t mx = _MIN (cx, (GRID_MAX_POINTS_X) - 2 ) + 1 , my = _MIN (cy, (GRID_MAX_POINTS_Y) - 2 ) + 1 ,
268
+ x0 = get_mesh_x (cx), x1 = get_mesh_x (cx + 1 );
269
+ const float z1 = calc_z0 (rx0, x0, z_values[cx][cy], x1, z_values[mx][cy]),
270
+ z2 = calc_z0 (rx0, x0, z_values[cx][my], x1, z_values[mx][my]);
271
+ float z0 = calc_z0 (ry0, get_mesh_y (cy), z1, get_mesh_y (cy + 1 ), z2);
271
272
272
- if (isnan (z0)) { // if part of the Mesh is undefined, it will show up as NAN
273
- z0 = 0.0 ; // in ubl. z_values[][] and propagate through the
274
- // calculations. If our correction is NAN, we throw it out
275
- // because part of the Mesh is undefined and we don't have the
276
- // information we need to complete the height correction.
273
+ if (isnan (z0)) { // If part of the Mesh is undefined, it will show up as NAN
274
+ z0 = 0.0 ; // in z_values[][] and propagate through the calculations.
275
+ // If our correction is NAN, we throw it out because part of
276
+ // the Mesh is undefined and we don't have the information
277
+ // needed to complete the height correction.
277
278
278
279
if (DEBUGGING (MESH_ADJUST)) DEBUG_ECHOLNPGM (" ??? Yikes! NAN in " );
279
280
}
@@ -287,10 +288,12 @@ class unified_bed_leveling {
287
288
}
288
289
static float get_z_correction (const xy_pos_t &pos) { return get_z_correction (pos.x , pos.y ); }
289
290
290
- static float mesh_index_to_xpos (const uint8_t i) {
291
+ static constexpr float get_z_offset () { return 0 .0f ; }
292
+
293
+ static float get_mesh_x (const uint8_t i) {
291
294
return i < (GRID_MAX_POINTS_X) ? pgm_read_float (&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST);
292
295
}
293
- static float mesh_index_to_ypos (const uint8_t i) {
296
+ static float get_mesh_y (const uint8_t i) {
294
297
return i < (GRID_MAX_POINTS_Y) ? pgm_read_float (&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
295
298
}
296
299
@@ -307,11 +310,7 @@ class unified_bed_leveling {
307
310
308
311
}; // class unified_bed_leveling
309
312
310
- extern unified_bed_leveling ubl;
311
-
312
- #define _GET_MESH_X (I ) ubl.mesh_index_to_xpos(I)
313
- #define _GET_MESH_Y (J ) ubl.mesh_index_to_ypos(J)
314
- #define Z_VALUES_ARR ubl.z_values
313
+ extern unified_bed_leveling bedlevel;
315
314
316
315
// Prevent debugging propagating to other files
317
316
#include " ../../../core/debug_out.h"
0 commit comments