Skip to content

Commit 7425141

Browse files
jsrobson10thinkyhead
authored andcommitted
🐛 Fix G38 with Z, support 9 axes (MarlinFirmware#25691)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent c649960 commit 7425141

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

Marlin/src/inc/Conditionals_post.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,21 +341,21 @@
341341
#ifdef MANUAL_U_HOME_POS
342342
#define U_HOME_POS MANUAL_U_HOME_POS
343343
#else
344-
#define U_HOME_POS (U_HOME_DIR < 0 ? U_MIN_POS : U_MAX_POS)
344+
#define U_HOME_POS TERN(U_HOME_TO_MIN, U_MIN_POS, U_MAX_POS)
345345
#endif
346346
#endif
347347
#if HAS_V_AXIS
348348
#ifdef MANUAL_V_HOME_POS
349349
#define V_HOME_POS MANUAL_V_HOME_POS
350350
#else
351-
#define V_HOME_POS (V_HOME_DIR < 0 ? V_MIN_POS : V_MAX_POS)
351+
#define V_HOME_POS TERN(V_HOME_TO_MIN, V_MIN_POS, V_MAX_POS)
352352
#endif
353353
#endif
354354
#if HAS_W_AXIS
355355
#ifdef MANUAL_W_HOME_POS
356356
#define W_HOME_POS MANUAL_W_HOME_POS
357357
#else
358-
#define W_HOME_POS (W_HOME_DIR < 0 ? W_MIN_POS : W_MAX_POS)
358+
#define W_HOME_POS TERN(W_HOME_TO_MIN, W_MIN_POS, W_MAX_POS)
359359
#endif
360360
#endif
361361

Marlin/src/module/endstops.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -1107,17 +1107,13 @@ void Endstops::update() {
11071107
#endif
11081108

11091109
#if HAS_G38_PROBE // TODO (DerAndere): Add support for HAS_I_AXIS
1110-
#define _G38_OPEN_STATE TERN(G38_PROBE_AWAY, (G38_move >= 4), LOW)
11111110
// For G38 moves check the probe's pin for ALL movement
1112-
if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) != _G38_OPEN_STATE) {
1113-
if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); }
1114-
#if HAS_Y_AXIS
1115-
else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, TERN(Y_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Y_AXIS); }
1116-
#endif
1117-
#if HAS_Z_AXIS
1118-
else if (stepper.axis_is_moving(Z_AXIS)) { _ENDSTOP_HIT(Z, TERN(Z_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Z_AXIS); }
1119-
#endif
1111+
if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) {
11201112
G38_did_trigger = true;
1113+
#define _G38_SET(Q) | (stepper.axis_is_moving(_AXIS(Q)) << _AXIS(Q))
1114+
#define _G38_RESP(Q) if (moving[_AXIS(Q)]) { _ENDSTOP_HIT(Q, ENDSTOP); planner.endstop_triggered(_AXIS(Q)); }
1115+
const Flags<NUM_AXES> moving = { value_t(NUM_AXES)(0 MAIN_AXIS_MAP(_G38_SET)) };
1116+
MAIN_AXIS_MAP(_G38_RESP);
11211117
}
11221118
#endif
11231119

0 commit comments

Comments
 (0)