Browse Source

🐛 Fix G38 with probe on Z_MIN (#22452)

Grayson 3 years ago
parent
commit
a90c8b762c
No account linked to committer's email address

+ 2
- 2
Marlin/src/inc/Conditionals_LCD.h View File

@@ -771,7 +771,7 @@
771 771
 #endif
772 772
 
773 773
 /**
774
- * Set flags for enabled probes
774
+ * Set a flag for any type of bed probe, including the paper-test
775 775
  */
776 776
 #if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE)
777 777
   #define HAS_BED_PROBE 1
@@ -913,7 +913,7 @@
913 913
   #if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && !BOTH(DELTA, SENSORLESS_PROBING)
914 914
     #define USES_Z_MIN_PROBE_PIN 1
915 915
   #endif
916
-  #if Z_HOME_TO_MIN && (!USES_Z_MIN_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING))
916
+  #if Z_HOME_TO_MIN && TERN1(USES_Z_MIN_PROBE_PIN, ENABLED(USE_PROBE_FOR_Z_HOMING))
917 917
     #define HOMING_Z_WITH_PROBE 1
918 918
   #endif
919 919
   #ifndef Z_PROBE_LOW_POINT

+ 1
- 1
Marlin/src/inc/Conditionals_post.h View File

@@ -2166,7 +2166,7 @@
2166 2166
 #if PIN_EXISTS(Z4_MAX)
2167 2167
   #define HAS_Z4_MAX 1
2168 2168
 #endif
2169
-#if BOTH(HAS_BED_PROBE, USES_Z_MIN_PROBE_PIN) && PIN_EXISTS(Z_MIN_PROBE)
2169
+#if HAS_BED_PROBE && PIN_EXISTS(Z_MIN_PROBE)
2170 2170
   #define HAS_Z_MIN_PROBE_PIN 1
2171 2171
 #endif
2172 2172
 

+ 16
- 18
Marlin/src/module/endstops.cpp View File

@@ -596,14 +596,15 @@ void _O2 Endstops::report_states() {
596 596
 // endstop ISR or the Stepper ISR.
597 597
 
598 598
 #if BOTH(DELTA, SENSORLESS_PROBING)
599
-  #define _ENDSTOP(AXIS, MINMAX) AXIS ##_MAX
600
-  #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_MAX_PIN
601
-  #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_MAX_ENDSTOP_INVERTING
599
+  #define __ENDSTOP(AXIS, ...) AXIS ##_MAX
600
+  #define _ENDSTOP_PIN(AXIS, ...) AXIS ##_MAX_PIN
601
+  #define _ENDSTOP_INVERTING(AXIS, ...) AXIS ##_MAX_ENDSTOP_INVERTING
602 602
 #else
603
-  #define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
603
+  #define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
604 604
   #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
605 605
   #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
606 606
 #endif
607
+#define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX)
607 608
 
608 609
 // Check endstops - Could be called from Temperature ISR!
609 610
 void Endstops::update() {
@@ -615,9 +616,10 @@ void Endstops::update() {
615 616
   #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
616 617
   #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))
617 618
 
618
-  #if BOTH(G38_PROBE_TARGET, HAS_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
619
-    // If G38 command is active check Z_MIN_PROBE for ALL movement
620
-    if (G38_move) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
619
+  #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
620
+    #define HAS_G38_PROBE 1
621
+    // For G38 moves check the probe's pin for ALL movement
622
+    if (G38_move) UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN));
621 623
   #endif
622 624
 
623 625
   // With Dual X, endstops are only checked in the homing direction for the active extruder
@@ -746,7 +748,7 @@ void Endstops::update() {
746 748
           COPY_LIVE_STATE(Z_MAX, Z4_MAX);
747 749
         #endif
748 750
       #endif
749
-    #elif !USES_Z_MIN_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN
751
+    #elif TERN1(USES_Z_MIN_PROBE_PIN, Z_MAX_PIN != Z_MIN_PROBE_PIN)
750 752
       // If this pin isn't the bed probe it's the Z endstop
751 753
       UPDATE_ENDSTOP_BIT(Z, MAX);
752 754
     #endif
@@ -930,15 +932,11 @@ void Endstops::update() {
930 932
     #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX)
931 933
   #endif
932 934
 
933
-  #if BOTH(G38_PROBE_TARGET, HAS_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
934
-    #if ENABLED(G38_PROBE_AWAY)
935
-      #define _G38_OPEN_STATE (G38_move >= 4)
936
-    #else
937
-      #define _G38_OPEN_STATE LOW
938
-    #endif
939
-    // If G38 command is active check Z_MIN_PROBE for ALL movement
940
-    if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE)) != _G38_OPEN_STATE) {
941
-           if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); }
935
+  #if HAS_G38_PROBE
936
+    #define _G38_OPEN_STATE TERN(G38_PROBE_AWAY, (G38_move >= 4), LOW)
937
+    // For G38 moves check the probe's pin for ALL movement
938
+    if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) != _G38_OPEN_STATE) {
939
+             if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); }
942 940
       #if HAS_Y_AXIS
943 941
         else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, TERN(Y_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Y_AXIS); }
944 942
       #endif
@@ -1043,7 +1041,7 @@ void Endstops::update() {
1043 1041
         #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_TO_MAX)
1044 1042
           #if ENABLED(Z_MULTI_ENDSTOPS)
1045 1043
             PROCESS_ENDSTOP_Z(MAX);
1046
-          #elif !USES_Z_MIN_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN  // No probe or probe is Z_MIN || Probe is not Z_MAX
1044
+          #elif TERN1(USES_Z_MIN_PROBE_PIN, Z_MAX_PIN != Z_MIN_PROBE_PIN)  // No probe or probe is Z_MIN || Probe is not Z_MAX
1047 1045
             PROCESS_ENDSTOP(Z, MAX);
1048 1046
           #endif
1049 1047
           #if   CORE_DIAG(XZ, X, MIN)

Loading…
Cancel
Save