|
|
|
@ -1620,10 +1620,6 @@ static void setup_for_endstop_or_probe_move() {
|
|
|
|
|
feedrate_multiplier = 100;
|
|
|
|
|
refresh_cmd_timeout();
|
|
|
|
|
}
|
|
|
|
|
static void setup_for_endstop_move() {
|
|
|
|
|
setup_for_endstop_or_probe_move();
|
|
|
|
|
endstops.enable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
@ -2348,16 +2344,17 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
|
|
|
|
|
|
|
|
|
static void homeaxis(AxisEnum axis) {
|
|
|
|
|
#define HOMEAXIS_DO(LETTER) \
|
|
|
|
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
|
|
|
|
|
|
|
|
|
if (!(axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0)) return;
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
SERIAL_ECHOPAIR(">>> homeaxis(", axis);
|
|
|
|
|
SERIAL_ECHOLNPGM(")");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#define HOMEAXIS_DO(LETTER) \
|
|
|
|
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
|
|
|
|
|
|
|
|
|
if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) {
|
|
|
|
|
|
|
|
|
|
int axis_home_dir =
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
@ -2394,21 +2391,11 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
current_position[axis] = 0;
|
|
|
|
|
sync_plan_position();
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)");
|
|
|
|
|
#endif
|
|
|
|
|
endstops.enable(false); // Disable endstops while moving away
|
|
|
|
|
|
|
|
|
|
// Move away from the endstop by the axis HOME_BUMP_MM
|
|
|
|
|
destination[axis] = -home_bump_mm(axis) * axis_home_dir;
|
|
|
|
|
line_to_destination();
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
|
|
|
|
|
#endif
|
|
|
|
|
endstops.enable(true); // Enable endstops for next homing move
|
|
|
|
|
|
|
|
|
|
// Slow down the feedrate for the next move
|
|
|
|
|
set_homing_bump_feedrate(axis);
|
|
|
|
|
|
|
|
|
@ -2449,10 +2436,6 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
#if ENABLED(DELTA)
|
|
|
|
|
// retrace by the amount specified in endstop_adj
|
|
|
|
|
if (endstop_adj[axis] * axis_home_dir < 0) {
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)");
|
|
|
|
|
#endif
|
|
|
|
|
endstops.enable(false); // Disable endstops while moving away
|
|
|
|
|
sync_plan_position();
|
|
|
|
|
destination[axis] = endstop_adj[axis];
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
@ -2463,20 +2446,8 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
#endif
|
|
|
|
|
line_to_destination();
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
|
|
|
|
|
#endif
|
|
|
|
|
endstops.enable(true); // Enable endstops for next homing move
|
|
|
|
|
}
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
SERIAL_ECHOPAIR("> endstop_adj * axis_home_dir = ", endstop_adj[axis] * axis_home_dir);
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Set the axis position to its home position (plus home offsets)
|
|
|
|
|
set_axis_is_at_home(axis);
|
|
|
|
@ -2502,8 +2473,6 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
SERIAL_ECHOPAIR("<<< homeaxis(", axis);
|
|
|
|
@ -2779,8 +2748,6 @@ inline void gcode_G4() {
|
|
|
|
|
int x_axis_home_dir = home_dir(X_AXIS);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
SYNC_PLAN_POSITION_KINEMATIC();
|
|
|
|
|
|
|
|
|
|
float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS),
|
|
|
|
|
mlratio = mlx > mly ? mly / mlx : mlx / mly;
|
|
|
|
|
|
|
|
|
@ -2789,30 +2756,9 @@ inline void gcode_G4() {
|
|
|
|
|
feedrate = min(homing_feedrate[X_AXIS], homing_feedrate[Y_AXIS]) * sqrt(mlratio * mlratio + 1);
|
|
|
|
|
line_to_destination();
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
set_axis_is_at_home(X_AXIS);
|
|
|
|
|
set_axis_is_at_home(Y_AXIS);
|
|
|
|
|
SYNC_PLAN_POSITION_KINEMATIC();
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 1", current_position);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
destination[X_AXIS] = current_position[X_AXIS];
|
|
|
|
|
destination[Y_AXIS] = current_position[Y_AXIS];
|
|
|
|
|
line_to_destination();
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
endstops.hit_on_purpose(); // clear endstop hit flags
|
|
|
|
|
|
|
|
|
|
current_position[X_AXIS] = destination[X_AXIS];
|
|
|
|
|
current_position[Y_AXIS] = destination[Y_AXIS];
|
|
|
|
|
#if DISABLED(SCARA)
|
|
|
|
|
current_position[Z_AXIS] = destination[Z_AXIS];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 2", current_position);
|
|
|
|
|
#endif
|
|
|
|
|
destination[X_AXIS] = destination[Y_AXIS] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // QUICK_HOME
|
|
|
|
@ -2866,7 +2812,12 @@ inline void gcode_G28() {
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
setup_for_endstop_move();
|
|
|
|
|
setup_for_endstop_or_probe_move();
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
|
|
|
|
|
#endif
|
|
|
|
|
endstops.enable(true); // Enable endstops for next homing move
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DELTA)
|
|
|
|
|
/**
|
|
|
|
@ -2915,10 +2866,10 @@ inline void gcode_G28() {
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#elif defined(MIN_Z_HEIGHT_FOR_HOMING) && MIN_Z_HEIGHT_FOR_HOMING > 0
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
// Raise Z before homing X or Y, if specified
|
|
|
|
|
if (home_all_axis || homeX || homeY) {
|
|
|
|
|
// Raise Z before homing any other axes and z is not already high enough (never lower z)
|
|
|
|
|
float z_dest = home_offset[Z_AXIS] + MIN_Z_HEIGHT_FOR_HOMING;
|
|
|
|
|
if (z_dest > current_position[Z_AXIS]) {
|
|
|
|
|
|
|
|
|
@ -2930,19 +2881,13 @@ inline void gcode_G28() {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
feedrate = homing_feedrate[Z_AXIS];
|
|
|
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
|
|
|
|
do_blocking_move_to_z(z_dest);
|
|
|
|
|
#else
|
|
|
|
|
line_to_z(z_dest);
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
destination[Z_AXIS] = current_position[Z_AXIS] = z_dest;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // MIN_Z_HEIGHT_FOR_HOMING
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if ENABLED(QUICK_HOME)
|
|
|
|
|
|
|
|
|
@ -3044,13 +2989,8 @@ inline void gcode_G28() {
|
|
|
|
|
*/
|
|
|
|
|
current_position[X_AXIS] = destination[X_AXIS];
|
|
|
|
|
current_position[Y_AXIS] = destination[Y_AXIS];
|
|
|
|
|
|
|
|
|
|
// Home the Z axis
|
|
|
|
|
HOMEAXIS(Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (homeZ) { // Don't need to Home Z twice
|
|
|
|
|
|
|
|
|
|
// Let's see if X and Y are homed
|
|
|
|
|
if (axis_unhomed_error(true, true, false)) return;
|
|
|
|
|
|
|
|
|
@ -3073,7 +3013,6 @@ inline void gcode_G28() {
|
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
|
SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
|
|
|
|
|
}
|
|
|
|
|
} // !home_all_axes && homeZ
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
@ -3099,7 +3038,11 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
#endif // !DELTA (gcode_G28)
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.not_homing()");
|
|
|
|
|
#endif
|
|
|
|
|
endstops.not_homing();
|
|
|
|
|
endstops.hit_on_purpose(); // clear endstop hit flags
|
|
|
|
|
|
|
|
|
|
// Enable mesh leveling again
|
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
@ -3139,8 +3082,6 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
clean_up_after_endstop_or_probe_move();
|
|
|
|
|
|
|
|
|
|
endstops.hit_on_purpose(); // clear endstop hit flags
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
|
|
|
|
|
#endif
|
|
|
|
|