Browse Source

Change M421 to take coordinates

This makes `M421` more amenable for irregular matrices
Scott Lahteine 9 years ago
parent
commit
ff178d8cf7

+ 6
- 7
Marlin/Marlin_main.cpp View File

188
  * M407 - Display measured filament diameter
188
  * M407 - Display measured filament diameter
189
  * M410 - Quickstop. Abort all the planned moves
189
  * M410 - Quickstop. Abort all the planned moves
190
  * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable
190
  * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable
191
- * M421 - Set a single Z coordinate in the Mesh Leveling grid. X<index> Y<index> Z<offset in mm>
191
+ * M421 - Set a single Z coordinate in the Mesh Leveling grid. X<mm> Y<mm> Z<mm>
192
  * M500 - Store parameters in EEPROM
192
  * M500 - Store parameters in EEPROM
193
  * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
193
  * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
194
  * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
194
  * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
4467
    * M421: Set a single Mesh Bed Leveling Z coordinate
4467
    * M421: Set a single Mesh Bed Leveling Z coordinate
4468
    */
4468
    */
4469
   inline void gcode_M421() {
4469
   inline void gcode_M421() {
4470
-    int x, y;
4471
-    float z;
4470
+    float x, y, z;
4472
     bool err = false, hasX, hasY, hasZ;
4471
     bool err = false, hasX, hasY, hasZ;
4473
-    if ((hasX = code_seen('X'))) x = code_value_short();
4474
-    if ((hasY = code_seen('Y'))) y = code_value_short();
4472
+    if ((hasX = code_seen('X'))) x = code_value();
4473
+    if ((hasY = code_seen('Y'))) y = code_value();
4475
     if ((hasZ = code_seen('Z'))) z = code_value();
4474
     if ((hasZ = code_seen('Z'))) z = code_value();
4476
 
4475
 
4477
     if (!hasX || !hasY || !hasZ) {
4476
     if (!hasX || !hasY || !hasZ) {
4478
       SERIAL_ERROR_START;
4477
       SERIAL_ERROR_START;
4479
-      SERIAL_ERRORLNPGM(MSG_ERR_XYZ_REQUIRED_FOR_M421);
4478
+      SERIAL_ERRORLNPGM(MSG_ERR_M421_REQUIRES_XYZ);
4480
       err = true;
4479
       err = true;
4481
     }
4480
     }
4482
 
4481
 
4486
       err = true;
4485
       err = true;
4487
     }
4486
     }
4488
 
4487
 
4489
-    if (!err) mbl.z_values[y][x] = z;
4488
+    if (!err) mbl.set_z(select_x_index(x), select_y_index(y), z);
4490
   }
4489
   }
4491
 
4490
 
4492
 #endif
4491
 #endif

+ 5
- 7
Marlin/configuration_store.cpp View File

96
 #include "configuration_store.h"
96
 #include "configuration_store.h"
97
 
97
 
98
 #ifdef MESH_BED_LEVELING
98
 #ifdef MESH_BED_LEVELING
99
-   #include "mesh_bed_leveling.h"
100
-#endif  // MESH_BED_LEVELING
99
+  #include "mesh_bed_leveling.h"
100
+#endif
101
 
101
 
102
 void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
102
 void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
103
   uint8_t c;
103
   uint8_t c;
168
     EEPROM_WRITE_VAR(i, mesh_num_x);
168
     EEPROM_WRITE_VAR(i, mesh_num_x);
169
     EEPROM_WRITE_VAR(i, mesh_num_y);
169
     EEPROM_WRITE_VAR(i, mesh_num_y);
170
     dummy = 0.0f;
170
     dummy = 0.0f;
171
-    for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
172
-      EEPROM_WRITE_VAR(i, dummy);
173
-    }
171
+    for (int q=0; q<mesh_num_x*mesh_num_y; q++) EEPROM_WRITE_VAR(i, dummy);
174
   #endif // MESH_BED_LEVELING
172
   #endif // MESH_BED_LEVELING
175
 
173
 
176
   #ifndef ENABLE_AUTO_BED_LEVELING
174
   #ifndef ENABLE_AUTO_BED_LEVELING
685
     for (int y=0; y<MESH_NUM_Y_POINTS; y++) {
683
     for (int y=0; y<MESH_NUM_Y_POINTS; y++) {
686
       for (int x=0; x<MESH_NUM_X_POINTS; x++) {
684
       for (int x=0; x<MESH_NUM_X_POINTS; x++) {
687
         CONFIG_ECHO_START;
685
         CONFIG_ECHO_START;
688
-        SERIAL_ECHOPAIR("  M421 X", x);
689
-        SERIAL_ECHOPAIR(" Y", y);
686
+        SERIAL_ECHOPAIR("  M421 X", mbl.get_x(x));
687
+        SERIAL_ECHOPAIR(" Y", mbl.get_y(y));
690
         SERIAL_ECHOPAIR(" Z", mbl.z_values[y][x]);
688
         SERIAL_ECHOPAIR(" Z", mbl.z_values[y][x]);
691
         SERIAL_EOL;
689
         SERIAL_EOL;
692
       }
690
       }

+ 1
- 1
Marlin/configurator/config/language.h View File

159
 #define MSG_Z2_MAX                          "z2_max: "
159
 #define MSG_Z2_MAX                          "z2_max: "
160
 #define MSG_Z_PROBE                         "z_probe: "
160
 #define MSG_Z_PROBE                         "z_probe: "
161
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
161
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
162
-#define MSG_ERR_XYZ_REQUIRED_FOR_M421       "M421 requires XYZ parameters"
162
+#define MSG_ERR_M421_REQUIRES_XYZ           "M421 requires XYZ parameters"
163
 #define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
163
 #define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
164
 #define MSG_M119_REPORT                     "Reporting endstop status"
164
 #define MSG_M119_REPORT                     "Reporting endstop status"
165
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"
165
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"

+ 1
- 1
Marlin/language.h View File

159
 #define MSG_Z2_MAX                          "z2_max: "
159
 #define MSG_Z2_MAX                          "z2_max: "
160
 #define MSG_Z_PROBE                         "z_probe: "
160
 #define MSG_Z_PROBE                         "z_probe: "
161
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
161
 #define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
162
-#define MSG_ERR_XYZ_REQUIRED_FOR_M421       "M421 requires XYZ parameters"
162
+#define MSG_ERR_M421_REQUIRES_XYZ           "M421 requires XYZ parameters"
163
 #define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
163
 #define MSG_ERR_MESH_INDEX_OOB              "Mesh XY index is out of bounds"
164
 #define MSG_M119_REPORT                     "Reporting endstop status"
164
 #define MSG_M119_REPORT                     "Reporting endstop status"
165
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"
165
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"

Loading…
Cancel
Save