Browse Source

Let M421 C select any point

Fixing #21147
vanilla_fb_2.0.x
Scott Lahteine 3 years ago
parent
commit
94edfc0a8f
  1. 2
      Marlin/src/feature/bedlevel/ubl/ubl.h
  2. 4
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  3. 2
      Marlin/src/gcode/bedlevel/ubl/M421.cpp

2
Marlin/src/feature/bedlevel/ubl/ubl.h

@ -32,7 +32,7 @@
#define UBL_OK false
#define UBL_ERR true
enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP, CLOSEST };
// External references

4
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

@ -1282,7 +1282,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
static bool test_func(uint8_t i, uint8_t j, void *data) {
find_closest_t *d = (find_closest_t*)data;
if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL))
if ( d->type == CLOSEST || d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL)
|| (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j))
) {
// Found a Mesh Point of the specified type!
@ -1326,7 +1326,7 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh
float best_so_far = 99999.99f;
GRID_LOOP(i, j) {
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
if ( type == CLOSEST || type == (isnan(z_values[i][j]) ? INVALID : REAL)
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
) {
// Found a Mesh Point of the specified type!

2
Marlin/src/gcode/bedlevel/ubl/M421.cpp

@ -54,7 +54,7 @@ void GcodeSuite::M421() {
hasZ = parser.seen('Z'),
hasQ = !hasZ && parser.seen('Q');
if (hasC) ij = ubl.find_closest_mesh_point_of_type(REAL, current_position);
if (hasC) ij = ubl.find_closest_mesh_point_of_type(CLOSEST, current_position);
if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ || hasN))
SERIAL_ERROR_MSG(STR_ERR_M421_PARAMETERS);

Loading…
Cancel
Save