From 360adc6a3bffb636e65535e9bd90cf85a66214f3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 May 2016 19:06:27 -0700 Subject: [PATCH] Small reduction in M421 code --- Marlin/Marlin_main.cpp | 17 +++++++---------- Marlin/language.h | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 736de5ac9..b3c302d49 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5904,20 +5904,17 @@ inline void gcode_M410() { stepper.quick_stop(); } * Use either 'M421 X Y Z' or 'M421 I J Z' */ inline void gcode_M421() { - float x = 0, y = 0, z = 0; - int8_t px = 0, py = 0; - bool err = false, hasX, hasY, hasZ, hasI, hasJ; - if ((hasX = code_seen('X'))) x = code_value(); - if ((hasY = code_seen('Y'))) y = code_value(); - if ((hasZ = code_seen('Z'))) z = code_value(); + int8_t px, py; + float z = 0; + bool hasX, hasY, hasZ, hasI, hasJ; + if ((hasX = code_seen('X'))) px = mbl.probe_index_x(code_value()); + if ((hasY = code_seen('Y'))) py = mbl.probe_index_y(code_value()); if ((hasI = code_seen('I'))) px = code_value(); if ((hasJ = code_seen('J'))) py = code_value(); + if ((hasZ = code_seen('Z'))) z = code_value(); if (hasX && hasY && hasZ) { - px = mbl.probe_index_x(x); - py = mbl.probe_index_y(y); - if (px >= 0 && py >= 0) mbl.set_z(px, py, z); else { @@ -5935,7 +5932,7 @@ inline void gcode_M410() { stepper.quick_stop(); } } else { SERIAL_ERROR_START; - SERIAL_ERRORLNPGM(MSG_ERR_M421_REQUIRES_XYZ); + SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS); } } diff --git a/Marlin/language.h b/Marlin/language.h index 6ef215415..edef06be1 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -147,7 +147,7 @@ #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_REQUIRES_XYZ "M421 requires XYZ or IJZ parameters" +#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_M428_TOO_FAR "Too far from reference point" #define MSG_ERR_M303_DISABLED "PIDTEMP disabled"