Refine endstops fixes (#12413)

When endstops/probe are enabled `ENDSTOP_NOISE_THRESHOLD` calls to `update` are required to properly re-sync endstops/probe status.
This commit is contained in:
Giuliano Zaro 2018-11-13 11:31:58 +01:00 committed by Scott Lahteine
parent 0ee1a92971
commit d631267548
2 changed files with 20 additions and 7 deletions

View File

@ -42,7 +42,7 @@
Endstops endstops;
// public:
// private:
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
volatile uint8_t Endstops::hit_state;
@ -259,15 +259,13 @@ void Endstops::poll() {
void Endstops::enable_globally(const bool onoff) {
enabled_globally = enabled = onoff;
update();
resync();
}
// Enable / disable endstop checking
void Endstops::enable(const bool onoff) {
enabled = onoff;
update();
resync();
}
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
@ -287,11 +285,24 @@ void Endstops::not_homing() {
#if HAS_BED_PROBE
void Endstops::enable_z_probe(const bool onoff) {
z_probe_enabled = onoff;
update();
resync();
}
#endif
// Get the stable endstop states when enabled
void Endstops::resync() {
if (!abort_enabled()) return; // If endstops/probes are disabled the loop below can hang
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !ENDSTOP_NOISE_THRESHOLD
update();
#else
safe_delay(2); // Wait for Temperature ISR (runs at 1KHz)
#endif
#if ENDSTOP_NOISE_THRESHOLD
while (endstop_poll_count) safe_delay(1);
#endif
}
#if ENABLED(PINS_DEBUGGING)
void Endstops::run_monitor() {
if (!monitor_flag) return;

View File

@ -162,6 +162,8 @@ class Endstops {
static void enable_z_probe(const bool onoff=true);
#endif
static void resync();
// Debugging of endstops
#if ENABLED(PINS_DEBUGGING)
static bool monitor_flag;