Skip to content

Commit 49b05ba

Browse files
committed
🎨 Flags for homing directions
1 parent 85fa8c5 commit 49b05ba

27 files changed

+131
-114
lines changed

Marlin/src/HAL/LPC1768/inc/SanityCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
144144
#error "Serial port pins (2) conflict with Z4 pins!"
145145
#elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
146146
#error "Serial port pins (2) conflict with other pins!"
147-
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
147+
#elif Y_HOME_TO_MIN && IS_TX2(Y_STOP_PIN)
148148
#error "Serial port pins (2) conflict with Y endstop pin!"
149149
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
150150
#error "Serial port pins (2) conflict with probe pin!"

Marlin/src/feature/powerloss.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void PrintJobRecovery::resume() {
375375

376376
gcode.process_subcommands_now_P(PSTR("G92.9E0")); // Reset E to 0
377377

378-
#if Z_HOME_DIR > 0
378+
#if Z_HOME_TO_MAX
379379

380380
float z_now = z_raised;
381381

Marlin/src/gcode/calibrate/G28.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
current_position.set(0.0, 0.0);
7474
sync_plan_position();
7575

76-
const int x_axis_home_dir = x_home_dir(active_extruder);
76+
const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder);
7777

7878
const float mlx = max_length(X_AXIS),
7979
mly = max_length(Y_AXIS),

Marlin/src/inc/Conditionals_LCD.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,31 @@
814814
#endif
815815
#endif // FILAMENT_RUNOUT_SENSOR
816816

817+
// Homing to Min or Max
818+
#if X_HOME_DIR > 0
819+
#define X_HOME_TO_MAX 1
820+
#elif X_HOME_DIR < 0
821+
#define X_HOME_TO_MIN 1
822+
#endif
823+
#if Y_HOME_DIR > 0
824+
#define Y_HOME_TO_MAX 1
825+
#elif Y_HOME_DIR < 0
826+
#define Y_HOME_TO_MIN 1
827+
#endif
828+
#if Z_HOME_DIR > 0
829+
#define Z_HOME_TO_MAX 1
830+
#elif Z_HOME_DIR < 0
831+
#define Z_HOME_TO_MIN 1
832+
#endif
833+
817834
#if HAS_BED_PROBE
818835
#if DISABLED(NOZZLE_AS_PROBE)
819836
#define HAS_PROBE_XY_OFFSET 1
820837
#endif
821838
#if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && !BOTH(DELTA, SENSORLESS_PROBING)
822839
#define HAS_CUSTOM_PROBE_PIN 1
823840
#endif
824-
#if Z_HOME_DIR < 0 && (!HAS_CUSTOM_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING))
841+
#if Z_HOME_TO_MIN && (!HAS_CUSTOM_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING))
825842
#define HOMING_Z_WITH_PROBE 1
826843
#endif
827844
#ifndef Z_PROBE_LOW_POINT
@@ -843,7 +860,7 @@
843860
#undef USE_PROBE_FOR_Z_HOMING
844861
#endif
845862

846-
#if Z_HOME_DIR > 0
863+
#if Z_HOME_TO_MAX
847864
#define HOME_Z_FIRST // If homing away from BED do Z first
848865
#endif
849866

Marlin/src/inc/Conditionals_adv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@
391391
#define POLL_JOG
392392
#endif
393393

394+
#if X2_HOME_DIR > 0
395+
#define X2_HOME_TO_MAX 1
396+
#elif X2_HOME_DIR < 0
397+
#define X2_HOME_TO_MIN 1
398+
#endif
399+
394400
#ifndef HOMING_BUMP_MM
395401
#define HOMING_BUMP_MM { 0, 0, 0 }
396402
#endif

Marlin/src/inc/Conditionals_post.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
#ifdef MANUAL_X_HOME_POS
156156
#define X_HOME_POS MANUAL_X_HOME_POS
157157
#else
158-
#define X_END_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
158+
#define X_END_POS TERN(X_HOME_TO_MIN, X_MIN_POS, X_MAX_POS)
159159
#if ENABLED(BED_CENTER_AT_0_0)
160160
#define X_HOME_POS TERN(DELTA, 0, X_END_POS)
161161
#else
@@ -166,7 +166,7 @@
166166
#ifdef MANUAL_Y_HOME_POS
167167
#define Y_HOME_POS MANUAL_Y_HOME_POS
168168
#else
169-
#define Y_END_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
169+
#define Y_END_POS TERN(Y_HOME_TO_MIN, Y_MIN_POS, Y_MAX_POS)
170170
#if ENABLED(BED_CENTER_AT_0_0)
171171
#define Y_HOME_POS TERN(DELTA, 0, Y_END_POS)
172172
#else
@@ -177,7 +177,7 @@
177177
#ifdef MANUAL_Z_HOME_POS
178178
#define Z_HOME_POS MANUAL_Z_HOME_POS
179179
#else
180-
#define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS)
180+
#define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS)
181181
#endif
182182

183183
/**
@@ -798,7 +798,7 @@
798798
* X_DUAL_ENDSTOPS endstop reassignment
799799
*/
800800
#if ENABLED(X_DUAL_ENDSTOPS)
801-
#if X_HOME_DIR > 0
801+
#if X_HOME_TO_MAX
802802
#ifndef X2_MAX_ENDSTOP_INVERTING
803803
#if X2_USE_ENDSTOP == _XMIN_
804804
#define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
@@ -921,7 +921,7 @@
921921
* Y_DUAL_ENDSTOPS endstop reassignment
922922
*/
923923
#if ENABLED(Y_DUAL_ENDSTOPS)
924-
#if Y_HOME_DIR > 0
924+
#if Y_HOME_TO_MAX
925925
#ifndef Y2_MAX_ENDSTOP_INVERTING
926926
#if Y2_USE_ENDSTOP == _XMIN_
927927
#define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
@@ -1045,7 +1045,7 @@
10451045
*/
10461046
#if ENABLED(Z_MULTI_ENDSTOPS)
10471047

1048-
#if Z_HOME_DIR > 0
1048+
#if Z_HOME_TO_MAX
10491049
#ifndef Z2_MAX_ENDSTOP_INVERTING
10501050
#if Z2_USE_ENDSTOP == _XMIN_
10511051
#define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
@@ -1164,7 +1164,7 @@
11641164
#endif
11651165

11661166
#if NUM_Z_STEPPER_DRIVERS >= 3
1167-
#if Z_HOME_DIR > 0
1167+
#if Z_HOME_TO_MAX
11681168
#ifndef Z3_MAX_ENDSTOP_INVERTING
11691169
#if Z3_USE_ENDSTOP == _XMIN_
11701170
#define Z3_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
@@ -1284,7 +1284,7 @@
12841284
#endif
12851285

12861286
#if NUM_Z_STEPPER_DRIVERS >= 4
1287-
#if Z_HOME_DIR > 0
1287+
#if Z_HOME_TO_MAX
12881288
#ifndef Z4_MAX_ENDSTOP_INVERTING
12891289
#if Z4_USE_ENDSTOP == _XMIN_
12901290
#define Z4_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING

Marlin/src/inc/SanityCheck.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
16821682
* Allen Key
16831683
* Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis.
16841684
*/
1685-
#if BOTH(Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && Z_HOME_DIR < 0
1685+
#if ALL(Z_HOME_TO_MIN, Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
16861686
#error "You can't home to a Z min endstop with a Z_PROBE_ALLEN_KEY."
16871687
#endif
16881688

@@ -1700,7 +1700,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
17001700
#error "DUAL_X_CARRIAGE requires USE_XMAX_PLUG and an X Max Endstop."
17011701
#elif !defined(X2_HOME_POS) || !defined(X2_MIN_POS) || !defined(X2_MAX_POS)
17021702
#error "DUAL_X_CARRIAGE requires X2_HOME_POS, X2_MIN_POS, and X2_MAX_POS."
1703-
#elif X_HOME_DIR != -1 || X2_HOME_DIR != 1
1703+
#elif X_HOME_TO_MAX || X2_HOME_TO_MIN
17041704
#error "DUAL_X_CARRIAGE requires X_HOME_DIR -1 and X2_HOME_DIR 1."
17051705
#endif
17061706
#endif
@@ -2089,25 +2089,25 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
20892089

20902090
// Delta and Cartesian use 3 homing endstops
20912091
#if NONE(IS_SCARA, SPI_ENDSTOPS)
2092-
#if X_HOME_DIR < 0 && DISABLED(USE_XMIN_PLUG)
2092+
#if X_HOME_TO_MIN && DISABLED(USE_XMIN_PLUG)
20932093
#error "Enable USE_XMIN_PLUG when homing X to MIN."
2094-
#elif X_HOME_DIR > 0 && DISABLED(USE_XMAX_PLUG)
2094+
#elif X_HOME_TO_MAX && DISABLED(USE_XMAX_PLUG)
20952095
#error "Enable USE_XMAX_PLUG when homing X to MAX."
2096-
#elif Y_HOME_DIR < 0 && DISABLED(USE_YMIN_PLUG)
2096+
#elif Y_HOME_TO_MIN && DISABLED(USE_YMIN_PLUG)
20972097
#error "Enable USE_YMIN_PLUG when homing Y to MIN."
2098-
#elif Y_HOME_DIR > 0 && DISABLED(USE_YMAX_PLUG)
2098+
#elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG)
20992099
#error "Enable USE_YMAX_PLUG when homing Y to MAX."
21002100
#endif
21012101
#endif
21022102

21032103
// Z homing direction and plug usage flags
2104-
#if Z_HOME_DIR < 0 && NONE(USE_ZMIN_PLUG, HOMING_Z_WITH_PROBE)
2104+
#if Z_HOME_TO_MIN && NONE(USE_ZMIN_PLUG, HOMING_Z_WITH_PROBE)
21052105
#error "Enable USE_ZMIN_PLUG when homing Z to MIN."
2106-
#elif Z_HOME_DIR > 0 && ENABLED(USE_PROBE_FOR_Z_HOMING)
2106+
#elif Z_HOME_TO_MAX && ENABLED(USE_PROBE_FOR_Z_HOMING)
21072107
#error "Z_HOME_DIR must be -1 when homing Z with the probe."
21082108
#elif BOTH(HOMING_Z_WITH_PROBE, Z_MULTI_ENDSTOPS)
21092109
#error "Z_MULTI_ENDSTOPS is incompatible with USE_PROBE_FOR_Z_HOMING."
2110-
#elif Z_HOME_DIR > 0 && DISABLED(USE_ZMAX_PLUG)
2110+
#elif Z_HOME_TO_MAX && DISABLED(USE_ZMAX_PLUG)
21112111
#error "Enable USE_ZMAX_PLUG when homing Z to MAX."
21122112
#endif
21132113
#endif
@@ -2630,17 +2630,17 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
26302630
#define Z_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Z,TMC2209)
26312631

26322632
#if NONE(SPI_ENDSTOPS, ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS)
2633-
#if X_SENSORLESS && X_HOME_DIR < 0 && DISABLED(ENDSTOPPULLUP_XMIN)
2633+
#if X_SENSORLESS && X_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_XMIN)
26342634
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_XMIN (or ENDSTOPPULLUPS) when homing to X_MIN."
2635-
#elif X_SENSORLESS && X_HOME_DIR > 0 && DISABLED(ENDSTOPPULLUP_XMAX)
2635+
#elif X_SENSORLESS && X_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_XMAX)
26362636
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_XMAX (or ENDSTOPPULLUPS) when homing to X_MAX."
2637-
#elif Y_SENSORLESS && Y_HOME_DIR < 0 && DISABLED(ENDSTOPPULLUP_YMIN)
2637+
#elif Y_SENSORLESS && Y_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_YMIN)
26382638
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_YMIN (or ENDSTOPPULLUPS) when homing to Y_MIN."
2639-
#elif Y_SENSORLESS && Y_HOME_DIR > 0 && DISABLED(ENDSTOPPULLUP_YMAX)
2639+
#elif Y_SENSORLESS && Y_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_YMAX)
26402640
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_YMAX (or ENDSTOPPULLUPS) when homing to Y_MAX."
2641-
#elif Z_SENSORLESS && Z_HOME_DIR < 0 && DISABLED(ENDSTOPPULLUP_ZMIN)
2641+
#elif Z_SENSORLESS && Z_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_ZMIN)
26422642
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN."
2643-
#elif Z_SENSORLESS && Z_HOME_DIR > 0 && DISABLED(ENDSTOPPULLUP_ZMAX)
2643+
#elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX)
26442644
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX."
26452645
#endif
26462646
#endif
@@ -2650,37 +2650,37 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
26502650
#warning "SPI_ENDSTOPS may be unreliable with QUICK_HOME. Adjust back-offs for better results."
26512651
#endif
26522652
#else
2653-
#if X_SENSORLESS && X_HOME_DIR < 0 && X_MIN_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING
2653+
#if X_SENSORLESS && X_HOME_TO_MIN && X_MIN_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING
26542654
#if X_ENDSTOP_INVERTING
26552655
#error "SENSORLESS_HOMING requires X_MIN_ENDSTOP_INVERTING = true when homing to X_MIN."
26562656
#else
26572657
#error "SENSORLESS_HOMING requires X_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to X_MIN."
26582658
#endif
2659-
#elif X_SENSORLESS && X_HOME_DIR > 0 && X_MAX_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING
2659+
#elif X_SENSORLESS && X_HOME_TO_MAX && X_MAX_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING
26602660
#if X_ENDSTOP_INVERTING
26612661
#error "SENSORLESS_HOMING requires X_MAX_ENDSTOP_INVERTING = true when homing to X_MAX."
26622662
#else
26632663
#error "SENSORLESS_HOMING requires X_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to X_MAX."
26642664
#endif
2665-
#elif Y_SENSORLESS && Y_HOME_DIR < 0 && Y_MIN_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING
2665+
#elif Y_SENSORLESS && Y_HOME_TO_MIN && Y_MIN_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING
26662666
#if Y_ENDSTOP_INVERTING
26672667
#error "SENSORLESS_HOMING requires Y_MIN_ENDSTOP_INVERTING = true when homing to Y_MIN."
26682668
#else
26692669
#error "SENSORLESS_HOMING requires Y_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to Y_MIN."
26702670
#endif
2671-
#elif Y_SENSORLESS && Y_HOME_DIR > 0 && Y_MAX_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING
2671+
#elif Y_SENSORLESS && Y_HOME_TO_MAX && Y_MAX_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING
26722672
#if Y_ENDSTOP_INVERTING
26732673
#error "SENSORLESS_HOMING requires Y_MAX_ENDSTOP_INVERTING = true when homing to Y_MAX."
26742674
#else
26752675
#error "SENSORLESS_HOMING requires Y_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to Y_MAX."
26762676
#endif
2677-
#elif Z_SENSORLESS && Z_HOME_DIR < 0 && Z_MIN_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING
2677+
#elif Z_SENSORLESS && Z_HOME_TO_MIN && Z_MIN_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING
26782678
#if Z_ENDSTOP_INVERTING
26792679
#error "SENSORLESS_HOMING requires Z_MIN_ENDSTOP_INVERTING = true when homing to Z_MIN."
26802680
#else
26812681
#error "SENSORLESS_HOMING requires Z_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to Z_MIN."
26822682
#endif
2683-
#elif Z_SENSORLESS && Z_HOME_DIR > 0 && Z_MAX_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING
2683+
#elif Z_SENSORLESS && Z_HOME_TO_MAX && Z_MAX_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING
26842684
#if Z_ENDSTOP_INVERTING
26852685
#error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING = true when homing to Z_MAX."
26862686
#else
@@ -2918,9 +2918,9 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
29182918
#error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING."
29192919
#elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
29202920
#error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
2921-
#elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR > 0
2921+
#elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MAX
29222922
#error "POWER_LOSS_RECOVER_ZHOME is not needed on a machine that homes to ZMAX."
2923-
#elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR < 0 && !defined(POWER_LOSS_ZHOME_POS)
2923+
#elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MIN && !defined(POWER_LOSS_ZHOME_POS)
29242924
#error "POWER_LOSS_RECOVER_ZHOME requires POWER_LOSS_ZHOME_POS for a Cartesian that homes to ZMIN."
29252925
#endif
29262926
#endif

Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) {
6666
w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3));
6767
#endif
6868
#endif
69-
#if Z_HOME_DIR < 0
69+
#if Z_HOME_TO_MIN
7070
w.button(24, GET_TEXT_F(MSG_MOVE_Z_TO_TOP), !axis_should_home(Z_AXIS));
7171
#endif
7272
w.increments();

Marlin/src/lcd/marlinui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,12 @@ bool MarlinUI::get_blink() {
488488

489489
if (RRK(EN_KEYPAD_MIDDLE)) goto_screen(menu_move);
490490

491-
#if DISABLED(DELTA) && Z_HOME_DIR < 0
491+
#if NONE(DELTA, Z_HOME_TO_MAX)
492492
if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
493493
#endif
494494

495495
if (homed) {
496-
#if ENABLED(DELTA) || Z_HOME_DIR != -1
496+
#if EITHER(DELTA, Z_HOME_TO_MAX)
497497
if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
498498
#endif
499499
if (RRK(EN_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1);

Marlin/src/module/endstops.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,8 @@ void Endstops::update() {
513513
#endif
514514

515515
// With Dual X, endstops are only checked in the homing direction for the active extruder
516-
#if ENABLED(DUAL_X_CARRIAGE)
517-
#define E0_ACTIVE stepper.last_moved_extruder == 0
518-
#define X_MIN_TEST() ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE))
519-
#define X_MAX_TEST() ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE))
520-
#else
521-
#define X_MIN_TEST() true
522-
#define X_MAX_TEST() true
523-
#endif
516+
#define X_MIN_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MIN, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MIN, stepper.last_moved_extruder != 0))
517+
#define X_MAX_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MAX, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MAX, stepper.last_moved_extruder != 0))
524518

525519
// Use HEAD for core axes, AXIS for others
526520
#if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
@@ -765,7 +759,7 @@ void Endstops::update() {
765759

766760
if (stepper.axis_is_moving(X_AXIS)) {
767761
if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
768-
#if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_DIR < 0)
762+
#if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_TO_MIN)
769763
PROCESS_ENDSTOP_X(MIN);
770764
#if CORE_DIAG(XY, Y, MIN)
771765
PROCESS_CORE_ENDSTOP(Y,MIN,X,MIN);
@@ -779,7 +773,7 @@ void Endstops::update() {
779773
#endif
780774
}
781775
else { // +direction
782-
#if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_DIR > 0)
776+
#if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_TO_MAX)
783777
PROCESS_ENDSTOP_X(MAX);
784778
#if CORE_DIAG(XY, Y, MIN)
785779
PROCESS_CORE_ENDSTOP(Y,MIN,X,MAX);
@@ -796,7 +790,7 @@ void Endstops::update() {
796790

797791
if (stepper.axis_is_moving(Y_AXIS)) {
798792
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
799-
#if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_DIR < 0)
793+
#if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_TO_MIN)
800794
PROCESS_ENDSTOP_Y(MIN);
801795
#if CORE_DIAG(XY, X, MIN)
802796
PROCESS_CORE_ENDSTOP(X,MIN,Y,MIN);
@@ -810,7 +804,7 @@ void Endstops::update() {
810804
#endif
811805
}
812806
else { // +direction
813-
#if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_DIR > 0)
807+
#if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_TO_MAX)
814808
PROCESS_ENDSTOP_Y(MAX);
815809
#if CORE_DIAG(XY, X, MIN)
816810
PROCESS_CORE_ENDSTOP(X,MIN,Y,MAX);
@@ -828,7 +822,7 @@ void Endstops::update() {
828822
if (stepper.axis_is_moving(Z_AXIS)) {
829823
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
830824

831-
#if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_DIR < 0)
825+
#if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_TO_MIN)
832826
if ( TERN1(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, z_probe_enabled)
833827
&& TERN1(HAS_CUSTOM_PROBE_PIN, !z_probe_enabled)
834828
) PROCESS_ENDSTOP_Z(MIN);
@@ -849,7 +843,7 @@ void Endstops::update() {
849843
#endif
850844
}
851845
else { // Z +direction. Gantry up, bed down.
852-
#if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_DIR > 0)
846+
#if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_TO_MAX)
853847
#if ENABLED(Z_MULTI_ENDSTOPS)
854848
PROCESS_ENDSTOP_Z(MAX);
855849
#elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN // No probe or probe is Z_MIN || Probe is not Z_MAX

0 commit comments

Comments
 (0)