️ Home Z (and maybe XY) at the start of G35 (#22060)

This commit is contained in:
qwewer0 2021-06-14 23:52:42 +02:00 committed by Scott Lahteine
parent cdd9507493
commit dec083dcc1
6 changed files with 34 additions and 28 deletions

View file

@ -91,8 +91,8 @@ void GcodeSuite::G35() {
// Disable duplication mode on homing // Disable duplication mode on homing
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));
// Home all before this procedure // Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure
home_all_axes(); if (!all_axes_trusted()) process_subcommands_now_P(PSTR("G28Z"));
bool err_break = false; bool err_break = false;

View file

@ -39,7 +39,7 @@
void GcodeSuite::G34() { void GcodeSuite::G34() {
// Home before the alignment procedure // Home before the alignment procedure
if (!all_axes_trusted()) home_all_axes(); home_if_needed();
TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false)); TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false));

View file

@ -167,7 +167,7 @@ void GcodeSuite::G34() {
)); ));
// Home before the alignment procedure // 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 // Move the Z coordinate realm towards the positive - dirty trick
current_position.z += z_probe * 0.5f; current_position.z += z_probe * 0.5f;

View file

@ -99,7 +99,7 @@ void GcodeSuite::M600() {
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE) #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
// If needed, home before parking for filament change // If needed, home before parking for filament change
if (!all_axes_trusted()) home_all_axes(true); home_if_needed(true);
#endif #endif
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER

View file

@ -294,6 +294,10 @@ void report_current_position_projected() {
#endif #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 * Run out the planner buffer and re-sync the current
* position from the last-updated stepper positions. * position from the last-updated stepper positions.

View file

@ -392,33 +392,35 @@ void set_axis_is_at_home(const AxisEnum axis);
void set_axis_never_homed(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); 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); 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); } 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); } inline void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); }
FORCE_INLINE void set_all_unhomed() { axis_homed = axis_trusted = 0; } inline void set_all_unhomed() { axis_homed = axis_trusted = 0; }
FORCE_INLINE void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); } 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); } 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_all_homed() { axis_homed = axis_trusted = linear_bits; }
#else #else
constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted 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) {} inline void homeaxis(const AxisEnum axis) {}
FORCE_INLINE void set_axis_never_homed(const AxisEnum) {} 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; } 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; } inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; }
FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) {} inline void set_axis_unhomed(const AxisEnum axis) {}
FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) {} inline void set_axis_untrusted(const AxisEnum axis) {}
FORCE_INLINE void set_all_unhomed() {} inline void set_all_unhomed() {}
FORCE_INLINE void set_axis_homed(const AxisEnum axis) {} inline void set_axis_homed(const AxisEnum axis) {}
FORCE_INLINE void set_axis_trusted(const AxisEnum axis) {} inline void set_axis_trusted(const AxisEnum axis) {}
FORCE_INLINE void set_all_homed() {} inline void set_all_homed() {}
#endif #endif
FORCE_INLINE bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); } 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); } 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; } inline bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; }
FORCE_INLINE bool no_axes_homed() { return !axis_homed; } inline bool no_axes_homed() { return !axis_homed; }
FORCE_INLINE bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); } inline bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); }
FORCE_INLINE bool homing_needed() { return !all_axes_homed(); } inline bool homing_needed() { return !all_axes_homed(); }
FORCE_INLINE bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); } 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) #if ENABLED(NO_MOTION_BEFORE_HOMING)
#define MOTION_CONDITIONS (IsRunning() && !homing_needed_error()) #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())