Account for home_offset in G29 handler

This commit is contained in:
Scott Lahteine 2016-04-09 19:20:12 -07:00
parent f3562dd895
commit 1b7356b3a1
2 changed files with 28 additions and 19 deletions

View File

@ -2841,7 +2841,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 {
@ -2850,7 +2850,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();
} }
@ -2859,8 +2859,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++;
@ -3144,7 +3144,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)
@ -3157,7 +3157,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
@ -3318,9 +3318,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);
@ -6962,10 +6971,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);
@ -6978,7 +6987,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;
@ -6986,7 +6995,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;
@ -6994,7 +7003,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;
@ -7002,7 +7011,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;

View File

@ -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
@ -1111,7 +1111,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