From b6cdaee4f7a94c1534a529b8ae078ab8e56c88b4 Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sun, 6 Jun 2021 07:52:11 +0200 Subject: [PATCH 1/3] Speed up G35 Check if all axis trusted and only home if not. --- Marlin/src/gcode/bedlevel/G35.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index ad2cc67db041..49a35208a67d 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -91,8 +91,8 @@ void GcodeSuite::G35() { // Disable duplication mode on homing TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); - // Home all before this procedure - home_all_axes(); + // Home all axis if needed before this procedure + if (!all_axes_trusted()) home_all_axes(); bool err_break = false; @@ -161,9 +161,6 @@ void GcodeSuite::G35() { probe.stow(); move_to_tramming_wait_pos(); - - // After this operation the Z position needs correction - set_axis_never_homed(Z_AXIS); } #endif // ASSISTED_TRAMMING From 58d2f86da3766a59032cd4a05c940594c1d39b69 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 8 Jun 2021 20:22:02 -0500 Subject: [PATCH 2/3] Add home_if_needed() --- Marlin/src/gcode/bedlevel/G35.cpp | 4 +- Marlin/src/gcode/calibrate/G34.cpp | 2 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/feature/pause/M600.cpp | 2 +- Marlin/src/module/motion.cpp | 4 ++ Marlin/src/module/motion.h | 52 +++++++++++++------------ 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 49a35208a67d..f02588e4b998 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -91,8 +91,8 @@ void GcodeSuite::G35() { // Disable duplication mode on homing TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); - // Home all axis if needed before this procedure - if (!all_axes_trusted()) home_all_axes(); + // Home all axes if needed before this procedure + home_if_needed(); bool err_break = false; diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index bcca00dd42b3..956960866dc8 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -39,7 +39,7 @@ void GcodeSuite::G34() { // Home before the alignment procedure - if (!all_axes_trusted()) home_all_axes(); + home_if_needed(); TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false)); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 1803933d1698..686996202840 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -167,7 +167,7 @@ void GcodeSuite::G34() { )); // Home before the alignment procedure - if (!all_axes_trusted()) home_all_axes(); + home_if_needed(); // Move the Z coordinate realm towards the positive - dirty trick current_position.z += z_probe * 0.5f; diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 2daa7d999a19..541fa08350e6 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -99,7 +99,7 @@ void GcodeSuite::M600() { #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE) // If needed, home before parking for filament change - if (!all_axes_trusted()) home_all_axes(true); + home_if_needed(true); #endif #if HAS_MULTI_EXTRUDER diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index d465a0035685..b540c9a9380c 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -294,6 +294,10 @@ void report_current_position_projected() { #endif +void home_if_needed(const bool keeplev/*=false*/) { + if (!all_axes_trusted()) gcode.home_all_axes(keeplev); +} + /** * Run out the planner buffer and re-sync the current * position from the last-updated stepper positions. diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index d099246f17e3..c41738a5ab67 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -392,33 +392,35 @@ void set_axis_is_at_home(const AxisEnum axis); void set_axis_never_homed(const AxisEnum axis); linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits=linear_bits); bool homing_needed_error(linear_axis_bits_t axis_bits=linear_bits); - FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); } - FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); } - FORCE_INLINE void set_all_unhomed() { axis_homed = axis_trusted = 0; } - FORCE_INLINE void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); } - FORCE_INLINE void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); } - FORCE_INLINE void set_all_homed() { axis_homed = axis_trusted = linear_bits; } + inline void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); } + inline void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); } + inline void set_all_unhomed() { axis_homed = axis_trusted = 0; } + inline void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); } + inline void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); } + inline void set_all_homed() { axis_homed = axis_trusted = linear_bits; } #else constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted - FORCE_INLINE void homeaxis(const AxisEnum axis) {} - FORCE_INLINE void set_axis_never_homed(const AxisEnum) {} - FORCE_INLINE linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } - FORCE_INLINE bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } - FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) {} - FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) {} - FORCE_INLINE void set_all_unhomed() {} - FORCE_INLINE void set_axis_homed(const AxisEnum axis) {} - FORCE_INLINE void set_axis_trusted(const AxisEnum axis) {} - FORCE_INLINE void set_all_homed() {} -#endif - -FORCE_INLINE bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); } -FORCE_INLINE bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); } -FORCE_INLINE bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; } -FORCE_INLINE bool no_axes_homed() { return !axis_homed; } -FORCE_INLINE bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); } -FORCE_INLINE bool homing_needed() { return !all_axes_homed(); } -FORCE_INLINE bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); } + inline void homeaxis(const AxisEnum axis) {} + inline void set_axis_never_homed(const AxisEnum) {} + inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } + inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } + inline void set_axis_unhomed(const AxisEnum axis) {} + inline void set_axis_untrusted(const AxisEnum axis) {} + inline void set_all_unhomed() {} + inline void set_axis_homed(const AxisEnum axis) {} + inline void set_axis_trusted(const AxisEnum axis) {} + inline void set_all_homed() {} +#endif + +inline bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); } +inline bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); } +inline bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; } +inline bool no_axes_homed() { return !axis_homed; } +inline bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); } +inline bool homing_needed() { return !all_axes_homed(); } +inline bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); } + +void home_if_needed(const bool keeplev=false); #if ENABLED(NO_MOTION_BEFORE_HOMING) #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error()) From 5e052adea74d5d28fd78e6ba0618e90397699a91 Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sun, 13 Jun 2021 09:12:18 +0200 Subject: [PATCH 3/3] Update G35.cpp Home only Z axis when X and Y is trusted, otherwise all axes --- Marlin/src/gcode/bedlevel/G35.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index f02588e4b998..52ae8b0a71ec 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -91,8 +91,8 @@ void GcodeSuite::G35() { // Disable duplication mode on homing TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); - // Home all axes if needed before this procedure - home_if_needed(); + // Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure + if (!all_axes_trusted()) queue.inject_P(PSTR("G28Z")); bool err_break = false; @@ -161,6 +161,9 @@ void GcodeSuite::G35() { probe.stow(); move_to_tramming_wait_pos(); + + // After this operation the Z position needs correction + set_axis_never_homed(Z_AXIS); } #endif // ASSISTED_TRAMMING