diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b281595ba2..c7f6841e3a 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7106,6 +7106,40 @@ void quickstop_stepper() { } } +#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) + + /** + * M421: Set a single Mesh Bed Leveling Z coordinate + * + * M421 I J Z + */ + inline void gcode_M421() { + int8_t px = 0, py = 0; + float z = 0; + bool hasI, hasJ, hasZ; + if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS); + if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS); + if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS); + + if (hasI && hasJ && hasZ) { + if (px >= 0 && px < ABL_GRID_MAX_POINTS_X && py >= 0 && py < ABL_GRID_MAX_POINTS_X) { + bed_level_grid[px][py] = z; + #if ENABLED(ABL_BILINEAR_SUBDIVISION) + bed_level_virt_prepare(); + bed_level_virt_interpolate(); + #endif + } + else { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY); + } + } + else { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS); + } + } + #endif /** diff --git a/Marlin/language.h b/Marlin/language.h index 322db7617a..27bfaed64e 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -153,8 +153,8 @@ #define MSG_Z2_MAX "z2_max: " #define MSG_Z_PROBE "z_probe: " #define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" -#define MSG_ERR_M421_PARAMETERS "M421 requires XYZ or IJZ parameters" -#define MSG_ERR_MESH_XY "Mesh XY or IJ cannot be resolved" +#define MSG_ERR_M421_PARAMETERS "M421 required parameters missing" +#define MSG_ERR_MESH_XY "Mesh point cannot be resolved" #define MSG_ERR_ARC_ARGS "G2/G3 bad parameters" #define MSG_ERR_PROTECTED_PIN "Protected Pin" #define MSG_ERR_M420_FAILED "Failed to enable Bed Leveling"