Browse Source

Extra insurance against endstop false positives (#11013)

Scott Lahteine 6 years ago
parent
commit
4c8d6df13c
No account linked to committer's email address
2 changed files with 13 additions and 16 deletions
  1. 12
    15
      Marlin/src/module/endstops.cpp
  2. 1
    1
      Marlin/src/module/endstops.h

+ 12
- 15
Marlin/src/module/endstops.cpp View File

@@ -265,7 +265,7 @@ void Endstops::not_homing() {
265 265
 
266 266
 // Enable / disable endstop z-probe checking
267 267
 #if HAS_BED_PROBE
268
-  void Endstops::enable_z_probe(bool onoff) {
268
+  void Endstops::enable_z_probe(const bool onoff) {
269 269
     z_probe_enabled = onoff;
270 270
 
271 271
     #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
@@ -439,7 +439,7 @@ void Endstops::update() {
439 439
   if (stepper.axis_is_moving(X_AXIS)) {
440 440
     if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
441 441
       #if HAS_X_MIN
442
-        #if ENABLED(X_DUAL_ENDSTOPS)
442
+        #if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR < 0
443 443
           UPDATE_ENDSTOP_BIT(X, MIN);
444 444
           #if HAS_X2_MIN
445 445
             UPDATE_ENDSTOP_BIT(X2, MIN);
@@ -453,7 +453,7 @@ void Endstops::update() {
453 453
     }
454 454
     else { // +direction
455 455
       #if HAS_X_MAX
456
-        #if ENABLED(X_DUAL_ENDSTOPS)
456
+        #if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR > 0
457 457
           UPDATE_ENDSTOP_BIT(X, MAX);
458 458
           #if HAS_X2_MAX
459 459
             UPDATE_ENDSTOP_BIT(X2, MAX);
@@ -469,7 +469,7 @@ void Endstops::update() {
469 469
 
470 470
   if (stepper.axis_is_moving(Y_AXIS)) {
471 471
     if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
472
-      #if HAS_Y_MIN
472
+      #if HAS_Y_MIN && Y_HOME_DIR < 0
473 473
         #if ENABLED(Y_DUAL_ENDSTOPS)
474 474
           UPDATE_ENDSTOP_BIT(Y, MIN);
475 475
           #if HAS_Y2_MIN
@@ -483,7 +483,7 @@ void Endstops::update() {
483 483
       #endif
484 484
     }
485 485
     else { // +direction
486
-      #if HAS_Y_MAX
486
+      #if HAS_Y_MAX && Y_HOME_DIR > 0
487 487
         #if ENABLED(Y_DUAL_ENDSTOPS)
488 488
           UPDATE_ENDSTOP_BIT(Y, MAX);
489 489
           #if HAS_Y2_MAX
@@ -501,19 +501,17 @@ void Endstops::update() {
501 501
   if (stepper.axis_is_moving(Z_AXIS)) {
502 502
     if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
503 503
       #if HAS_Z_MIN
504
-        #if ENABLED(Z_DUAL_ENDSTOPS)
504
+        #if ENABLED(Z_DUAL_ENDSTOPS) && Z_HOME_DIR < 0
505 505
           UPDATE_ENDSTOP_BIT(Z, MIN);
506 506
           #if HAS_Z2_MIN
507 507
             UPDATE_ENDSTOP_BIT(Z2, MIN);
508 508
           #else
509 509
             COPY_BIT(live_state, Z_MIN, Z2_MIN);
510 510
           #endif
511
-        #else
512
-          #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
513
-            if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
514
-          #else
515
-            UPDATE_ENDSTOP_BIT(Z, MIN);
516
-          #endif
511
+        #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
512
+          if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
513
+        #elif Z_HOME_DIR < 0
514
+          UPDATE_ENDSTOP_BIT(Z, MIN);
517 515
         #endif
518 516
       #endif
519 517
 
@@ -523,7 +521,7 @@ void Endstops::update() {
523 521
       #endif
524 522
     }
525 523
     else { // Z +direction. Gantry up, bed down.
526
-      #if HAS_Z_MAX
524
+      #if HAS_Z_MAX && Z_HOME_DIR > 0
527 525
         // Check both Z dual endstops
528 526
         #if ENABLED(Z_DUAL_ENDSTOPS)
529 527
           UPDATE_ENDSTOP_BIT(Z, MAX);
@@ -532,9 +530,8 @@ void Endstops::update() {
532 530
           #else
533 531
             COPY_BIT(live_state, Z_MAX, Z2_MAX);
534 532
           #endif
535
-        // If this pin is not hijacked for the bed probe
536
-        // then it belongs to the Z endstop
537 533
         #elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
534
+          // If this pin isn't the bed probe it's the Z endstop
538 535
           UPDATE_ENDSTOP_BIT(Z, MAX);
539 536
         #endif
540 537
       #endif

+ 1
- 1
Marlin/src/module/endstops.h View File

@@ -143,7 +143,7 @@ class Endstops {
143 143
     // Enable / disable endstop z-probe checking
144 144
     #if HAS_BED_PROBE
145 145
       static volatile bool z_probe_enabled;
146
-      static void enable_z_probe(bool onoff=true);
146
+      static void enable_z_probe(const bool onoff=true);
147 147
     #endif
148 148
 
149 149
     // Debugging of endstops

Loading…
Cancel
Save