@@ -38,8 +38,8 @@ enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP, CLOSEST };
3838
3939struct mesh_index_pair ;
4040
41- #define MESH_X_DIST (float (( MESH_MAX_X ) - ( MESH_MIN_X ) ) / (GRID_MAX_CELLS_X ))
42- #define MESH_Y_DIST (float (( MESH_MAX_Y ) - ( MESH_MIN_Y ) ) / (GRID_MAX_CELLS_Y ))
41+ #define MESH_X_DIST ((mesh_max.x - mesh_min.x ) / (GRID_MAX_CELLS_X ))
42+ #define MESH_Y_DIST ((mesh_max.y - mesh_min.y ) / (GRID_MAX_CELLS_Y ))
4343
4444#if ENABLED(OPTIMIZED_MESH_STORAGE)
4545 #if ANY(PROUI_EX, PROUI_GRID_PNTS)
@@ -140,11 +140,11 @@ class unified_bed_leveling {
140140 FORCE_INLINE static void set_z (const int8_t px, const int8_t py, const float z) { z_values[px][py] = z; }
141141
142142 static int8_t cell_index_x_raw (const float x) {
143- return FLOOR ((x - ( MESH_MIN_X ) ) * RECIPROCAL (MESH_X_DIST ));
143+ return FLOOR ((x - mesh_min. x ) * RECIPROCAL (MESH_X_DIST ));
144144 }
145145
146146 static int8_t cell_index_y_raw (const float y) {
147- return FLOOR ((y - ( MESH_MIN_Y ) ) * RECIPROCAL (MESH_Y_DIST ));
147+ return FLOOR ((y - mesh_min. y ) * RECIPROCAL (MESH_Y_DIST ));
148148 }
149149
150150 static bool cell_index_x_valid (const float x) {
@@ -169,11 +169,11 @@ class unified_bed_leveling {
169169 static xy_uint8_t cell_indexes (const xy_pos_t &xy) { return cell_indexes (xy.x , xy.y ); }
170170
171171 static int8_t closest_x_index (const float x) {
172- const int8_t px = (x - ( MESH_MIN_X ) + (MESH_X_DIST ) * 0.5 ) * RECIPROCAL (MESH_X_DIST );
172+ const int8_t px = (x - mesh_min. x + (MESH_X_DIST ) * 0.5 ) * RECIPROCAL (MESH_X_DIST );
173173 return WITHIN (px, 0 , (GRID_MAX_POINTS_X ) - 1 ) ? px : -1 ;
174174 }
175175 static int8_t closest_y_index (const float y) {
176- const int8_t py = (y - ( MESH_MIN_Y ) + (MESH_Y_DIST ) * 0.5 ) * RECIPROCAL (MESH_Y_DIST );
176+ const int8_t py = (y - mesh_min. y + (MESH_Y_DIST ) * 0.5 ) * RECIPROCAL (MESH_Y_DIST );
177177 return WITHIN (py, 0 , (GRID_MAX_POINTS_Y ) - 1 ) ? py : -1 ;
178178 }
179179 static xy_int8_t closest_indexes (const xy_pos_t &xy) {
@@ -266,7 +266,7 @@ class unified_bed_leveling {
266266 * UBL_Z_RAISE_WHEN_OFF_MESH is specified, that value is returned.
267267 */
268268 #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
269- if (!WITHIN (rx0, MESH_MIN_X , MESH_MAX_X ) || !WITHIN (ry0, MESH_MIN_Y , MESH_MAX_Y ))
269+ if (!WITHIN (rx0, mesh_min. x , mesh_max. x ) || !WITHIN (ry0, mesh_min. y , mesh_max. y ))
270270 return UBL_Z_RAISE_WHEN_OFF_MESH ;
271271 #endif
272272
@@ -294,22 +294,23 @@ class unified_bed_leveling {
294294
295295 static constexpr float get_z_offset () { return 0 .0f ; }
296296
297+ #if !ALL(PROUI_EX, PROUI_MESH_EDIT) || DISABLED(DWIN_LCD_PROUI)
298+ static float _get_mesh_x (const uint8_t i) { return mesh_min.x + i * (MESH_X_DIST ); }
299+ static float _get_mesh_y (const uint8_t j) { return mesh_min.y + j * (MESH_Y_DIST ); }
300+ #endif
301+
297302 #if ALL(PROUI_EX, PROUI_MESH_EDIT)
298303 static float get_mesh_x (const uint8_t i);
299304 static float get_mesh_y (const uint8_t j);
300- #elif ENABLED(PROUI_MESH_EDIT)
301- static float get_mesh_x (const uint8_t i) {
302- return MESH_MIN_X + i * (MESH_X_DIST );
303- }
304- static float get_mesh_y (const uint8_t j) {
305- return MESH_MIN_Y + j * (MESH_Y_DIST );
306- }
305+ #elif ENABLED(DWIN_LCD_PROUI)
306+ static float get_mesh_x (const uint8_t i) { return _get_mesh_x (i); }
307+ static float get_mesh_y (const uint8_t j) { return _get_mesh_y (j); }
307308 #else
308309 static float get_mesh_x (const uint8_t i) {
309- return i < (GRID_MAX_POINTS_X ) ? pgm_read_float (&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * ( MESH_X_DIST );
310+ return i < (GRID_MAX_POINTS_X ) ? pgm_read_float (&_mesh_index_to_xpos[i]) : _get_mesh_x (i );
310311 }
311312 static float get_mesh_y (const uint8_t j) {
312- return j < (GRID_MAX_POINTS_Y ) ? pgm_read_float (&_mesh_index_to_ypos[j]) : MESH_MIN_Y + j * ( MESH_Y_DIST );
313+ return j < (GRID_MAX_POINTS_Y ) ? pgm_read_float (&_mesh_index_to_ypos[j]) : _get_mesh_y (j );
313314 }
314315 #endif
315316
0 commit comments