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:
parent
0ee1a92971
commit
d631267548
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
Endstops endstops;
|
Endstops endstops;
|
||||||
|
|
||||||
// public:
|
// private:
|
||||||
|
|
||||||
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
|
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
|
||||||
volatile uint8_t Endstops::hit_state;
|
volatile uint8_t Endstops::hit_state;
|
||||||
@ -259,15 +259,13 @@ void Endstops::poll() {
|
|||||||
|
|
||||||
void Endstops::enable_globally(const bool onoff) {
|
void Endstops::enable_globally(const bool onoff) {
|
||||||
enabled_globally = enabled = onoff;
|
enabled_globally = enabled = onoff;
|
||||||
|
resync();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable / disable endstop checking
|
// Enable / disable endstop checking
|
||||||
void Endstops::enable(const bool onoff) {
|
void Endstops::enable(const bool onoff) {
|
||||||
enabled = onoff;
|
enabled = onoff;
|
||||||
|
resync();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
|
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
|
||||||
@ -287,11 +285,24 @@ void Endstops::not_homing() {
|
|||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
void Endstops::enable_z_probe(const bool onoff) {
|
void Endstops::enable_z_probe(const bool onoff) {
|
||||||
z_probe_enabled = onoff;
|
z_probe_enabled = onoff;
|
||||||
|
resync();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
#if ENABLED(PINS_DEBUGGING)
|
||||||
void Endstops::run_monitor() {
|
void Endstops::run_monitor() {
|
||||||
if (!monitor_flag) return;
|
if (!monitor_flag) return;
|
||||||
|
@ -162,6 +162,8 @@ class Endstops {
|
|||||||
static void enable_z_probe(const bool onoff=true);
|
static void enable_z_probe(const bool onoff=true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void resync();
|
||||||
|
|
||||||
// Debugging of endstops
|
// Debugging of endstops
|
||||||
#if ENABLED(PINS_DEBUGGING)
|
#if ENABLED(PINS_DEBUGGING)
|
||||||
static bool monitor_flag;
|
static bool monitor_flag;
|
||||||
|
Loading…
Reference in New Issue
Block a user