Skip to content

Commit 2b3faf0

Browse files
qwewer0ptoal
authored andcommitted
⚡️ Home Z (and maybe XY) at the start of G35 (MarlinFirmware#22060)
1 parent 5bc71f4 commit 2b3faf0

File tree

6 files changed

+36
-30
lines changed

6 files changed

+36
-30
lines changed

Marlin/src/gcode/bedlevel/G35.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void GcodeSuite::G35() {
9191
// Disable duplication mode on homing
9292
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));
9393

94-
// Home all before this procedure
95-
home_all_axes();
94+
// Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure
95+
if (!all_axes_trusted()) process_subcommands_now_P(PSTR("G28Z"));
9696

9797
bool err_break = false;
9898

Marlin/src/gcode/calibrate/G34.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
void GcodeSuite::G34() {
4040

4141
// Home before the alignment procedure
42-
if (!all_axes_trusted()) home_all_axes();
42+
home_if_needed();
4343

4444
TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false));
4545

Marlin/src/gcode/calibrate/G34_M422.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void GcodeSuite::G34() {
167167
));
168168

169169
// Home before the alignment procedure
170-
if (!all_axes_trusted()) home_all_axes();
170+
home_if_needed();
171171

172172
// Move the Z coordinate realm towards the positive - dirty trick
173173
current_position.z += z_probe * 0.5f;

Marlin/src/gcode/feature/pause/M600.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void GcodeSuite::M600() {
9999

100100
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
101101
// If needed, home before parking for filament change
102-
if (!all_axes_trusted()) home_all_axes(true);
102+
home_if_needed(true);
103103
#endif
104104

105105
#if HAS_MULTI_EXTRUDER

Marlin/src/module/motion.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ void report_current_position_projected() {
294294

295295
#endif
296296

297+
void home_if_needed(const bool keeplev/*=false*/) {
298+
if (!all_axes_trusted()) gcode.home_all_axes(keeplev);
299+
}
300+
297301
/**
298302
* Run out the planner buffer and re-sync the current
299303
* position from the last-updated stepper positions.

Marlin/src/module/motion.h

+27-25
Original file line numberDiff line numberDiff line change
@@ -392,33 +392,35 @@ void set_axis_is_at_home(const AxisEnum axis);
392392
void set_axis_never_homed(const AxisEnum axis);
393393
linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits=linear_bits);
394394
bool homing_needed_error(linear_axis_bits_t axis_bits=linear_bits);
395-
FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); }
396-
FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); }
397-
FORCE_INLINE void set_all_unhomed() { axis_homed = axis_trusted = 0; }
398-
FORCE_INLINE void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); }
399-
FORCE_INLINE void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); }
400-
FORCE_INLINE void set_all_homed() { axis_homed = axis_trusted = linear_bits; }
395+
inline void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); }
396+
inline void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); }
397+
inline void set_all_unhomed() { axis_homed = axis_trusted = 0; }
398+
inline void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); }
399+
inline void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); }
400+
inline void set_all_homed() { axis_homed = axis_trusted = linear_bits; }
401401
#else
402402
constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted
403-
FORCE_INLINE void homeaxis(const AxisEnum axis) {}
404-
FORCE_INLINE void set_axis_never_homed(const AxisEnum) {}
405-
FORCE_INLINE linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; }
406-
FORCE_INLINE bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; }
407-
FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) {}
408-
FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) {}
409-
FORCE_INLINE void set_all_unhomed() {}
410-
FORCE_INLINE void set_axis_homed(const AxisEnum axis) {}
411-
FORCE_INLINE void set_axis_trusted(const AxisEnum axis) {}
412-
FORCE_INLINE void set_all_homed() {}
413-
#endif
414-
415-
FORCE_INLINE bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); }
416-
FORCE_INLINE bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); }
417-
FORCE_INLINE bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; }
418-
FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
419-
FORCE_INLINE bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); }
420-
FORCE_INLINE bool homing_needed() { return !all_axes_homed(); }
421-
FORCE_INLINE bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); }
403+
inline void homeaxis(const AxisEnum axis) {}
404+
inline void set_axis_never_homed(const AxisEnum) {}
405+
inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; }
406+
inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; }
407+
inline void set_axis_unhomed(const AxisEnum axis) {}
408+
inline void set_axis_untrusted(const AxisEnum axis) {}
409+
inline void set_all_unhomed() {}
410+
inline void set_axis_homed(const AxisEnum axis) {}
411+
inline void set_axis_trusted(const AxisEnum axis) {}
412+
inline void set_all_homed() {}
413+
#endif
414+
415+
inline bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); }
416+
inline bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); }
417+
inline bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; }
418+
inline bool no_axes_homed() { return !axis_homed; }
419+
inline bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); }
420+
inline bool homing_needed() { return !all_axes_homed(); }
421+
inline bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); }
422+
423+
void home_if_needed(const bool keeplev=false);
422424

423425
#if ENABLED(NO_MOTION_BEFORE_HOMING)
424426
#define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())

0 commit comments

Comments
 (0)