Browse Source

Fix error checking in M421

Scott Lahteine 8 years ago
parent
commit
13175ce7da
2 changed files with 14 additions and 11 deletions
  1. 13
    10
      Marlin/Marlin_main.cpp
  2. 1
    1
      Marlin/language.h

+ 13
- 10
Marlin/Marlin_main.cpp View File

@@ -5851,19 +5851,22 @@ inline void gcode_M410() { stepper.quick_stop(); }
5851 5851
     if ((hasY = code_seen('Y'))) y = code_value();
5852 5852
     if ((hasZ = code_seen('Z'))) z = code_value();
5853 5853
 
5854
-    if (!hasX || !hasY || !hasZ) {
5855
-      SERIAL_ERROR_START;
5856
-      SERIAL_ERRORLNPGM(MSG_ERR_M421_REQUIRES_XYZ);
5857
-      err = true;
5858
-    }
5854
+    if (hasX && hasY && hasZ) {
5859 5855
 
5860
-    if (x >= MESH_NUM_X_POINTS || y >= MESH_NUM_Y_POINTS) {
5856
+      int8_t ix = mbl.select_x_index(x),
5857
+             iy = mbl.select_y_index(y);
5858
+
5859
+      if (ix >= 0 && iy >= 0)
5860
+        mbl.set_z(ix, iy, z);
5861
+      else {
5862
+        SERIAL_ERROR_START;
5863
+        SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
5864
+      }
5865
+    }
5866
+    else {
5861 5867
       SERIAL_ERROR_START;
5862
-      SERIAL_ERRORLNPGM(MSG_ERR_MESH_INDEX_OOB);
5863
-      err = true;
5868
+      SERIAL_ERRORLNPGM(MSG_ERR_M421_REQUIRES_XYZ);
5864 5869
     }
5865
-
5866
-    if (!err) mbl.set_z(mbl.select_x_index(x), mbl.select_y_index(y), z);
5867 5870
   }
5868 5871
 
5869 5872
 #endif

+ 1
- 1
Marlin/language.h View File

@@ -148,7 +148,7 @@
148 148
 #define MSG_Z_PROBE                         "z_probe: "
149 149
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
150 150
 #define MSG_ERR_M421_REQUIRES_XYZ           "M421 requires XYZ parameters"
151
-#define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
151
+#define MSG_ERR_MESH_XY                     "Mesh XY 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"
154 154
 #define MSG_M119_REPORT                     "Reporting endstop status"

Loading…
Cancel
Save