@@ -175,13 +175,13 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
175
175
xy_float_t LevelingBilinear::grid_factor_virt;
176
176
177
177
#define LINEAR_EXTRAPOLATION (E, I ) ((E) * 2 - (I))
178
- float LevelingBilinear::bed_level_virt_coord (const uint8_t x, const uint8_t y) {
178
+ float LevelingBilinear::virt_coord (const uint8_t x, const uint8_t y) {
179
179
uint8_t ep = 0 , ip = 1 ;
180
180
if (x > (GRID_MAX_POINTS_X) + 1 || y > (GRID_MAX_POINTS_Y) + 1 ) {
181
181
// The requested point requires extrapolating two points beyond the mesh.
182
182
// These values are only requested for the edges of the mesh, which are always an actual mesh point,
183
183
// and do not require interpolation. When interpolation is not needed, this "Mesh + 2" point is
184
- // cancelled out in bed_level_virt_cmr and does not impact the result. Return 0.0 rather than
184
+ // cancelled out in virt_cmr and does not impact the result. Return 0.0 rather than
185
185
// making this function more complex by extrapolating two points.
186
186
return 0.0 ;
187
187
}
@@ -197,8 +197,8 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
197
197
);
198
198
else
199
199
return LINEAR_EXTRAPOLATION (
200
- bed_level_virt_coord (ep + 1 , y),
201
- bed_level_virt_coord (ip + 1 , y)
200
+ virt_coord (ep + 1 , y),
201
+ virt_coord (ip + 1 , y)
202
202
);
203
203
}
204
204
if (!y || y == ABL_TEMP_POINTS_Y - 1 ) {
@@ -213,14 +213,14 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
213
213
);
214
214
else
215
215
return LINEAR_EXTRAPOLATION (
216
- bed_level_virt_coord (x, ep + 1 ),
217
- bed_level_virt_coord (x, ip + 1 )
216
+ virt_coord (x, ep + 1 ),
217
+ virt_coord (x, ip + 1 )
218
218
);
219
219
}
220
220
return z_values[x - 1 ][y - 1 ];
221
221
}
222
222
223
- float LevelingBilinear::bed_level_virt_cmr (const float p[4 ], const uint8_t i, const float t) {
223
+ float LevelingBilinear::virt_cmr (const float p[4 ], const uint8_t i, const float t) {
224
224
return (
225
225
p[i-1 ] * -t * sq (1 - t)
226
226
+ p[i] * (2 - 5 * sq (t) + 3 * t * sq (t))
@@ -229,18 +229,18 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
229
229
) * 0 .5f ;
230
230
}
231
231
232
- float LevelingBilinear::bed_level_virt_2cmr (const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) {
232
+ float LevelingBilinear::virt_2cmr (const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) {
233
233
float row[4 ], column[4 ];
234
234
LOOP_L_N (i, 4 ) {
235
235
LOOP_L_N (j, 4 ) {
236
- column[j] = bed_level_virt_coord (i + x - 1 , j + y - 1 );
236
+ column[j] = virt_coord (i + x - 1 , j + y - 1 );
237
237
}
238
- row[i] = bed_level_virt_cmr (column, 1 , ty);
238
+ row[i] = virt_cmr (column, 1 , ty);
239
239
}
240
- return bed_level_virt_cmr (row, 1 , tx);
240
+ return virt_cmr (row, 1 , tx);
241
241
}
242
242
243
- void LevelingBilinear::bed_level_virt_interpolate () {
243
+ void LevelingBilinear::subdivide_mesh () {
244
244
grid_spacing_virt = grid_spacing / (BILINEAR_SUBDIVISIONS);
245
245
grid_factor_virt = grid_spacing_virt.reciprocal ();
246
246
LOOP_L_N (y, GRID_MAX_POINTS_Y)
@@ -250,20 +250,15 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
250
250
if ((ty && y == (GRID_MAX_POINTS_Y) - 1 ) || (tx && x == (GRID_MAX_POINTS_X) - 1 ))
251
251
continue ;
252
252
z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
253
- bed_level_virt_2cmr (
254
- x + 1 ,
255
- y + 1 ,
256
- (float )tx / (BILINEAR_SUBDIVISIONS),
257
- (float )ty / (BILINEAR_SUBDIVISIONS)
258
- );
253
+ virt_2cmr (x + 1 , y + 1 , (float )tx / (BILINEAR_SUBDIVISIONS), (float )ty / (BILINEAR_SUBDIVISIONS));
259
254
}
260
255
}
261
256
262
257
#endif // ABL_BILINEAR_SUBDIVISION
263
258
264
259
// Refresh after other values have been updated
265
260
void LevelingBilinear::refresh_bed_level () {
266
- TERN_ (ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate ());
261
+ TERN_ (ABL_BILINEAR_SUBDIVISION, subdivide_mesh ());
267
262
cached_rel.x = cached_rel.y = -999.999 ;
268
263
cached_g.x = cached_g.y = -99 ;
269
264
}
0 commit comments