Merge pull request #6315 from thinkyhead/rc_unify_M421

Unify M421
This commit is contained in:
Scott Lahteine 2017-04-12 19:43:28 -05:00 committed by GitHub
commit 4022b971db
4 changed files with 21 additions and 44 deletions

View file

@ -3817,7 +3817,7 @@ inline void gcode_G28() {
SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5); SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
SERIAL_PROTOCOLLNPGM("\nMeasured points:"); SERIAL_PROTOCOLLNPGM("\nMeasured points:");
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5, print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
[](const uint8_t ix, const uint8_t iy) { return mbl.z_values[iy][ix]; } [](const uint8_t ix, const uint8_t iy) { return mbl.z_values[ix][iy]; }
); );
} }
@ -3948,7 +3948,7 @@ inline void gcode_G28() {
} }
if (code_seen('Z')) { if (code_seen('Z')) {
mbl.z_values[py][px] = code_value_axis_units(Z_AXIS); mbl.z_values[px][py] = code_value_axis_units(Z_AXIS);
} }
else { else {
SERIAL_CHAR('Z'); say_not_entered(); SERIAL_CHAR('Z'); say_not_entered();
@ -7844,7 +7844,7 @@ void quickstop_stepper() {
} }
} }
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL)
/** /**
* M421: Set a single Mesh Bed Leveling Z coordinate * M421: Set a single Mesh Bed Leveling Z coordinate
@ -7861,9 +7861,13 @@ void quickstop_stepper() {
if (hasI && hasJ && hasZ) { if (hasI && hasJ && hasZ) {
if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_X - 1)) { if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_X - 1)) {
bed_level_grid[px][py] = z; #if ENABLED(AUTO_BED_LEVELING_UBL)
#if ENABLED(ABL_BILINEAR_SUBDIVISION) ubl.z_values[px][py] = z;
bed_level_virt_interpolate(); #else
bed_level_grid[px][py] = z;
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
bed_level_virt_interpolate();
#endif
#endif #endif
} }
else { else {
@ -7876,34 +7880,7 @@ void quickstop_stepper() {
SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS); SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
} }
} }
#elif ENABLED(AUTO_BED_LEVELING_UBL)
/**
* M421: Set a single Mesh Bed Leveling Z coordinate
*
* M421 I<xindex> J<yindex> Z<linear>
*/
inline void gcode_M421() {
int8_t px = 0, py = 0;
float z = 0;
bool hasI, hasJ, hasZ;
if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS);
if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS);
if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
if (hasI && hasJ && hasZ) {
if (WITHIN(px, 0, GRID_MAX_POINTS_Y - 1) && WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
ubl.z_values[px][py] = z;
}
else {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
}
}
else {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
}
}
#endif #endif
#if DISABLED(NO_WORKSPACE_OFFSETS) #if DISABLED(NO_WORKSPACE_OFFSETS)

View file

@ -36,7 +36,7 @@
* *
*/ */
#define EEPROM_VERSION "V33" #define EEPROM_VERSION "V34"
// Change EEPROM version if these are changed: // Change EEPROM version if these are changed:
#define EEPROM_OFFSET 100 #define EEPROM_OFFSET 100
@ -1267,13 +1267,13 @@ void MarlinSettings::reset() {
SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height); SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height);
#endif #endif
SERIAL_EOL; SERIAL_EOL;
for (uint8_t py = 1; py <= GRID_MAX_POINTS_Y; py++) { for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
for (uint8_t px = 1; px <= GRID_MAX_POINTS_X; px++) { for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" G29 S3 X", (int)px); SERIAL_ECHOPAIR(" G29 S3 X", (int)px + 1);
SERIAL_ECHOPAIR(" Y", (int)py); SERIAL_ECHOPAIR(" Y", (int)py + 1);
SERIAL_ECHOPGM(" Z"); SERIAL_ECHOPGM(" Z");
SERIAL_PROTOCOL_F(mbl.z_values[py-1][px-1], 5); SERIAL_PROTOCOL_F(mbl.z_values[px][py], 5);
SERIAL_EOL; SERIAL_EOL;
} }
} }

View file

@ -29,7 +29,7 @@
uint8_t mesh_bed_leveling::status; uint8_t mesh_bed_leveling::status;
float mesh_bed_leveling::z_offset, float mesh_bed_leveling::z_offset,
mesh_bed_leveling::z_values[GRID_MAX_POINTS_Y][GRID_MAX_POINTS_X], mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X], mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y]; mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];

View file

@ -47,7 +47,7 @@
public: public:
static uint8_t status; // Has Mesh and Is Active bits static uint8_t status; // Has Mesh and Is Active bits
static float z_offset, static float z_offset,
z_values[GRID_MAX_POINTS_Y][GRID_MAX_POINTS_X], z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
index_to_xpos[GRID_MAX_POINTS_X], index_to_xpos[GRID_MAX_POINTS_X],
index_to_ypos[GRID_MAX_POINTS_Y]; index_to_ypos[GRID_MAX_POINTS_Y];
@ -55,7 +55,7 @@
static void reset(); static void reset();
static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[py][px] = z; } static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
static bool active() { return TEST(status, MBL_STATUS_ACTIVE_BIT); } static bool active() { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
static void set_active(const bool onOff) { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); } static void set_active(const bool onOff) { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
@ -108,8 +108,8 @@
#endif #endif
) { ) {
const int8_t cx = cell_index_x(x0), cy = cell_index_y(y0); const int8_t cx = cell_index_x(x0), cy = cell_index_y(y0);
const float z1 = calc_z0(x0, index_to_xpos[cx], z_values[cy][cx], index_to_xpos[cx + 1], z_values[cy][cx + 1]), const float z1 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy], index_to_xpos[cx + 1], z_values[cx + 1][cy]),
z2 = calc_z0(x0, index_to_xpos[cx], z_values[cy + 1][cx], index_to_xpos[cx + 1], z_values[cy + 1][cx + 1]), z2 = calc_z0(x0, index_to_xpos[cx], z_values[cx][cy + 1], index_to_xpos[cx + 1], z_values[cx + 1][cy + 1]),
z0 = calc_z0(y0, index_to_ypos[cy], z1, index_to_ypos[cy + 1], z2); z0 = calc_z0(y0, index_to_ypos[cy], z1, index_to_ypos[cy + 1], z2);
return z_offset + z0 return z_offset + z0