Browse Source

Merge pull request #6315 from thinkyhead/rc_unify_M421

Unify M421
Scott Lahteine 8 years ago
parent
commit
4022b971db

+ 10
- 33
Marlin/Marlin_main.cpp View File

3817
     SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
3817
     SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
3818
     SERIAL_PROTOCOLLNPGM("\nMeasured points:");
3818
     SERIAL_PROTOCOLLNPGM("\nMeasured points:");
3819
     print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
3819
     print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
3820
-      [](const uint8_t ix, const uint8_t iy) { return mbl.z_values[iy][ix]; }
3820
+      [](const uint8_t ix, const uint8_t iy) { return mbl.z_values[ix][iy]; }
3821
     );
3821
     );
3822
   }
3822
   }
3823
 
3823
 
3948
         }
3948
         }
3949
 
3949
 
3950
         if (code_seen('Z')) {
3950
         if (code_seen('Z')) {
3951
-          mbl.z_values[py][px] = code_value_axis_units(Z_AXIS);
3951
+          mbl.z_values[px][py] = code_value_axis_units(Z_AXIS);
3952
         }
3952
         }
3953
         else {
3953
         else {
3954
           SERIAL_CHAR('Z'); say_not_entered();
3954
           SERIAL_CHAR('Z'); say_not_entered();
7844
     }
7844
     }
7845
   }
7845
   }
7846
 
7846
 
7847
-#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7847
+#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL)
7848
 
7848
 
7849
   /**
7849
   /**
7850
    * M421: Set a single Mesh Bed Leveling Z coordinate
7850
    * M421: Set a single Mesh Bed Leveling Z coordinate
7861
 
7861
 
7862
     if (hasI && hasJ && hasZ) {
7862
     if (hasI && hasJ && hasZ) {
7863
       if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_X - 1)) {
7863
       if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_X - 1)) {
7864
-        bed_level_grid[px][py] = z;
7865
-        #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7866
-          bed_level_virt_interpolate();
7864
+        #if ENABLED(AUTO_BED_LEVELING_UBL)
7865
+          ubl.z_values[px][py] = z;
7866
+        #else
7867
+          bed_level_grid[px][py] = z;
7868
+          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7869
+            bed_level_virt_interpolate();
7870
+          #endif
7867
         #endif
7871
         #endif
7868
       }
7872
       }
7869
       else {
7873
       else {
7876
       SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
7880
       SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
7877
     }
7881
     }
7878
   }
7882
   }
7879
-#elif ENABLED(AUTO_BED_LEVELING_UBL)
7880
-  /**
7881
-   * M421: Set a single Mesh Bed Leveling Z coordinate
7882
-   *
7883
-   *   M421 I<xindex> J<yindex> Z<linear>
7884
-   */
7885
-  inline void gcode_M421() {
7886
-    int8_t px = 0, py = 0;
7887
-    float z = 0;
7888
-    bool hasI, hasJ, hasZ;
7889
-    if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS);
7890
-    if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS);
7891
-    if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
7892
 
7883
 
7893
-    if (hasI && hasJ && hasZ) {
7894
-      if (WITHIN(px, 0, GRID_MAX_POINTS_Y - 1) && WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
7895
-        ubl.z_values[px][py] = z;
7896
-      }
7897
-      else {
7898
-        SERIAL_ERROR_START;
7899
-        SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
7900
-      }
7901
-    }
7902
-    else {
7903
-      SERIAL_ERROR_START;
7904
-      SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
7905
-    }
7906
-  }
7907
 #endif
7884
 #endif
7908
 
7885
 
7909
 #if DISABLED(NO_WORKSPACE_OFFSETS)
7886
 #if DISABLED(NO_WORKSPACE_OFFSETS)

+ 6
- 6
Marlin/configuration_store.cpp View File

36
  *
36
  *
37
  */
37
  */
38
 
38
 
39
-#define EEPROM_VERSION "V33"
39
+#define EEPROM_VERSION "V34"
40
 
40
 
41
 // Change EEPROM version if these are changed:
41
 // Change EEPROM version if these are changed:
42
 #define EEPROM_OFFSET 100
42
 #define EEPROM_OFFSET 100
1267
         SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height);
1267
         SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height);
1268
       #endif
1268
       #endif
1269
       SERIAL_EOL;
1269
       SERIAL_EOL;
1270
-      for (uint8_t py = 1; py <= GRID_MAX_POINTS_Y; py++) {
1271
-        for (uint8_t px = 1; px <= GRID_MAX_POINTS_X; px++) {
1270
+      for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
1271
+        for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
1272
           CONFIG_ECHO_START;
1272
           CONFIG_ECHO_START;
1273
-          SERIAL_ECHOPAIR("  G29 S3 X", (int)px);
1274
-          SERIAL_ECHOPAIR(" Y", (int)py);
1273
+          SERIAL_ECHOPAIR("  G29 S3 X", (int)px + 1);
1274
+          SERIAL_ECHOPAIR(" Y", (int)py + 1);
1275
           SERIAL_ECHOPGM(" Z");
1275
           SERIAL_ECHOPGM(" Z");
1276
-          SERIAL_PROTOCOL_F(mbl.z_values[py-1][px-1], 5);
1276
+          SERIAL_PROTOCOL_F(mbl.z_values[px][py], 5);
1277
           SERIAL_EOL;
1277
           SERIAL_EOL;
1278
         }
1278
         }
1279
       }
1279
       }

+ 1
- 1
Marlin/mesh_bed_leveling.cpp View File

29
   uint8_t mesh_bed_leveling::status;
29
   uint8_t mesh_bed_leveling::status;
30
 
30
 
31
   float mesh_bed_leveling::z_offset,
31
   float mesh_bed_leveling::z_offset,
32
-        mesh_bed_leveling::z_values[GRID_MAX_POINTS_Y][GRID_MAX_POINTS_X],
32
+        mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
33
         mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
33
         mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
34
         mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];
34
         mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];
35
 
35
 

+ 4
- 4
Marlin/mesh_bed_leveling.h View File

47
   public:
47
   public:
48
     static uint8_t status; // Has Mesh and Is Active bits
48
     static uint8_t status; // Has Mesh and Is Active bits
49
     static float z_offset,
49
     static float z_offset,
50
-                 z_values[GRID_MAX_POINTS_Y][GRID_MAX_POINTS_X],
50
+                 z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
51
                  index_to_xpos[GRID_MAX_POINTS_X],
51
                  index_to_xpos[GRID_MAX_POINTS_X],
52
                  index_to_ypos[GRID_MAX_POINTS_Y];
52
                  index_to_ypos[GRID_MAX_POINTS_Y];
53
 
53
 
55
 
55
 
56
     static void reset();
56
     static void reset();
57
 
57
 
58
-    static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[py][px] = z; }
58
+    static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
59
 
59
 
60
     static bool active()                       { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
60
     static bool active()                       { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
61
     static void set_active(const bool onOff)   { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
61
     static void set_active(const bool onOff)   { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
108
       #endif
108
       #endif
109
     ) {
109
     ) {
110
       const int8_t cx = cell_index_x(x0), cy = cell_index_y(y0);
110
       const int8_t cx = cell_index_x(x0), cy = cell_index_y(y0);
111
-      const float z1 = calc_z0(x0, index_to_xpos[cx], z_values[cy][cx], index_to_xpos[cx + 1], z_values[cy][cx + 1]),
112
-                  z2 = calc_z0(x0, index_to_xpos[cx], z_values[cy + 1][cx], index_to_xpos[cx + 1], z_values[cy + 1][cx + 1]),
111
+      const float z1 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy], index_to_xpos[cx + 1], z_values[cx + 1][cy]),
112
+                  z2 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy + 1], index_to_xpos[cx + 1], z_values[cx + 1][cy + 1]),
113
                   z0 = calc_z0(y0, index_to_ypos[cy], z1, index_to_ypos[cy + 1], z2);
113
                   z0 = calc_z0(y0, index_to_ypos[cy], z1, index_to_ypos[cy + 1], z2);
114
 
114
 
115
       return z_offset + z0
115
       return z_offset + z0

Loading…
Cancel
Save