Browse Source

Extra insurance against endstop false positives (#11013)

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

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

143
     // Enable / disable endstop z-probe checking
143
     // Enable / disable endstop z-probe checking
144
     #if HAS_BED_PROBE
144
     #if HAS_BED_PROBE
145
       static volatile bool z_probe_enabled;
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
     #endif
147
     #endif
148
 
148
 
149
     // Debugging of endstops
149
     // Debugging of endstops

Loading…
Cancel
Save