Merge pull request #3446 from thinkyhead/rc_fixup_M206_and_mesh
Fix home_offset handling and account for it in G29
This commit is contained in:
commit
c5a2ce4366
|
@ -2847,7 +2847,7 @@ inline void gcode_G28() {
|
||||||
}
|
}
|
||||||
if (probe_point == 0) {
|
if (probe_point == 0) {
|
||||||
// Set Z to a positive value before recording the first Z.
|
// Set Z to a positive value before recording the first Z.
|
||||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + home_offset[Z_AXIS];
|
||||||
sync_plan_position();
|
sync_plan_position();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2856,7 +2856,7 @@ inline void gcode_G28() {
|
||||||
iy = (probe_point - 1) / (MESH_NUM_X_POINTS);
|
iy = (probe_point - 1) / (MESH_NUM_X_POINTS);
|
||||||
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
||||||
mbl.set_z(ix, iy, current_position[Z_AXIS]);
|
mbl.set_z(ix, iy, current_position[Z_AXIS]);
|
||||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + home_offset[Z_AXIS];
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 60, active_extruder);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 60, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
}
|
}
|
||||||
|
@ -2865,8 +2865,8 @@ inline void gcode_G28() {
|
||||||
ix = probe_point % (MESH_NUM_X_POINTS);
|
ix = probe_point % (MESH_NUM_X_POINTS);
|
||||||
iy = probe_point / (MESH_NUM_X_POINTS);
|
iy = probe_point / (MESH_NUM_X_POINTS);
|
||||||
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
||||||
current_position[X_AXIS] = mbl.get_x(ix);
|
current_position[X_AXIS] = mbl.get_x(ix) + home_offset[X_AXIS];
|
||||||
current_position[Y_AXIS] = mbl.get_y(iy);
|
current_position[Y_AXIS] = mbl.get_y(iy) + home_offset[Y_AXIS];
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 60, active_extruder);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 60, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
probe_point++;
|
probe_point++;
|
||||||
|
@ -3155,7 +3155,7 @@ inline void gcode_G28() {
|
||||||
|
|
||||||
// raise extruder
|
// raise extruder
|
||||||
float measured_z,
|
float measured_z,
|
||||||
z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING;
|
z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS];
|
||||||
|
|
||||||
if (probePointCounter) {
|
if (probePointCounter) {
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
|
@ -3168,7 +3168,7 @@ inline void gcode_G28() {
|
||||||
else {
|
else {
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING)) {
|
if (DEBUGGING(LEVELING)) {
|
||||||
SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING);
|
SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS]);
|
||||||
SERIAL_EOL;
|
SERIAL_EOL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3329,9 +3329,18 @@ inline void gcode_G28() {
|
||||||
p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
|
p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
|
||||||
|
|
||||||
// Probe at 3 arbitrary points
|
// Probe at 3 arbitrary points
|
||||||
float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, verbose_level),
|
float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
|
||||||
z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, p2, verbose_level),
|
ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
|
||||||
z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, p3, verbose_level);
|
Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS],
|
||||||
|
p1, verbose_level),
|
||||||
|
z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
|
||||||
|
ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
|
||||||
|
current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
|
||||||
|
p2, verbose_level),
|
||||||
|
z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
|
||||||
|
ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
|
||||||
|
current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
|
||||||
|
p3, verbose_level);
|
||||||
clean_up_after_endstop_move();
|
clean_up_after_endstop_move();
|
||||||
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
||||||
|
|
||||||
|
@ -4986,19 +4995,26 @@ inline void gcode_M205() {
|
||||||
if (code_seen('E')) max_e_jerk = code_value();
|
if (code_seen('E')) max_e_jerk = code_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_home_offset(AxisEnum axis, float v) {
|
||||||
|
min_pos[axis] = base_min_pos(axis) + v;
|
||||||
|
max_pos[axis] = base_max_pos(axis) + v;
|
||||||
|
current_position[axis] += v - home_offset[axis];
|
||||||
|
home_offset[axis] = v;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
||||||
*/
|
*/
|
||||||
inline void gcode_M206() {
|
inline void gcode_M206() {
|
||||||
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
|
||||||
if (code_seen(axis_codes[i])) {
|
if (code_seen(axis_codes[i]))
|
||||||
home_offset[i] = code_value();
|
set_home_offset((AxisEnum)i, code_value());
|
||||||
}
|
|
||||||
}
|
|
||||||
#if ENABLED(SCARA)
|
#if ENABLED(SCARA)
|
||||||
if (code_seen('T')) home_offset[X_AXIS] = code_value(); // Theta
|
if (code_seen('T')) set_home_offset(X_AXIS, code_value()); // Theta
|
||||||
if (code_seen('P')) home_offset[Y_AXIS] = code_value(); // Psi
|
if (code_seen('P')) set_home_offset(Y_AXIS, code_value()); // Psi
|
||||||
#endif
|
#endif
|
||||||
|
sync_plan_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(DELTA)
|
#if ENABLED(DELTA)
|
||||||
|
@ -5685,16 +5701,12 @@ inline void gcode_M410() { quickStop(); }
|
||||||
*/
|
*/
|
||||||
inline void gcode_M428() {
|
inline void gcode_M428() {
|
||||||
bool err = false;
|
bool err = false;
|
||||||
float new_offs[3], new_pos[3];
|
|
||||||
memcpy(new_pos, current_position, sizeof(new_pos));
|
|
||||||
memcpy(new_offs, home_offset, sizeof(new_offs));
|
|
||||||
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
||||||
if (axis_homed[i]) {
|
if (axis_homed[i]) {
|
||||||
float base = (new_pos[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
|
float base = (current_position[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
|
||||||
diff = new_pos[i] - base;
|
diff = current_position[i] - base;
|
||||||
if (diff > -20 && diff < 20) {
|
if (diff > -20 && diff < 20) {
|
||||||
new_offs[i] -= diff;
|
set_home_offset((AxisEnum)i, home_offset[i] - diff);
|
||||||
new_pos[i] = base;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERIAL_ERROR_START;
|
SERIAL_ERROR_START;
|
||||||
|
@ -5710,8 +5722,6 @@ inline void gcode_M428() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
memcpy(current_position, new_pos, sizeof(new_pos));
|
|
||||||
memcpy(home_offset, new_offs, sizeof(new_offs));
|
|
||||||
sync_plan_position();
|
sync_plan_position();
|
||||||
LCD_ALERTMESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
|
LCD_ALERTMESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
|
||||||
#if HAS_BUZZER
|
#if HAS_BUZZER
|
||||||
|
@ -6980,10 +6990,10 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
||||||
set_current_to_destination();
|
set_current_to_destination();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pix = mbl.select_x_index(current_position[X_AXIS]);
|
int pix = mbl.select_x_index(current_position[X_AXIS] - home_offset[X_AXIS]);
|
||||||
int piy = mbl.select_y_index(current_position[Y_AXIS]);
|
int piy = mbl.select_y_index(current_position[Y_AXIS] - home_offset[Y_AXIS]);
|
||||||
int ix = mbl.select_x_index(x);
|
int ix = mbl.select_x_index(x - home_offset[X_AXIS]);
|
||||||
int iy = mbl.select_y_index(y);
|
int iy = mbl.select_y_index(y - home_offset[Y_AXIS]);
|
||||||
pix = min(pix, MESH_NUM_X_POINTS - 2);
|
pix = min(pix, MESH_NUM_X_POINTS - 2);
|
||||||
piy = min(piy, MESH_NUM_Y_POINTS - 2);
|
piy = min(piy, MESH_NUM_Y_POINTS - 2);
|
||||||
ix = min(ix, MESH_NUM_X_POINTS - 2);
|
ix = min(ix, MESH_NUM_X_POINTS - 2);
|
||||||
|
@ -6996,7 +7006,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
||||||
}
|
}
|
||||||
float nx, ny, nz, ne, normalized_dist;
|
float nx, ny, nz, ne, normalized_dist;
|
||||||
if (ix > pix && TEST(x_splits, ix)) {
|
if (ix > pix && TEST(x_splits, ix)) {
|
||||||
nx = mbl.get_x(ix);
|
nx = mbl.get_x(ix) + home_offset[X_AXIS];
|
||||||
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
||||||
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
||||||
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
||||||
|
@ -7004,7 +7014,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
||||||
CBI(x_splits, ix);
|
CBI(x_splits, ix);
|
||||||
}
|
}
|
||||||
else if (ix < pix && TEST(x_splits, pix)) {
|
else if (ix < pix && TEST(x_splits, pix)) {
|
||||||
nx = mbl.get_x(pix);
|
nx = mbl.get_x(pix) + home_offset[X_AXIS];
|
||||||
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
||||||
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
||||||
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
||||||
|
@ -7012,7 +7022,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
||||||
CBI(x_splits, pix);
|
CBI(x_splits, pix);
|
||||||
}
|
}
|
||||||
else if (iy > piy && TEST(y_splits, iy)) {
|
else if (iy > piy && TEST(y_splits, iy)) {
|
||||||
ny = mbl.get_y(iy);
|
ny = mbl.get_y(iy) + home_offset[Y_AXIS];
|
||||||
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
||||||
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
||||||
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
||||||
|
@ -7020,7 +7030,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
||||||
CBI(y_splits, iy);
|
CBI(y_splits, iy);
|
||||||
}
|
}
|
||||||
else if (iy < piy && TEST(y_splits, piy)) {
|
else if (iy < piy && TEST(y_splits, piy)) {
|
||||||
ny = mbl.get_y(piy);
|
ny = mbl.get_y(piy) + home_offset[Y_AXIS];
|
||||||
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
||||||
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
||||||
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
||||||
|
|
|
@ -568,7 +568,7 @@ float junction_deviation = 0.1;
|
||||||
while (block_buffer_tail == next_buffer_head) idle();
|
while (block_buffer_tail == next_buffer_head) idle();
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
if (mbl.active) z += mbl.get_z(x, y);
|
if (mbl.active) z += mbl.get_z(x - home_offset[X_AXIS], y - home_offset[Y_AXIS]);
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_FEATURE)
|
#elif ENABLED(AUTO_BED_LEVELING_FEATURE)
|
||||||
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
|
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1123,7 +1123,7 @@ float junction_deviation = 0.1;
|
||||||
#endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
|
#endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
|
||||||
{
|
{
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
if (mbl.active) z += mbl.get_z(x, y);
|
if (mbl.active) z += mbl.get_z(x - home_offset[X_AXIS], y - home_offset[Y_AXIS]);
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_FEATURE)
|
#elif ENABLED(AUTO_BED_LEVELING_FEATURE)
|
||||||
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
|
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue