From 18e456d38d8625ac13970fbfc4e6bdbb8adefc28 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Mon, 24 Sep 2018 22:56:01 +0200 Subject: [PATCH] [2.0.x] fix home endstop bug (DON'T MERGE, needs discussion) (#11900) --- Marlin/src/module/endstops.cpp | 19 ++++++++++++++----- Marlin/src/module/endstops.h | 3 +-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index f8f6db3d3..dbef281f0 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -246,10 +246,10 @@ void Endstops::poll() { run_monitor(); // report changes in endstop status #endif - #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && ENABLED(ENDSTOP_NOISE_FILTER) - if (endstop_poll_count) update(); - #elif DISABLED(ENDSTOP_INTERRUPTS_FEATURE) || ENABLED(ENDSTOP_NOISE_FILTER) + #if DISABLED(ENDSTOP_INTERRUPTS_FEATURE) update(); + #elif ENABLED(ENDSTOP_NOISE_FILTER) + if (endstop_poll_count) update(); #endif } @@ -275,7 +275,16 @@ void Endstops::not_homing() { enabled = enabled_globally; #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) - update(); + // Still 'enabled'? Then endstops are always on and kept in sync. + // Otherwise reset 'live's variables to let axes move in both directions. + if (!enabled) { + #if ENABLED(ENDSTOP_NOISE_FILTER) + endstop_poll_count = validated_live_state = 0; // Stop filtering + #endif + live_state = 0; + } + //#else + // When in polling endstops are always kept in sync #endif } @@ -666,7 +675,7 @@ void Endstops::update() { if (triple_hit) { \ _ENDSTOP_HIT(AXIS1, MINMAX); \ /* if not performing home or if both endstops were trigged during homing... */ \ - if (!stepper.separate_multi_axis || triple_hit == 0x7) \ + if (!stepper.separate_multi_axis || triple_hit == 0b111) \ planner.endstop_triggered(_AXIS(AXIS1)); \ } \ }while(0) diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index cf3f0df7c..0e52e0d00 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -54,8 +54,6 @@ class Endstops { public: - static bool enabled, enabled_globally; - #if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS typedef uint16_t esbits_t; #if ENABLED(X_DUAL_ENDSTOPS) @@ -75,6 +73,7 @@ class Endstops { #endif private: + static bool enabled, enabled_globally; static esbits_t live_state; static volatile uint8_t hit_state; // Use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT index