Browse Source

Small reduction in M421 code

Scott Lahteine 8 years ago
parent
commit
360adc6a3b
2 changed files with 8 additions and 11 deletions
  1. 7
    10
      Marlin/Marlin_main.cpp
  2. 1
    1
      Marlin/language.h

+ 7
- 10
Marlin/Marlin_main.cpp View File

@@ -5904,20 +5904,17 @@ inline void gcode_M410() { stepper.quick_stop(); }
5904 5904
    * Use either 'M421 X<mm> Y<mm> Z<mm>' or 'M421 I<xindex> J<yindex> Z<mm>'
5905 5905
    */
5906 5906
   inline void gcode_M421() {
5907
-    float x = 0, y = 0, z = 0;
5908
-    int8_t px = 0, py = 0;
5909
-    bool err = false, hasX, hasY, hasZ, hasI, hasJ;
5910
-    if ((hasX = code_seen('X'))) x = code_value();
5911
-    if ((hasY = code_seen('Y'))) y = code_value();
5912
-    if ((hasZ = code_seen('Z'))) z = code_value();
5907
+    int8_t px, py;
5908
+    float z = 0;
5909
+    bool hasX, hasY, hasZ, hasI, hasJ;
5910
+    if ((hasX = code_seen('X'))) px = mbl.probe_index_x(code_value());
5911
+    if ((hasY = code_seen('Y'))) py = mbl.probe_index_y(code_value());
5913 5912
     if ((hasI = code_seen('I'))) px = code_value();
5914 5913
     if ((hasJ = code_seen('J'))) py = code_value();
5914
+    if ((hasZ = code_seen('Z'))) z = code_value();
5915 5915
 
5916 5916
     if (hasX && hasY && hasZ) {
5917 5917
 
5918
-      px = mbl.probe_index_x(x);
5919
-      py = mbl.probe_index_y(y);
5920
-
5921 5918
       if (px >= 0 && py >= 0)
5922 5919
         mbl.set_z(px, py, z);
5923 5920
       else {
@@ -5935,7 +5932,7 @@ inline void gcode_M410() { stepper.quick_stop(); }
5935 5932
     }
5936 5933
     else {
5937 5934
       SERIAL_ERROR_START;
5938
-      SERIAL_ERRORLNPGM(MSG_ERR_M421_REQUIRES_XYZ);
5935
+      SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
5939 5936
     }
5940 5937
   }
5941 5938
 

+ 1
- 1
Marlin/language.h View File

@@ -147,7 +147,7 @@
147 147
 #define MSG_Z2_MAX                          "z2_max: "
148 148
 #define MSG_Z_PROBE                         "z_probe: "
149 149
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
150
-#define MSG_ERR_M421_REQUIRES_XYZ           "M421 requires XYZ or IJZ parameters"
150
+#define MSG_ERR_M421_PARAMETERS             "M421 requires XYZ or IJZ parameters"
151 151
 #define MSG_ERR_MESH_XY                     "Mesh XY or IJ cannot be resolved"
152 152
 #define MSG_ERR_M428_TOO_FAR                "Too far from reference point"
153 153
 #define MSG_ERR_M303_DISABLED               "PIDTEMP disabled"

Loading…
Cancel
Save