|
@@ -2847,7 +2847,7 @@ inline void gcode_G28() {
|
2847
|
2847
|
}
|
2848
|
2848
|
if (probe_point == 0) {
|
2849
|
2849
|
// Set Z to a positive value before recording the first Z.
|
2850
|
|
- current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
|
2850
|
+ current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + home_offset[Z_AXIS];
|
2851
|
2851
|
sync_plan_position();
|
2852
|
2852
|
}
|
2853
|
2853
|
else {
|
|
@@ -2856,7 +2856,7 @@ inline void gcode_G28() {
|
2856
|
2856
|
iy = (probe_point - 1) / (MESH_NUM_X_POINTS);
|
2857
|
2857
|
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
2858
|
2858
|
mbl.set_z(ix, iy, current_position[Z_AXIS]);
|
2859
|
|
- current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
|
2859
|
+ current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + home_offset[Z_AXIS];
|
2860
|
2860
|
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);
|
2861
|
2861
|
st_synchronize();
|
2862
|
2862
|
}
|
|
@@ -2865,8 +2865,8 @@ inline void gcode_G28() {
|
2865
|
2865
|
ix = probe_point % (MESH_NUM_X_POINTS);
|
2866
|
2866
|
iy = probe_point / (MESH_NUM_X_POINTS);
|
2867
|
2867
|
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
2868
|
|
- current_position[X_AXIS] = mbl.get_x(ix);
|
2869
|
|
- current_position[Y_AXIS] = mbl.get_y(iy);
|
|
2868
|
+ current_position[X_AXIS] = mbl.get_x(ix) + home_offset[X_AXIS];
|
|
2869
|
+ current_position[Y_AXIS] = mbl.get_y(iy) + home_offset[Y_AXIS];
|
2870
|
2870
|
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);
|
2871
|
2871
|
st_synchronize();
|
2872
|
2872
|
probe_point++;
|
|
@@ -3155,7 +3155,7 @@ inline void gcode_G28() {
|
3155
|
3155
|
|
3156
|
3156
|
// raise extruder
|
3157
|
3157
|
float measured_z,
|
3158
|
|
- z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING;
|
|
3158
|
+ z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS];
|
3159
|
3159
|
|
3160
|
3160
|
if (probePointCounter) {
|
3161
|
3161
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -3168,7 +3168,7 @@ inline void gcode_G28() {
|
3168
|
3168
|
else {
|
3169
|
3169
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3170
|
3170
|
if (DEBUGGING(LEVELING)) {
|
3171
|
|
- SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING);
|
|
3171
|
+ SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS]);
|
3172
|
3172
|
SERIAL_EOL;
|
3173
|
3173
|
}
|
3174
|
3174
|
#endif
|
|
@@ -3329,9 +3329,18 @@ inline void gcode_G28() {
|
3329
|
3329
|
p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
|
3330
|
3330
|
|
3331
|
3331
|
// Probe at 3 arbitrary points
|
3332
|
|
- float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, verbose_level),
|
3333
|
|
- 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),
|
3334
|
|
- 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);
|
|
3332
|
+ float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
|
|
3333
|
+ ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
|
|
3334
|
+ Z_RAISE_BEFORE_PROBING + home_offset[Z_AXIS],
|
|
3335
|
+ p1, verbose_level),
|
|
3336
|
+ z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
|
|
3337
|
+ ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
|
|
3338
|
+ current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
|
|
3339
|
+ p2, verbose_level),
|
|
3340
|
+ z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
|
|
3341
|
+ ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
|
|
3342
|
+ current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
|
|
3343
|
+ p3, verbose_level);
|
3335
|
3344
|
clean_up_after_endstop_move();
|
3336
|
3345
|
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
3337
|
3346
|
|
|
@@ -4986,19 +4995,26 @@ inline void gcode_M205() {
|
4986
|
4995
|
if (code_seen('E')) max_e_jerk = code_value();
|
4987
|
4996
|
}
|
4988
|
4997
|
|
|
4998
|
+static void set_home_offset(AxisEnum axis, float v) {
|
|
4999
|
+ min_pos[axis] = base_min_pos(axis) + v;
|
|
5000
|
+ max_pos[axis] = base_max_pos(axis) + v;
|
|
5001
|
+ current_position[axis] += v - home_offset[axis];
|
|
5002
|
+ home_offset[axis] = v;
|
|
5003
|
+}
|
|
5004
|
+
|
4989
|
5005
|
/**
|
4990
|
5006
|
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
4991
|
5007
|
*/
|
4992
|
5008
|
inline void gcode_M206() {
|
4993
|
|
- for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
4994
|
|
- if (code_seen(axis_codes[i])) {
|
4995
|
|
- home_offset[i] = code_value();
|
4996
|
|
- }
|
4997
|
|
- }
|
|
5009
|
+ for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
|
|
5010
|
+ if (code_seen(axis_codes[i]))
|
|
5011
|
+ set_home_offset((AxisEnum)i, code_value());
|
|
5012
|
+
|
4998
|
5013
|
#if ENABLED(SCARA)
|
4999
|
|
- if (code_seen('T')) home_offset[X_AXIS] = code_value(); // Theta
|
5000
|
|
- if (code_seen('P')) home_offset[Y_AXIS] = code_value(); // Psi
|
|
5014
|
+ if (code_seen('T')) set_home_offset(X_AXIS, code_value()); // Theta
|
|
5015
|
+ if (code_seen('P')) set_home_offset(Y_AXIS, code_value()); // Psi
|
5001
|
5016
|
#endif
|
|
5017
|
+ sync_plan_position();
|
5002
|
5018
|
}
|
5003
|
5019
|
|
5004
|
5020
|
#if ENABLED(DELTA)
|
|
@@ -5685,16 +5701,12 @@ inline void gcode_M410() { quickStop(); }
|
5685
|
5701
|
*/
|
5686
|
5702
|
inline void gcode_M428() {
|
5687
|
5703
|
bool err = false;
|
5688
|
|
- float new_offs[3], new_pos[3];
|
5689
|
|
- memcpy(new_pos, current_position, sizeof(new_pos));
|
5690
|
|
- memcpy(new_offs, home_offset, sizeof(new_offs));
|
5691
|
5704
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
5692
|
5705
|
if (axis_homed[i]) {
|
5693
|
|
- float base = (new_pos[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
|
5694
|
|
- diff = new_pos[i] - base;
|
|
5706
|
+ float base = (current_position[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
|
|
5707
|
+ diff = current_position[i] - base;
|
5695
|
5708
|
if (diff > -20 && diff < 20) {
|
5696
|
|
- new_offs[i] -= diff;
|
5697
|
|
- new_pos[i] = base;
|
|
5709
|
+ set_home_offset((AxisEnum)i, home_offset[i] - diff);
|
5698
|
5710
|
}
|
5699
|
5711
|
else {
|
5700
|
5712
|
SERIAL_ERROR_START;
|
|
@@ -5710,8 +5722,6 @@ inline void gcode_M428() {
|
5710
|
5722
|
}
|
5711
|
5723
|
|
5712
|
5724
|
if (!err) {
|
5713
|
|
- memcpy(current_position, new_pos, sizeof(new_pos));
|
5714
|
|
- memcpy(home_offset, new_offs, sizeof(new_offs));
|
5715
|
5725
|
sync_plan_position();
|
5716
|
5726
|
LCD_ALERTMESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
|
5717
|
5727
|
#if HAS_BUZZER
|
|
@@ -6980,10 +6990,10 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
6980
|
6990
|
set_current_to_destination();
|
6981
|
6991
|
return;
|
6982
|
6992
|
}
|
6983
|
|
- int pix = mbl.select_x_index(current_position[X_AXIS]);
|
6984
|
|
- int piy = mbl.select_y_index(current_position[Y_AXIS]);
|
6985
|
|
- int ix = mbl.select_x_index(x);
|
6986
|
|
- int iy = mbl.select_y_index(y);
|
|
6993
|
+ int pix = mbl.select_x_index(current_position[X_AXIS] - home_offset[X_AXIS]);
|
|
6994
|
+ int piy = mbl.select_y_index(current_position[Y_AXIS] - home_offset[Y_AXIS]);
|
|
6995
|
+ int ix = mbl.select_x_index(x - home_offset[X_AXIS]);
|
|
6996
|
+ int iy = mbl.select_y_index(y - home_offset[Y_AXIS]);
|
6987
|
6997
|
pix = min(pix, MESH_NUM_X_POINTS - 2);
|
6988
|
6998
|
piy = min(piy, MESH_NUM_Y_POINTS - 2);
|
6989
|
6999
|
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_
|
6996
|
7006
|
}
|
6997
|
7007
|
float nx, ny, nz, ne, normalized_dist;
|
6998
|
7008
|
if (ix > pix && TEST(x_splits, ix)) {
|
6999
|
|
- nx = mbl.get_x(ix);
|
|
7009
|
+ nx = mbl.get_x(ix) + home_offset[X_AXIS];
|
7000
|
7010
|
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
7001
|
7011
|
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
7002
|
7012
|
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_
|
7004
|
7014
|
CBI(x_splits, ix);
|
7005
|
7015
|
}
|
7006
|
7016
|
else if (ix < pix && TEST(x_splits, pix)) {
|
7007
|
|
- nx = mbl.get_x(pix);
|
|
7017
|
+ nx = mbl.get_x(pix) + home_offset[X_AXIS];
|
7008
|
7018
|
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
7009
|
7019
|
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
7010
|
7020
|
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_
|
7012
|
7022
|
CBI(x_splits, pix);
|
7013
|
7023
|
}
|
7014
|
7024
|
else if (iy > piy && TEST(y_splits, iy)) {
|
7015
|
|
- ny = mbl.get_y(iy);
|
|
7025
|
+ ny = mbl.get_y(iy) + home_offset[Y_AXIS];
|
7016
|
7026
|
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
7017
|
7027
|
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
7018
|
7028
|
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_
|
7020
|
7030
|
CBI(y_splits, iy);
|
7021
|
7031
|
}
|
7022
|
7032
|
else if (iy < piy && TEST(y_splits, piy)) {
|
7023
|
|
- ny = mbl.get_y(piy);
|
|
7033
|
+ ny = mbl.get_y(piy) + home_offset[Y_AXIS];
|
7024
|
7034
|
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
7025
|
7035
|
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
7026
|
7036
|
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|