Browse Source

Add M421 for ABL Bilinear

Scott Lahteine 8 years ago
parent
commit
6d7b1cdf6c
2 changed files with 36 additions and 2 deletions
  1. 34
    0
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/language.h

+ 34
- 0
Marlin/Marlin_main.cpp View File

@@ -7106,6 +7106,40 @@ void quickstop_stepper() {
7106 7106
     }
7107 7107
   }
7108 7108
 
7109
+#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7110
+
7111
+  /**
7112
+   * M421: Set a single Mesh Bed Leveling Z coordinate
7113
+   *
7114
+   *   M421 I<xindex> J<yindex> Z<linear>
7115
+   */
7116
+  inline void gcode_M421() {
7117
+    int8_t px = 0, py = 0;
7118
+    float z = 0;
7119
+    bool hasI, hasJ, hasZ;
7120
+    if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS);
7121
+    if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS);
7122
+    if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
7123
+
7124
+    if (hasI && hasJ && hasZ) {
7125
+      if (px >= 0 && px < ABL_GRID_MAX_POINTS_X && py >= 0 && py < ABL_GRID_MAX_POINTS_X) {
7126
+        bed_level_grid[px][py] = z;
7127
+        #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7128
+          bed_level_virt_prepare();
7129
+          bed_level_virt_interpolate();
7130
+        #endif
7131
+      }
7132
+      else {
7133
+        SERIAL_ERROR_START;
7134
+        SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
7135
+      }
7136
+    }
7137
+    else {
7138
+      SERIAL_ERROR_START;
7139
+      SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
7140
+    }
7141
+  }
7142
+
7109 7143
 #endif
7110 7144
 
7111 7145
 /**

+ 2
- 2
Marlin/language.h View File

@@ -153,8 +153,8 @@
153 153
 #define MSG_Z2_MAX                          "z2_max: "
154 154
 #define MSG_Z_PROBE                         "z_probe: "
155 155
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
156
-#define MSG_ERR_M421_PARAMETERS             "M421 requires XYZ or IJZ parameters"
157
-#define MSG_ERR_MESH_XY                     "Mesh XY or IJ cannot be resolved"
156
+#define MSG_ERR_M421_PARAMETERS             "M421 required parameters missing"
157
+#define MSG_ERR_MESH_XY                     "Mesh point cannot be resolved"
158 158
 #define MSG_ERR_ARC_ARGS                    "G2/G3 bad parameters"
159 159
 #define MSG_ERR_PROTECTED_PIN               "Protected Pin"
160 160
 #define MSG_ERR_M420_FAILED                 "Failed to enable Bed Leveling"

Loading…
Cancel
Save