|
@@ -1470,7 +1470,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
1470
|
1470
|
* the software endstop positions must be refreshed to remain
|
1471
|
1471
|
* at the same positions relative to the machine.
|
1472
|
1472
|
*/
|
1473
|
|
-static void update_software_endstops(AxisEnum axis) {
|
|
1473
|
+void update_software_endstops(AxisEnum axis) {
|
1474
|
1474
|
float offs = LOGICAL_POSITION(0, axis);
|
1475
|
1475
|
|
1476
|
1476
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
@@ -1530,7 +1530,7 @@ static void set_home_offset(AxisEnum axis, float v) {
|
1530
|
1530
|
static void set_axis_is_at_home(AxisEnum axis) {
|
1531
|
1531
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1532
|
1532
|
if (DEBUGGING(LEVELING)) {
|
1533
|
|
- SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis);
|
|
1533
|
+ SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
|
1534
|
1534
|
SERIAL_ECHOLNPGM(")");
|
1535
|
1535
|
}
|
1536
|
1536
|
#endif
|
|
@@ -1606,7 +1606,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
|
1606
|
1606
|
}
|
1607
|
1607
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1608
|
1608
|
if (DEBUGGING(LEVELING)) {
|
1609
|
|
- SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis);
|
|
1609
|
+ SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis_codes[axis]);
|
1610
|
1610
|
SERIAL_ECHOLNPGM(")");
|
1611
|
1611
|
}
|
1612
|
1612
|
#endif
|
|
@@ -1638,15 +1638,6 @@ inline void line_to_z(float zPosition) {
|
1638
|
1638
|
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
1639
|
1639
|
}
|
1640
|
1640
|
|
1641
|
|
-inline void line_to_axis_pos(AxisEnum axis, float where, float fr_mm_s = 0.0) {
|
1642
|
|
- float old_feedrate_mm_s = feedrate_mm_s;
|
1643
|
|
- current_position[axis] = where;
|
1644
|
|
- feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[axis];
|
1645
|
|
- planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
1646
|
|
- stepper.synchronize();
|
1647
|
|
- feedrate_mm_s = old_feedrate_mm_s;
|
1648
|
|
-}
|
1649
|
|
-
|
1650
|
1641
|
//
|
1651
|
1642
|
// line_to_destination
|
1652
|
1643
|
// Move the planner, not necessarily synced with current_position
|
|
@@ -2127,10 +2118,36 @@ static void clean_up_after_endstop_or_probe_move() {
|
2127
|
2118
|
return false;
|
2128
|
2119
|
}
|
2129
|
2120
|
|
|
2121
|
+ static void do_probe_move(float z, float fr_mm_m) {
|
|
2122
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2123
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
|
|
2124
|
+ #endif
|
|
2125
|
+
|
|
2126
|
+ // Move down until probe triggered
|
|
2127
|
+ do_blocking_move_to_z(LOGICAL_Z_POSITION(z), MMM_TO_MMS(fr_mm_m));
|
|
2128
|
+
|
|
2129
|
+ // Clear endstop flags
|
|
2130
|
+ endstops.hit_on_purpose();
|
|
2131
|
+
|
|
2132
|
+ // Get Z where the steppers were interrupted
|
|
2133
|
+ set_current_from_steppers_for_axis(Z_AXIS);
|
|
2134
|
+
|
|
2135
|
+ // Tell the planner where we actually are
|
|
2136
|
+ SYNC_PLAN_POSITION_KINEMATIC();
|
|
2137
|
+
|
|
2138
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2139
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
|
|
2140
|
+ #endif
|
|
2141
|
+ }
|
|
2142
|
+
|
2130
|
2143
|
// Do a single Z probe and return with current_position[Z_AXIS]
|
2131
|
2144
|
// at the height where the probe triggered.
|
2132
|
2145
|
static float run_z_probe() {
|
2133
|
2146
|
|
|
2147
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2148
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
|
|
2149
|
+ #endif
|
|
2150
|
+
|
2134
|
2151
|
// Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
|
2135
|
2152
|
refresh_cmd_timeout();
|
2136
|
2153
|
|
|
@@ -2139,26 +2156,27 @@ static void clean_up_after_endstop_or_probe_move() {
|
2139
|
2156
|
#endif
|
2140
|
2157
|
|
2141
|
2158
|
#if ENABLED(PROBE_DOUBLE_TOUCH)
|
2142
|
|
- do_blocking_move_to_z(-(Z_MAX_LENGTH + 10), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
2143
|
|
- endstops.hit_on_purpose();
|
2144
|
|
- set_current_from_steppers_for_axis(Z_AXIS);
|
2145
|
|
- SYNC_PLAN_POSITION_KINEMATIC();
|
2146
|
2159
|
|
2147
|
|
- // move up the retract distance
|
|
2160
|
+ // Do a first probe at the fast speed
|
|
2161
|
+ do_probe_move(-(Z_MAX_LENGTH) - 10, Z_PROBE_SPEED_FAST);
|
|
2162
|
+
|
|
2163
|
+ // move up by the bump distance
|
2148
|
2164
|
do_blocking_move_to_z(current_position[Z_AXIS] + home_bump_mm(Z_AXIS), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
|
2165
|
+
|
2149
|
2166
|
#else
|
|
2167
|
+
|
2150
|
2168
|
// move fast, close to the bed
|
2151
|
|
- do_blocking_move_to_z(home_bump_mm(Z_AXIS), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
|
2169
|
+ float z = LOGICAL_Z_POSITION(home_bump_mm(Z_AXIS));
|
|
2170
|
+ if (zprobe_zoffset < 0) z -= zprobe_zoffset;
|
|
2171
|
+ do_blocking_move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
|
|
2172
|
+
|
2152
|
2173
|
#endif
|
2153
|
2174
|
|
2154
|
2175
|
// move down slowly to find bed
|
2155
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] -2.0*home_bump_mm(Z_AXIS), MMM_TO_MMS(Z_PROBE_SPEED_SLOW));
|
2156
|
|
- endstops.hit_on_purpose();
|
2157
|
|
- set_current_from_steppers_for_axis(Z_AXIS);
|
2158
|
|
- SYNC_PLAN_POSITION_KINEMATIC();
|
|
2176
|
+ do_probe_move(-10, Z_PROBE_SPEED_SLOW);
|
2159
|
2177
|
|
2160
|
2178
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2161
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
|
|
2179
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
|
2162
|
2180
|
#endif
|
2163
|
2181
|
|
2164
|
2182
|
return current_position[Z_AXIS];
|
|
@@ -2393,6 +2411,15 @@ static void clean_up_after_endstop_or_probe_move() {
|
2393
|
2411
|
* Home an individual axis
|
2394
|
2412
|
*/
|
2395
|
2413
|
|
|
2414
|
+static void do_homing_move(AxisEnum axis, float where, float fr_mm_s = 0.0) {
|
|
2415
|
+ float old_feedrate_mm_s = feedrate_mm_s;
|
|
2416
|
+ current_position[axis] = where;
|
|
2417
|
+ feedrate_mm_s = (fr_mm_s != 0.0) ? fr_mm_s : homing_feedrate_mm_s[axis];
|
|
2418
|
+ planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
|
2419
|
+ stepper.synchronize();
|
|
2420
|
+ feedrate_mm_s = old_feedrate_mm_s;
|
|
2421
|
+}
|
|
2422
|
+
|
2396
|
2423
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
2397
|
2424
|
|
2398
|
2425
|
static void homeaxis(AxisEnum axis) {
|
|
@@ -2403,7 +2430,7 @@ static void homeaxis(AxisEnum axis) {
|
2403
|
2430
|
|
2404
|
2431
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2405
|
2432
|
if (DEBUGGING(LEVELING)) {
|
2406
|
|
- SERIAL_ECHOPAIR(">>> homeaxis(", axis);
|
|
2433
|
+ SERIAL_ECHOPAIR(">>> homeaxis(", axis_codes[axis]);
|
2407
|
2434
|
SERIAL_ECHOLNPGM(")");
|
2408
|
2435
|
}
|
2409
|
2436
|
#endif
|
|
@@ -2415,8 +2442,8 @@ static void homeaxis(AxisEnum axis) {
|
2415
|
2442
|
home_dir(axis);
|
2416
|
2443
|
|
2417
|
2444
|
// Homing Z towards the bed? Deploy the Z probe or endstop.
|
2418
|
|
- #if HAS_BED_PROBE && DISABLED(Z_MIN_PROBE_ENDSTOP)
|
2419
|
|
- if (axis == Z_AXIS && axis_home_dir < 0) {
|
|
2445
|
+ #if HAS_BED_PROBE && Z_HOME_DIR < 0 && DISABLED(Z_MIN_PROBE_ENDSTOP)
|
|
2446
|
+ if (axis == Z_AXIS) {
|
2420
|
2447
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2421
|
2448
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2422
|
2449
|
#endif
|
|
@@ -2434,17 +2461,17 @@ static void homeaxis(AxisEnum axis) {
|
2434
|
2461
|
#endif
|
2435
|
2462
|
|
2436
|
2463
|
// Move towards the endstop until an endstop is triggered
|
2437
|
|
- line_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir);
|
|
2464
|
+ do_homing_move(axis, 1.5 * max_length(axis) * axis_home_dir);
|
2438
|
2465
|
|
2439
|
2466
|
// Set the axis position as setup for the move
|
2440
|
2467
|
current_position[axis] = 0;
|
2441
|
2468
|
sync_plan_position();
|
2442
|
2469
|
|
2443
|
2470
|
// Move away from the endstop by the axis HOME_BUMP_MM
|
2444
|
|
- line_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir);
|
|
2471
|
+ do_homing_move(axis, -home_bump_mm(axis) * axis_home_dir);
|
2445
|
2472
|
|
2446
|
2473
|
// Move slowly towards the endstop until triggered
|
2447
|
|
- line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, get_homing_bump_feedrate(axis));
|
|
2474
|
+ do_homing_move(axis, 2 * home_bump_mm(axis) * axis_home_dir, get_homing_bump_feedrate(axis));
|
2448
|
2475
|
|
2449
|
2476
|
// reset current_position to 0 to reflect hitting endpoint
|
2450
|
2477
|
current_position[axis] = 0;
|
|
@@ -2468,7 +2495,7 @@ static void homeaxis(AxisEnum axis) {
|
2468
|
2495
|
if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
|
2469
|
2496
|
|
2470
|
2497
|
// Move to the adjusted endstop height
|
2471
|
|
- line_to_axis_pos(axis, adj);
|
|
2498
|
+ do_homing_move(axis, adj);
|
2472
|
2499
|
|
2473
|
2500
|
if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
|
2474
|
2501
|
stepper.set_homing_flag(false);
|
|
@@ -2477,14 +2504,14 @@ static void homeaxis(AxisEnum axis) {
|
2477
|
2504
|
|
2478
|
2505
|
#if ENABLED(DELTA)
|
2479
|
2506
|
// retrace by the amount specified in endstop_adj
|
2480
|
|
- if (endstop_adj[axis] * axis_home_dir < 0) {
|
|
2507
|
+ if (endstop_adj[axis] * Z_HOME_DIR < 0) {
|
2481
|
2508
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2482
|
2509
|
if (DEBUGGING(LEVELING)) {
|
2483
|
2510
|
SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
|
2484
|
2511
|
DEBUG_POS("", current_position);
|
2485
|
2512
|
}
|
2486
|
2513
|
#endif
|
2487
|
|
- line_to_axis_pos(axis, endstop_adj[axis]);
|
|
2514
|
+ do_homing_move(axis, endstop_adj[axis]);
|
2488
|
2515
|
}
|
2489
|
2516
|
#endif
|
2490
|
2517
|
|
|
@@ -2503,8 +2530,8 @@ static void homeaxis(AxisEnum axis) {
|
2503
|
2530
|
axis_homed[axis] = true;
|
2504
|
2531
|
|
2505
|
2532
|
// Put away the Z probe
|
2506
|
|
- #if HAS_BED_PROBE && DISABLED(Z_MIN_PROBE_ENDSTOP)
|
2507
|
|
- if (axis == Z_AXIS && axis_home_dir < 0) {
|
|
2533
|
+ #if HAS_BED_PROBE && Z_HOME_DIR < 0 && DISABLED(Z_MIN_PROBE_ENDSTOP)
|
|
2534
|
+ if (axis == Z_AXIS) {
|
2508
|
2535
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2509
|
2536
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2510
|
2537
|
#endif
|
|
@@ -2514,11 +2541,11 @@ static void homeaxis(AxisEnum axis) {
|
2514
|
2541
|
|
2515
|
2542
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2516
|
2543
|
if (DEBUGGING(LEVELING)) {
|
2517
|
|
- SERIAL_ECHOPAIR("<<< homeaxis(", axis);
|
|
2544
|
+ SERIAL_ECHOPAIR("<<< homeaxis(", axis_codes[axis]);
|
2518
|
2545
|
SERIAL_ECHOLNPGM(")");
|
2519
|
2546
|
}
|
2520
|
2547
|
#endif
|
2521
|
|
-}
|
|
2548
|
+} // homeaxis()
|
2522
|
2549
|
|
2523
|
2550
|
#if ENABLED(FWRETRACT)
|
2524
|
2551
|
|
|
@@ -3475,7 +3502,7 @@ inline void gcode_G28() {
|
3475
|
3502
|
|
3476
|
3503
|
int verbose_level = code_seen('V') ? code_value_int() : 1;
|
3477
|
3504
|
if (verbose_level < 0 || verbose_level > 4) {
|
3478
|
|
- SERIAL_ECHOLNPGM("?(V)erbose Level is implausible (0-4).");
|
|
3505
|
+ SERIAL_PROTOCOLLNPGM("?(V)erbose Level is implausible (0-4).");
|
3479
|
3506
|
return;
|
3480
|
3507
|
}
|
3481
|
3508
|
|
|
@@ -3587,12 +3614,12 @@ inline void gcode_G28() {
|
3587
|
3614
|
#if ENABLED(AUTO_BED_LEVELING_GRID)
|
3588
|
3615
|
|
3589
|
3616
|
// probe at the points of a lattice grid
|
3590
|
|
- const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1),
|
3591
|
|
- yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
|
|
3617
|
+ const float xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1),
|
|
3618
|
+ yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
|
3592
|
3619
|
|
3593
|
3620
|
#if ENABLED(DELTA)
|
3594
|
|
- delta_grid_spacing[0] = xGridSpacing;
|
3595
|
|
- delta_grid_spacing[1] = yGridSpacing;
|
|
3621
|
+ delta_grid_spacing[X_AXIS] = xGridSpacing;
|
|
3622
|
+ delta_grid_spacing[Y_AXIS] = yGridSpacing;
|
3596
|
3623
|
float zoffset = zprobe_zoffset;
|
3597
|
3624
|
if (code_seen('Z')) zoffset += code_value_axis_units(Z_AXIS);
|
3598
|
3625
|
#else // !DELTA
|
|
@@ -3614,10 +3641,11 @@ inline void gcode_G28() {
|
3614
|
3641
|
#endif // !DELTA
|
3615
|
3642
|
|
3616
|
3643
|
int probePointCounter = 0;
|
3617
|
|
- bool zig = (auto_bed_leveling_grid_points & 1) ? true : false; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
|
|
3644
|
+ bool zig = auto_bed_leveling_grid_points & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
|
3618
|
3645
|
|
3619
|
3646
|
for (int yCount = 0; yCount < auto_bed_leveling_grid_points; yCount++) {
|
3620
|
|
- double yProbe = front_probe_bed_position + yGridSpacing * yCount;
|
|
3647
|
+ float yBase = front_probe_bed_position + yGridSpacing * yCount,
|
|
3648
|
+ yProbe = floor(yProbe + (yProbe < 0 ? 0 : 0.5));
|
3621
|
3649
|
int xStart, xStop, xInc;
|
3622
|
3650
|
|
3623
|
3651
|
if (zig) {
|
|
@@ -3634,13 +3662,13 @@ inline void gcode_G28() {
|
3634
|
3662
|
zig = !zig;
|
3635
|
3663
|
|
3636
|
3664
|
for (int xCount = xStart; xCount != xStop; xCount += xInc) {
|
3637
|
|
- double xProbe = left_probe_bed_position + xGridSpacing * xCount;
|
|
3665
|
+ float xBase = left_probe_bed_position + xGridSpacing * xCount,
|
|
3666
|
+ xProbe = floor(xProbe + (xProbe < 0 ? 0 : 0.5));
|
3638
|
3667
|
|
3639
|
3668
|
#if ENABLED(DELTA)
|
3640
|
|
- // Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
|
3641
|
|
- float distance_from_center = HYPOT(xProbe, yProbe);
|
3642
|
|
- if (distance_from_center > DELTA_PROBEABLE_RADIUS) continue;
|
3643
|
|
- #endif //DELTA
|
|
3669
|
+ // Avoid probing outside the round or hexagonal area of a delta printer
|
|
3670
|
+ if (sq(xProbe) + sq(yProbe) > sq(DELTA_PROBEABLE_RADIUS)) continue;
|
|
3671
|
+ #endif
|
3644
|
3672
|
|
3645
|
3673
|
float measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
|
3646
|
3674
|
|
|
@@ -7875,12 +7903,12 @@ void clamp_to_software_endstops(float target[3]) {
|
7875
|
7903
|
|
7876
|
7904
|
// Adjust print surface height by linear interpolation over the bed_level array.
|
7877
|
7905
|
void adjust_delta(float cartesian[3]) {
|
7878
|
|
- if (delta_grid_spacing[0] == 0 || delta_grid_spacing[1] == 0) return; // G29 not done!
|
|
7906
|
+ if (delta_grid_spacing[X_AXIS] == 0 || delta_grid_spacing[Y_AXIS] == 0) return; // G29 not done!
|
7879
|
7907
|
|
7880
|
7908
|
int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
|
7881
|
7909
|
float h1 = 0.001 - half, h2 = half - 0.001,
|
7882
|
|
- grid_x = max(h1, min(h2, RAW_X_POSITION(cartesian[X_AXIS]) / delta_grid_spacing[0])),
|
7883
|
|
- grid_y = max(h1, min(h2, RAW_Y_POSITION(cartesian[Y_AXIS]) / delta_grid_spacing[1]));
|
|
7910
|
+ grid_x = max(h1, min(h2, RAW_X_POSITION(cartesian[X_AXIS]) / delta_grid_spacing[X_AXIS])),
|
|
7911
|
+ grid_y = max(h1, min(h2, RAW_Y_POSITION(cartesian[Y_AXIS]) / delta_grid_spacing[Y_AXIS]));
|
7884
|
7912
|
int floor_x = floor(grid_x), floor_y = floor(grid_y);
|
7885
|
7913
|
float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
|
7886
|
7914
|
z1 = bed_level[floor_x + half][floor_y + half],
|