|
@@ -42,7 +42,7 @@
|
42
|
42
|
|
43
|
43
|
Endstops endstops;
|
44
|
44
|
|
45
|
|
-// public:
|
|
45
|
+// private:
|
46
|
46
|
|
47
|
47
|
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
|
48
|
48
|
volatile uint8_t Endstops::hit_state;
|
|
@@ -259,15 +259,13 @@ void Endstops::poll() {
|
259
|
259
|
|
260
|
260
|
void Endstops::enable_globally(const bool onoff) {
|
261
|
261
|
enabled_globally = enabled = onoff;
|
262
|
|
-
|
263
|
|
- update();
|
|
262
|
+ resync();
|
264
|
263
|
}
|
265
|
264
|
|
266
|
265
|
// Enable / disable endstop checking
|
267
|
266
|
void Endstops::enable(const bool onoff) {
|
268
|
267
|
enabled = onoff;
|
269
|
|
-
|
270
|
|
- update();
|
|
268
|
+ resync();
|
271
|
269
|
}
|
272
|
270
|
|
273
|
271
|
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
|
|
@@ -287,11 +285,24 @@ void Endstops::not_homing() {
|
287
|
285
|
#if HAS_BED_PROBE
|
288
|
286
|
void Endstops::enable_z_probe(const bool onoff) {
|
289
|
287
|
z_probe_enabled = onoff;
|
290
|
|
-
|
291
|
|
- update();
|
|
288
|
+ resync();
|
292
|
289
|
}
|
293
|
290
|
#endif
|
294
|
291
|
|
|
292
|
+// Get the stable endstop states when enabled
|
|
293
|
+void Endstops::resync() {
|
|
294
|
+ if (!abort_enabled()) return; // If endstops/probes are disabled the loop below can hang
|
|
295
|
+
|
|
296
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !ENDSTOP_NOISE_THRESHOLD
|
|
297
|
+ update();
|
|
298
|
+ #else
|
|
299
|
+ safe_delay(2); // Wait for Temperature ISR (runs at 1KHz)
|
|
300
|
+ #endif
|
|
301
|
+ #if ENDSTOP_NOISE_THRESHOLD
|
|
302
|
+ while (endstop_poll_count) safe_delay(1);
|
|
303
|
+ #endif
|
|
304
|
+}
|
|
305
|
+
|
295
|
306
|
#if ENABLED(PINS_DEBUGGING)
|
296
|
307
|
void Endstops::run_monitor() {
|
297
|
308
|
if (!monitor_flag) return;
|