2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 03:20:14 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#include "../gcode.h"
|
|
|
|
|
|
|
|
#include "../../module/stepper.h"
|
|
|
|
#include "../../module/endstops.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-04-20 04:56:55 +00:00
|
|
|
#if HAS_MULTI_HOTEND
|
2017-09-08 20:35:25 +00:00
|
|
|
#include "../../module/tool_change.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "../../feature/bedlevel/bedlevel.h"
|
|
|
|
#endif
|
|
|
|
|
2018-02-21 01:44:02 +00:00
|
|
|
#if ENABLED(SENSORLESS_HOMING)
|
|
|
|
#include "../../feature/tmc_util.h"
|
|
|
|
#endif
|
|
|
|
|
2019-09-25 04:34:07 +00:00
|
|
|
#include "../../module/probe.h"
|
2019-06-26 10:11:05 +00:00
|
|
|
|
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
#include "../../feature/bltouch.h"
|
2018-03-11 18:07:55 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-17 00:36:25 +00:00
|
|
|
#include "../../lcd/marlinui.h"
|
2020-06-16 06:45:27 +00:00
|
|
|
#if ENABLED(DWIN_CREALITY_LCD)
|
2020-09-07 02:40:58 +00:00
|
|
|
#include "../../lcd/dwin/e3v2/dwin.h"
|
2020-06-16 06:45:27 +00:00
|
|
|
#endif
|
2017-09-08 20:35:25 +00:00
|
|
|
|
2020-01-14 00:47:30 +00:00
|
|
|
#if HAS_L64XX // set L6470 absolute position registers to counts
|
|
|
|
#include "../../libs/L64XX/L64XX_Marlin.h"
|
2019-01-24 01:06:54 +00:00
|
|
|
#endif
|
|
|
|
|
2020-06-08 05:47:31 +00:00
|
|
|
#if ENABLED(LASER_MOVE_G28_OFF)
|
|
|
|
#include "../../feature/spindle_laser.h"
|
|
|
|
#endif
|
|
|
|
|
2019-03-14 07:25:42 +00:00
|
|
|
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#include "../../core/debug_out.h"
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#if ENABLED(QUICK_HOME)
|
|
|
|
|
|
|
|
static void quick_home_xy() {
|
|
|
|
|
|
|
|
// Pretend the current position is 0,0
|
2019-09-29 09:25:39 +00:00
|
|
|
current_position.set(0.0, 0.0);
|
2017-09-06 11:28:31 +00:00
|
|
|
sync_plan_position();
|
|
|
|
|
2020-03-08 04:20:41 +00:00
|
|
|
const int x_axis_home_dir = x_home_dir(active_extruder);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
const float mlx = max_length(X_AXIS),
|
|
|
|
mly = max_length(Y_AXIS),
|
|
|
|
mlratio = mlx > mly ? mly / mlx : mlx / mly,
|
2019-07-05 23:01:21 +00:00
|
|
|
fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-02-21 01:44:02 +00:00
|
|
|
#if ENABLED(SENSORLESS_HOMING)
|
2019-08-05 03:22:58 +00:00
|
|
|
sensorless_t stealth_states {
|
|
|
|
tmc_enable_stallguard(stepperX)
|
|
|
|
, tmc_enable_stallguard(stepperY)
|
|
|
|
, false
|
|
|
|
, false
|
|
|
|
#if AXIS_HAS_STALLGUARD(X2)
|
|
|
|
|| tmc_enable_stallguard(stepperX2)
|
|
|
|
#endif
|
|
|
|
, false
|
|
|
|
#if AXIS_HAS_STALLGUARD(Y2)
|
|
|
|
|| tmc_enable_stallguard(stepperY2)
|
|
|
|
#endif
|
|
|
|
};
|
2018-02-21 01:44:02 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
|
2018-07-01 02:54:07 +00:00
|
|
|
|
|
|
|
endstops.validate_homing_move();
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
current_position.set(0.0, 0.0);
|
2018-02-21 01:44:02 +00:00
|
|
|
|
2018-02-19 16:11:11 +00:00
|
|
|
#if ENABLED(SENSORLESS_HOMING)
|
2018-12-07 21:34:21 +00:00
|
|
|
tmc_disable_stallguard(stepperX, stealth_states.x);
|
|
|
|
tmc_disable_stallguard(stepperY, stealth_states.y);
|
2019-02-02 00:09:01 +00:00
|
|
|
#if AXIS_HAS_STALLGUARD(X2)
|
|
|
|
tmc_disable_stallguard(stepperX2, stealth_states.x2);
|
|
|
|
#endif
|
|
|
|
#if AXIS_HAS_STALLGUARD(Y2)
|
|
|
|
tmc_disable_stallguard(stepperY2, stealth_states.y2);
|
|
|
|
#endif
|
2018-02-19 16:11:11 +00:00
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // QUICK_HOME
|
|
|
|
|
|
|
|
#if ENABLED(Z_SAFE_HOMING)
|
|
|
|
|
|
|
|
inline void home_z_safely() {
|
2020-07-09 02:44:21 +00:00
|
|
|
DEBUG_SECTION(log_G28, "home_z_safely", DEBUGGING(LEVELING));
|
|
|
|
|
2020-07-05 23:00:37 +00:00
|
|
|
// Disallow Z homing if X or Y homing is needed
|
2020-08-27 21:05:53 +00:00
|
|
|
if (homing_needed_error(_BV(X_AXIS) | _BV(Y_AXIS))) return;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-17 02:24:15 +00:00
|
|
|
sync_plan_position();
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the Z probe (or just the nozzle) to the safe homing point
|
2019-09-29 09:25:39 +00:00
|
|
|
* (Z is already at the right height)
|
2017-09-06 11:28:31 +00:00
|
|
|
*/
|
2020-10-18 20:53:12 +00:00
|
|
|
constexpr xy_float_t safe_homing_xy = { Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT };
|
|
|
|
#if HAS_HOME_OFFSET
|
|
|
|
xy_float_t okay_homing_xy = safe_homing_xy;
|
|
|
|
okay_homing_xy -= home_offset;
|
|
|
|
#else
|
|
|
|
constexpr xy_float_t okay_homing_xy = safe_homing_xy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
destination.set(okay_homing_xy, current_position.z);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
if (position_is_reachable(destination)) {
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-09-21 04:15:39 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-10-16 21:59:55 +00:00
|
|
|
// Free the active extruder for movement
|
|
|
|
TERN_(DUAL_X_CARRIAGE, idex_set_parked(false));
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle
|
2018-02-19 01:28:40 +00:00
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
do_blocking_move_to_xy(destination);
|
2018-06-30 23:13:13 +00:00
|
|
|
homeaxis(Z_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
|
2020-02-26 09:02:03 +00:00
|
|
|
SERIAL_ECHO_MSG(STR_ZPROBE_OUT_SER);
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // Z_SAFE_HOMING
|
|
|
|
|
2019-10-24 18:14:45 +00:00
|
|
|
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
|
|
|
|
|
|
|
|
slow_homing_t begin_slow_homing() {
|
|
|
|
slow_homing_t slow_homing{0};
|
|
|
|
slow_homing.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS],
|
|
|
|
planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
|
|
|
|
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
|
|
|
|
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
|
|
|
|
#if HAS_CLASSIC_JERK
|
|
|
|
slow_homing.jerk_xy = planner.max_jerk;
|
|
|
|
planner.max_jerk.set(0, 0);
|
|
|
|
#endif
|
|
|
|
planner.reset_acceleration_rates();
|
|
|
|
return slow_homing;
|
|
|
|
}
|
|
|
|
|
|
|
|
void end_slow_homing(const slow_homing_t &slow_homing) {
|
|
|
|
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
|
|
|
|
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HAS_CLASSIC_JERK, planner.max_jerk = slow_homing.jerk_xy);
|
2019-10-24 18:14:45 +00:00
|
|
|
planner.reset_acceleration_rates();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // IMPROVE_HOMING_RELIABILITY
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* G28: Home all axes according to settings
|
|
|
|
*
|
|
|
|
* Parameters
|
|
|
|
*
|
|
|
|
* None Home to all axes with no parameters.
|
|
|
|
* With QUICK_HOME enabled XY will home together, then Z.
|
|
|
|
*
|
2018-06-12 02:51:48 +00:00
|
|
|
* O Home only if position is unknown
|
|
|
|
*
|
2018-04-22 00:07:48 +00:00
|
|
|
* Rn Raise by n mm/inches before homing
|
|
|
|
*
|
|
|
|
* Cartesian/SCARA parameters
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* X Home to the X endstop
|
|
|
|
* Y Home to the Y endstop
|
|
|
|
* Z Home to the Z endstop
|
|
|
|
*/
|
2020-03-03 02:50:06 +00:00
|
|
|
void GcodeSuite::G28() {
|
2020-07-09 02:44:21 +00:00
|
|
|
DEBUG_SECTION(log_G28, "G28", DEBUGGING(LEVELING));
|
|
|
|
if (DEBUGGING(LEVELING)) log_machine_info();
|
2020-06-08 05:47:31 +00:00
|
|
|
|
2020-07-09 02:44:21 +00:00
|
|
|
TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser
|
2020-07-01 21:27:28 +00:00
|
|
|
|
2020-06-16 06:45:27 +00:00
|
|
|
TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);
|
|
|
|
|
2018-09-02 15:18:59 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
bool IDEX_saved_duplication_state = extruder_duplication_enabled;
|
|
|
|
DualXMode IDEX_saved_mode = dual_x_carriage_mode;
|
|
|
|
#endif
|
|
|
|
|
2018-07-03 03:27:05 +00:00
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
|
|
|
if (parser.seen('S')) {
|
|
|
|
LOOP_XYZ(a) set_axis_is_at_home((AxisEnum)a);
|
2018-09-17 02:24:15 +00:00
|
|
|
sync_plan_position();
|
2018-07-03 03:27:05 +00:00
|
|
|
SERIAL_ECHOLNPGM("Simulated Homing");
|
|
|
|
report_current_position();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-11-11 00:45:06 +00:00
|
|
|
// Home (O)nly if position is unknown
|
2019-06-26 08:42:21 +00:00
|
|
|
if (!homing_needed() && parser.boolval('O')) {
|
2020-07-09 02:44:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> homing not needed, skip");
|
2019-06-26 08:42:21 +00:00
|
|
|
return;
|
2018-06-12 02:51:48 +00:00
|
|
|
}
|
2018-06-12 23:38:00 +00:00
|
|
|
|
2020-10-12 21:48:04 +00:00
|
|
|
planner.synchronize(); // Wait for planner moves to finish!
|
|
|
|
|
|
|
|
SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Disable the leveling matrix before homing
|
|
|
|
#if HAS_LEVELING
|
2018-09-10 03:06:03 +00:00
|
|
|
|
|
|
|
// Cancel the active G29 session
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(PROBE_MANUALLY, g29_in_progress = false);
|
2018-09-10 03:06:03 +00:00
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(RESTORE_LEVELING_AFTER_G28, const bool leveling_was_active = planner.leveling_active);
|
2017-09-06 11:28:31 +00:00
|
|
|
set_bed_leveling_enabled(false);
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-07-01 21:27:28 +00:00
|
|
|
// Count this command as movement / activity
|
|
|
|
reset_stepper_timeout();
|
|
|
|
|
2019-11-11 00:45:06 +00:00
|
|
|
#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
|
2020-04-22 21:35:03 +00:00
|
|
|
#if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2)
|
|
|
|
#define HAS_HOMING_CURRENT 1
|
|
|
|
#endif
|
2019-11-11 00:45:06 +00:00
|
|
|
|
|
|
|
#if HAS_HOMING_CURRENT
|
2020-03-28 03:00:27 +00:00
|
|
|
auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){
|
|
|
|
serialprintPGM(s); DEBUG_ECHOLNPAIR(" current: ", a, " -> ", b);
|
2019-11-11 00:45:06 +00:00
|
|
|
};
|
|
|
|
#if HAS_CURRENT_HOME(X)
|
|
|
|
const int16_t tmc_save_current_X = stepperX.getMilliamps();
|
|
|
|
stepperX.rms_current(X_CURRENT_HOME);
|
2020-03-28 03:00:27 +00:00
|
|
|
if (DEBUGGING(LEVELING)) debug_current(PSTR("X"), tmc_save_current_X, X_CURRENT_HOME);
|
2019-11-11 00:45:06 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_CURRENT_HOME(X2)
|
|
|
|
const int16_t tmc_save_current_X2 = stepperX2.getMilliamps();
|
|
|
|
stepperX2.rms_current(X2_CURRENT_HOME);
|
2020-03-28 03:00:27 +00:00
|
|
|
if (DEBUGGING(LEVELING)) debug_current(PSTR("X2"), tmc_save_current_X2, X2_CURRENT_HOME);
|
2019-11-11 00:45:06 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_CURRENT_HOME(Y)
|
|
|
|
const int16_t tmc_save_current_Y = stepperY.getMilliamps();
|
|
|
|
stepperY.rms_current(Y_CURRENT_HOME);
|
2020-03-28 03:00:27 +00:00
|
|
|
if (DEBUGGING(LEVELING)) debug_current(PSTR("Y"), tmc_save_current_Y, Y_CURRENT_HOME);
|
2019-11-11 00:45:06 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_CURRENT_HOME(Y2)
|
|
|
|
const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps();
|
|
|
|
stepperY2.rms_current(Y2_CURRENT_HOME);
|
2020-03-28 03:00:27 +00:00
|
|
|
if (DEBUGGING(LEVELING)) debug_current(PSTR("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME);
|
2019-11-11 00:45:06 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing_t slow_homing = begin_slow_homing());
|
2019-08-05 03:22:58 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Always home with tool 0 active
|
2020-04-20 04:56:55 +00:00
|
|
|
#if HAS_MULTI_HOTEND
|
2018-03-16 05:46:42 +00:00
|
|
|
#if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
|
|
|
|
const uint8_t old_tool_index = active_extruder;
|
|
|
|
#endif
|
2019-06-24 01:00:48 +00:00
|
|
|
tool_change(0, true);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-16 21:59:55 +00:00
|
|
|
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-09-24 01:58:01 +00:00
|
|
|
remember_feedrate_scaling_off();
|
2019-02-25 20:28:01 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
endstops.enable(true); // Enable endstops for next homing move
|
|
|
|
|
|
|
|
#if ENABLED(DELTA)
|
|
|
|
|
2020-03-08 04:20:41 +00:00
|
|
|
constexpr bool doZ = true; // for NANODLP_Z_SYNC if your DLP is on a DELTA
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
home_delta();
|
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
|
2019-10-24 18:14:45 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#else // NOT DELTA
|
|
|
|
|
2020-06-03 00:12:08 +00:00
|
|
|
const bool homeZ = parser.seen('Z'),
|
2020-08-27 21:05:53 +00:00
|
|
|
needX = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(X_AXIS))),
|
|
|
|
needY = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(Y_AXIS))),
|
2020-06-03 00:12:08 +00:00
|
|
|
homeX = needX || parser.seen('X'), homeY = needY || parser.seen('Y'),
|
2020-03-03 02:50:06 +00:00
|
|
|
home_all = homeX == homeY && homeX == homeZ, // All or None
|
2019-05-26 20:30:20 +00:00
|
|
|
doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-11-11 22:58:34 +00:00
|
|
|
#if ENABLED(HOME_Z_FIRST)
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-04-04 07:47:19 +00:00
|
|
|
if (doZ) homeaxis(Z_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2017-12-06 01:40:36 +00:00
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-11-30 01:06:40 +00:00
|
|
|
const float z_homing_height = TERN1(UNKNOWN_Z_NO_RAISE, axis_is_trusted(Z_AXIS))
|
|
|
|
? (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT)
|
|
|
|
: 0;
|
2018-04-23 23:00:06 +00:00
|
|
|
|
2020-11-26 03:38:00 +00:00
|
|
|
if (z_homing_height && (doX || doY || TERN0(Z_SAFE_HOMING, doZ))) {
|
2017-12-06 01:40:36 +00:00
|
|
|
// Raise Z before homing any other axes and z is not already high enough (never lower z)
|
2020-07-09 02:44:21 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
|
2020-11-30 01:06:40 +00:00
|
|
|
do_z_clearance(z_homing_height, axis_is_trusted(Z_AXIS), DISABLED(UNKNOWN_Z_NO_RAISE));
|
2017-12-06 01:40:36 +00:00
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#if ENABLED(QUICK_HOME)
|
|
|
|
|
2019-04-04 07:47:19 +00:00
|
|
|
if (doX && doY) quick_home_xy();
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-02-16 15:59:44 +00:00
|
|
|
// Home Y (before X)
|
2020-11-26 03:38:00 +00:00
|
|
|
if (ENABLED(HOME_Y_BEFORE_X) && (doY || TERN0(CODEPENDENT_XY_HOMING, doX)))
|
2020-03-28 03:00:27 +00:00
|
|
|
homeaxis(Y_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Home X
|
2020-03-08 04:20:41 +00:00
|
|
|
if (doX || (doY && ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X))) {
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
|
|
|
// Always home the 2nd (right) extruder first
|
|
|
|
active_extruder = 1;
|
2018-06-30 23:13:13 +00:00
|
|
|
homeaxis(X_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Remember this extruder's position for later tool change
|
2020-10-16 21:59:55 +00:00
|
|
|
inactive_extruder_x = current_position.x;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Home the 1st (left) extruder
|
|
|
|
active_extruder = 0;
|
2018-06-30 23:13:13 +00:00
|
|
|
homeaxis(X_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-10-16 21:59:55 +00:00
|
|
|
// Consider the active extruder to be in its "parked" position
|
|
|
|
idex_set_parked();
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-06-30 23:13:13 +00:00
|
|
|
homeaxis(X_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-02-16 15:59:44 +00:00
|
|
|
// Home Y (after X)
|
2020-03-08 04:20:41 +00:00
|
|
|
if (DISABLED(HOME_Y_BEFORE_X) && doY)
|
|
|
|
homeaxis(Y_AXIS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
|
2019-10-24 18:14:45 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Home Z last if homing towards the bed
|
2020-11-11 22:58:34 +00:00
|
|
|
#if DISABLED(HOME_Z_FIRST)
|
2019-04-04 07:47:19 +00:00
|
|
|
if (doZ) {
|
2020-11-13 04:54:18 +00:00
|
|
|
#if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
|
|
|
|
stepper.set_all_z_lock(false);
|
|
|
|
stepper.set_separate_multi_axis(false);
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(BLTOUCH, bltouch.init());
|
2020-05-18 18:58:11 +00:00
|
|
|
TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS));
|
2020-07-09 02:44:21 +00:00
|
|
|
probe.move_z_after_homing();
|
2020-11-11 22:58:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-17 02:24:15 +00:00
|
|
|
sync_plan_position();
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
#endif // !DELTA (G28)
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-04 04:15:31 +00:00
|
|
|
/**
|
|
|
|
* Preserve DXC mode across a G28 for IDEX printers in DXC_DUPLICATION_MODE.
|
|
|
|
* This is important because it lets a user use the LCD Panel to set an IDEX Duplication mode, and
|
|
|
|
* then print a standard GCode file that contains a single print that does a G28 and has no other
|
|
|
|
* IDEX specific commands in it.
|
|
|
|
*/
|
2018-09-02 15:18:59 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2018-09-04 04:15:31 +00:00
|
|
|
|
2020-10-16 21:59:55 +00:00
|
|
|
if (idex_is_duplicating()) {
|
2018-09-02 15:18:59 +00:00
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing());
|
2019-10-24 18:14:45 +00:00
|
|
|
|
2018-09-04 04:15:31 +00:00
|
|
|
// Always home the 2nd (right) extruder first
|
|
|
|
active_extruder = 1;
|
|
|
|
homeaxis(X_AXIS);
|
2018-09-02 15:18:59 +00:00
|
|
|
|
2018-09-04 04:15:31 +00:00
|
|
|
// Remember this extruder's position for later tool change
|
2020-10-16 21:59:55 +00:00
|
|
|
inactive_extruder_x = current_position.x;
|
2018-09-02 15:18:59 +00:00
|
|
|
|
2018-09-04 04:15:31 +00:00
|
|
|
// Home the 1st (left) extruder
|
|
|
|
active_extruder = 0;
|
|
|
|
homeaxis(X_AXIS);
|
2018-09-02 15:18:59 +00:00
|
|
|
|
2018-09-04 04:15:31 +00:00
|
|
|
// Consider the active extruder to be parked
|
2020-10-16 21:59:55 +00:00
|
|
|
idex_set_parked();
|
|
|
|
|
|
|
|
dual_x_carriage_mode = IDEX_saved_mode;
|
|
|
|
set_duplication_enabled(IDEX_saved_duplication_state);
|
2019-10-24 18:14:45 +00:00
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
|
2018-09-02 15:18:59 +00:00
|
|
|
}
|
2018-09-04 04:15:31 +00:00
|
|
|
|
|
|
|
#endif // DUAL_X_CARRIAGE
|
2018-09-02 15:18:59 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
endstops.not_homing();
|
|
|
|
|
2019-08-05 03:22:58 +00:00
|
|
|
// Clear endstop state for polled stallGuard endstops
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
|
2019-08-05 03:22:58 +00:00
|
|
|
|
2019-03-17 04:43:06 +00:00
|
|
|
#if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
|
2017-09-06 11:28:31 +00:00
|
|
|
// move to a height where we can use the full xy-area
|
|
|
|
do_blocking_move_to_z(delta_clip_start_height);
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active));
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-09-24 01:58:01 +00:00
|
|
|
restore_feedrate_and_scaling();
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Restore the active tool after homing
|
2020-04-20 04:56:55 +00:00
|
|
|
#if HAS_MULTI_HOTEND && (DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE))
|
2020-03-08 04:20:41 +00:00
|
|
|
tool_change(old_tool_index, NONE(PARKING_EXTRUDER, DUAL_X_CARRIAGE)); // Do move if one of these
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-11 00:45:06 +00:00
|
|
|
#if HAS_HOMING_CURRENT
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore driver current...");
|
|
|
|
#if HAS_CURRENT_HOME(X)
|
|
|
|
stepperX.rms_current(tmc_save_current_X);
|
|
|
|
#endif
|
|
|
|
#if HAS_CURRENT_HOME(X2)
|
|
|
|
stepperX2.rms_current(tmc_save_current_X2);
|
|
|
|
#endif
|
|
|
|
#if HAS_CURRENT_HOME(Y)
|
|
|
|
stepperY.rms_current(tmc_save_current_Y);
|
|
|
|
#endif
|
|
|
|
#if HAS_CURRENT_HOME(Y2)
|
|
|
|
stepperY2.rms_current(tmc_save_current_Y2);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-11-11 18:16:24 +00:00
|
|
|
ui.refresh();
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-06-16 06:45:27 +00:00
|
|
|
TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
report_current_position();
|
2019-08-28 09:20:28 +00:00
|
|
|
|
2020-03-08 04:20:41 +00:00
|
|
|
if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS)))
|
|
|
|
SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2020-01-14 00:47:30 +00:00
|
|
|
#if HAS_L64XX
|
2019-01-24 01:06:54 +00:00
|
|
|
// Set L6470 absolute position registers to counts
|
2020-01-14 00:47:30 +00:00
|
|
|
// constexpr *might* move this to PROGMEM.
|
|
|
|
// If not, this will need a PROGMEM directive and an accessor.
|
2020-01-20 01:52:01 +00:00
|
|
|
static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = {
|
2020-01-14 00:47:30 +00:00
|
|
|
X_AXIS, Y_AXIS, Z_AXIS,
|
|
|
|
X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS,
|
|
|
|
E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS
|
|
|
|
};
|
|
|
|
for (uint8_t j = 1; j <= L64XX::chain[0]; j++) {
|
|
|
|
const uint8_t cv = L64XX::chain[j];
|
2020-01-20 01:52:01 +00:00
|
|
|
L64xxManager.set_param((L64XX_axis_t)cv, L6470_ABS_POS, stepper.position(L64XX_axis_xref[cv]));
|
2019-01-24 01:06:54 +00:00
|
|
|
}
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|