|
@@ -32,18 +32,27 @@
|
32
|
32
|
#include "../module/temperature.h"
|
33
|
33
|
#include "../lcd/ultralcd.h"
|
34
|
34
|
|
35
|
|
-// TEST_ENDSTOP: test the old and the current status of an endstop
|
36
|
|
-#define TEST_ENDSTOP(ENDSTOP) (TEST(current_endstop_bits & old_endstop_bits, ENDSTOP))
|
|
35
|
+#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
36
|
+ #include HAL_PATH(../HAL, endstop_interrupts.h)
|
|
37
|
+#endif
|
|
38
|
+
|
|
39
|
+// TEST_ENDSTOP: test the current status of an endstop
|
|
40
|
+#define TEST_ENDSTOP(ENDSTOP) (TEST(current_endstop_bits, ENDSTOP))
|
|
41
|
+
|
|
42
|
+#if HAS_BED_PROBE
|
|
43
|
+ #define ENDSTOPS_ENABLED (endstops.enabled || endstops.z_probe_enabled)
|
|
44
|
+#else
|
|
45
|
+ #define ENDSTOPS_ENABLED endstops.enabled
|
|
46
|
+#endif
|
37
|
47
|
|
38
|
48
|
Endstops endstops;
|
39
|
49
|
|
40
|
50
|
// public:
|
41
|
51
|
|
42
|
52
|
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
|
43
|
|
-volatile char Endstops::endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
|
|
53
|
+volatile uint8_t Endstops::endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
|
44
|
54
|
|
45
|
|
-Endstops::esbits_t Endstops::current_endstop_bits = 0,
|
46
|
|
- Endstops::old_endstop_bits = 0;
|
|
55
|
+Endstops::esbits_t Endstops::current_endstop_bits = 0;
|
47
|
56
|
|
48
|
57
|
#if HAS_BED_PROBE
|
49
|
58
|
volatile bool Endstops::z_probe_enabled = false;
|
|
@@ -196,8 +205,93 @@ void Endstops::init() {
|
196
|
205
|
#endif
|
197
|
206
|
#endif
|
198
|
207
|
|
|
208
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
209
|
+ setup_endstop_interrupts();
|
|
210
|
+ #endif
|
|
211
|
+
|
|
212
|
+ // Enable endstops
|
|
213
|
+ enable_globally(
|
|
214
|
+ #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
|
|
215
|
+ true
|
|
216
|
+ #else
|
|
217
|
+ false
|
|
218
|
+ #endif
|
|
219
|
+ );
|
|
220
|
+
|
199
|
221
|
} // Endstops::init
|
200
|
222
|
|
|
223
|
+// Called from ISR. A change was detected. Find out what happened!
|
|
224
|
+void Endstops::check_possible_change() { if (ENDSTOPS_ENABLED) endstops.update(); }
|
|
225
|
+
|
|
226
|
+// Called from ISR: Poll endstop state if required
|
|
227
|
+void Endstops::poll() {
|
|
228
|
+
|
|
229
|
+ #if ENABLED(PINS_DEBUGGING)
|
|
230
|
+ endstops.run_monitor(); // report changes in endstop status
|
|
231
|
+ #endif
|
|
232
|
+
|
|
233
|
+ #if DISABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
234
|
+ if (ENDSTOPS_ENABLED) endstops.update();
|
|
235
|
+ #endif
|
|
236
|
+}
|
|
237
|
+
|
|
238
|
+void Endstops::enable_globally(const bool onoff) {
|
|
239
|
+ enabled_globally = enabled = onoff;
|
|
240
|
+
|
|
241
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
242
|
+ if (onoff) endstops.update(); // If enabling, update state now
|
|
243
|
+ #endif
|
|
244
|
+}
|
|
245
|
+
|
|
246
|
+// Enable / disable endstop checking
|
|
247
|
+void Endstops::enable(const bool onoff) {
|
|
248
|
+ enabled = onoff;
|
|
249
|
+
|
|
250
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
251
|
+ if (onoff) endstops.update(); // If enabling, update state now
|
|
252
|
+ #endif
|
|
253
|
+}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
|
|
257
|
+void Endstops::not_homing() {
|
|
258
|
+ enabled = enabled_globally;
|
|
259
|
+
|
|
260
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
261
|
+ if (enabled) endstops.update(); // If enabling, update state now
|
|
262
|
+ #endif
|
|
263
|
+}
|
|
264
|
+
|
|
265
|
+// Clear endstops (i.e., they were hit intentionally) to suppress the report
|
|
266
|
+void Endstops::hit_on_purpose() {
|
|
267
|
+ endstop_hit_bits = 0;
|
|
268
|
+
|
|
269
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
270
|
+ if (enabled) endstops.update(); // If enabling, update state now
|
|
271
|
+ #endif
|
|
272
|
+}
|
|
273
|
+
|
|
274
|
+// Enable / disable endstop z-probe checking
|
|
275
|
+#if HAS_BED_PROBE
|
|
276
|
+ void Endstops::enable_z_probe(bool onoff) {
|
|
277
|
+ z_probe_enabled = onoff;
|
|
278
|
+
|
|
279
|
+ #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
280
|
+ if (enabled) endstops.update(); // If enabling, update state now
|
|
281
|
+ #endif
|
|
282
|
+ }
|
|
283
|
+#endif
|
|
284
|
+
|
|
285
|
+#if ENABLED(PINS_DEBUGGING)
|
|
286
|
+ void Endstops::run_monitor() {
|
|
287
|
+ if (!monitor_flag) return;
|
|
288
|
+ static uint8_t monitor_count = 16; // offset this check from the others
|
|
289
|
+ monitor_count += _BV(1); // 15 Hz
|
|
290
|
+ monitor_count &= 0x7F;
|
|
291
|
+ if (!monitor_count) monitor(); // report changes in endstop status
|
|
292
|
+ }
|
|
293
|
+#endif
|
|
294
|
+
|
201
|
295
|
void Endstops::report_state() {
|
202
|
296
|
if (endstop_hit_bits) {
|
203
|
297
|
#if ENABLED(ULTRA_LCD)
|
|
@@ -300,38 +394,41 @@ void Endstops::M119() {
|
300
|
394
|
#endif
|
301
|
395
|
} // Endstops::M119
|
302
|
396
|
|
|
397
|
+// The following routines are called from an ISR context. It could be the temperature ISR, the
|
|
398
|
+// endstop ISR or the Stepper ISR.
|
|
399
|
+
|
303
|
400
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
304
|
401
|
void Endstops::test_dual_x_endstops(const EndstopEnum es1, const EndstopEnum es2) {
|
305
|
402
|
const byte x_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for X, bit 1 for X2
|
306
|
|
- if (x_test && stepper.current_block->steps[X_AXIS] > 0) {
|
|
403
|
+ if (x_test && stepper.movement_non_null(X_AXIS)) {
|
307
|
404
|
SBI(endstop_hit_bits, X_MIN);
|
308
|
405
|
if (!stepper.performing_homing || (x_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
|
309
|
|
- stepper.kill_current_block();
|
|
406
|
+ stepper.quick_stop();
|
310
|
407
|
}
|
311
|
408
|
}
|
312
|
409
|
#endif
|
313
|
410
|
#if ENABLED(Y_DUAL_ENDSTOPS)
|
314
|
411
|
void Endstops::test_dual_y_endstops(const EndstopEnum es1, const EndstopEnum es2) {
|
315
|
412
|
const byte y_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for Y, bit 1 for Y2
|
316
|
|
- if (y_test && stepper.current_block->steps[Y_AXIS] > 0) {
|
|
413
|
+ if (y_test && stepper.movement_non_null(Y_AXIS)) {
|
317
|
414
|
SBI(endstop_hit_bits, Y_MIN);
|
318
|
415
|
if (!stepper.performing_homing || (y_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
|
319
|
|
- stepper.kill_current_block();
|
|
416
|
+ stepper.quick_stop();
|
320
|
417
|
}
|
321
|
418
|
}
|
322
|
419
|
#endif
|
323
|
420
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
324
|
421
|
void Endstops::test_dual_z_endstops(const EndstopEnum es1, const EndstopEnum es2) {
|
325
|
422
|
const byte z_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for Z, bit 1 for Z2
|
326
|
|
- if (z_test && stepper.current_block->steps[Z_AXIS] > 0) {
|
|
423
|
+ if (z_test && stepper.movement_non_null(Z_AXIS)) {
|
327
|
424
|
SBI(endstop_hit_bits, Z_MIN);
|
328
|
425
|
if (!stepper.performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
|
329
|
|
- stepper.kill_current_block();
|
|
426
|
+ stepper.quick_stop();
|
330
|
427
|
}
|
331
|
428
|
}
|
332
|
429
|
#endif
|
333
|
430
|
|
334
|
|
-// Check endstops - Called from ISR!
|
|
431
|
+// Check endstops - Could be called from ISR!
|
335
|
432
|
void Endstops::update() {
|
336
|
433
|
|
337
|
434
|
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
|
|
@@ -358,9 +455,9 @@ void Endstops::update() {
|
358
|
455
|
if (G38_move) {
|
359
|
456
|
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
|
360
|
457
|
if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
|
361
|
|
- if (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(_AXIS(X)); }
|
362
|
|
- else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(_AXIS(Y)); }
|
363
|
|
- else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(_AXIS(Z)); }
|
|
458
|
+ if (stepper.movement_non_null(_AXIS(X))) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(_AXIS(X)); }
|
|
459
|
+ else if (stepper.movement_non_null(_AXIS(Y))) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(_AXIS(Y)); }
|
|
460
|
+ else if (stepper.movement_non_null(_AXIS(Z))) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(_AXIS(Z)); }
|
364
|
461
|
G38_endstop_hit = true;
|
365
|
462
|
}
|
366
|
463
|
}
|
|
@@ -371,7 +468,7 @@ void Endstops::update() {
|
371
|
468
|
*/
|
372
|
469
|
|
373
|
470
|
#if IS_CORE
|
374
|
|
- #define S_(N) stepper.current_block->steps[CORE_AXIS_##N]
|
|
471
|
+ #define S_(N) stepper.movement_non_null(CORE_AXIS_##N)
|
375
|
472
|
#define D_(N) stepper.motor_direction(CORE_AXIS_##N)
|
376
|
473
|
#endif
|
377
|
474
|
|
|
@@ -391,7 +488,7 @@ void Endstops::update() {
|
391
|
488
|
#define X_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) X_CMP D_(2)) )
|
392
|
489
|
#define X_AXIS_HEAD X_HEAD
|
393
|
490
|
#else
|
394
|
|
- #define X_MOVE_TEST stepper.current_block->steps[X_AXIS] > 0
|
|
491
|
+ #define X_MOVE_TEST stepper.movement_non_null(X_AXIS)
|
395
|
492
|
#define X_AXIS_HEAD X_AXIS
|
396
|
493
|
#endif
|
397
|
494
|
|
|
@@ -411,7 +508,7 @@ void Endstops::update() {
|
411
|
508
|
#define Y_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Y_CMP D_(2)) )
|
412
|
509
|
#define Y_AXIS_HEAD Y_HEAD
|
413
|
510
|
#else
|
414
|
|
- #define Y_MOVE_TEST stepper.current_block->steps[Y_AXIS] > 0
|
|
511
|
+ #define Y_MOVE_TEST stepper.movement_non_null(Y_AXIS)
|
415
|
512
|
#define Y_AXIS_HEAD Y_AXIS
|
416
|
513
|
#endif
|
417
|
514
|
|
|
@@ -431,13 +528,13 @@ void Endstops::update() {
|
431
|
528
|
#define Z_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Z_CMP D_(2)) )
|
432
|
529
|
#define Z_AXIS_HEAD Z_HEAD
|
433
|
530
|
#else
|
434
|
|
- #define Z_MOVE_TEST stepper.current_block->steps[Z_AXIS] > 0
|
|
531
|
+ #define Z_MOVE_TEST stepper.movement_non_null(Z_AXIS)
|
435
|
532
|
#define Z_AXIS_HEAD Z_AXIS
|
436
|
533
|
#endif
|
437
|
534
|
|
438
|
535
|
// With Dual X, endstops are only checked in the homing direction for the active extruder
|
439
|
536
|
#if ENABLED(DUAL_X_CARRIAGE)
|
440
|
|
- #define E0_ACTIVE stepper.current_block->active_extruder == 0
|
|
537
|
+ #define E0_ACTIVE stepper.movement_extruder() == 0
|
441
|
538
|
#define X_MIN_TEST ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE))
|
442
|
539
|
#define X_MAX_TEST ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE))
|
443
|
540
|
#else
|
|
@@ -448,126 +545,119 @@ void Endstops::update() {
|
448
|
545
|
/**
|
449
|
546
|
* Check and update endstops according to conditions
|
450
|
547
|
*/
|
451
|
|
- if (stepper.current_block) {
|
452
|
|
-
|
453
|
|
- if (X_MOVE_TEST) {
|
454
|
|
- if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
|
455
|
|
- #if HAS_X_MIN
|
456
|
|
- #if ENABLED(X_DUAL_ENDSTOPS)
|
457
|
|
- UPDATE_ENDSTOP_BIT(X, MIN);
|
458
|
|
- #if HAS_X2_MIN
|
459
|
|
- UPDATE_ENDSTOP_BIT(X2, MIN);
|
460
|
|
- #else
|
461
|
|
- COPY_BIT(current_endstop_bits, X_MIN, X2_MIN);
|
462
|
|
- #endif
|
463
|
|
- test_dual_x_endstops(X_MIN, X2_MIN);
|
|
548
|
+ if (X_MOVE_TEST) {
|
|
549
|
+ if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
|
|
550
|
+ #if HAS_X_MIN
|
|
551
|
+ #if ENABLED(X_DUAL_ENDSTOPS)
|
|
552
|
+ UPDATE_ENDSTOP_BIT(X, MIN);
|
|
553
|
+ #if HAS_X2_MIN
|
|
554
|
+ UPDATE_ENDSTOP_BIT(X2, MIN);
|
464
|
555
|
#else
|
465
|
|
- if (X_MIN_TEST) UPDATE_ENDSTOP(X, MIN);
|
|
556
|
+ COPY_BIT(current_endstop_bits, X_MIN, X2_MIN);
|
466
|
557
|
#endif
|
|
558
|
+ test_dual_x_endstops(X_MIN, X2_MIN);
|
|
559
|
+ #else
|
|
560
|
+ if (X_MIN_TEST) UPDATE_ENDSTOP(X, MIN);
|
467
|
561
|
#endif
|
468
|
|
- }
|
469
|
|
- else { // +direction
|
470
|
|
- #if HAS_X_MAX
|
471
|
|
- #if ENABLED(X_DUAL_ENDSTOPS)
|
472
|
|
- UPDATE_ENDSTOP_BIT(X, MAX);
|
473
|
|
- #if HAS_X2_MAX
|
474
|
|
- UPDATE_ENDSTOP_BIT(X2, MAX);
|
475
|
|
- #else
|
476
|
|
- COPY_BIT(current_endstop_bits, X_MAX, X2_MAX);
|
477
|
|
- #endif
|
478
|
|
- test_dual_x_endstops(X_MAX, X2_MAX);
|
|
562
|
+ #endif
|
|
563
|
+ }
|
|
564
|
+ else { // +direction
|
|
565
|
+ #if HAS_X_MAX
|
|
566
|
+ #if ENABLED(X_DUAL_ENDSTOPS)
|
|
567
|
+ UPDATE_ENDSTOP_BIT(X, MAX);
|
|
568
|
+ #if HAS_X2_MAX
|
|
569
|
+ UPDATE_ENDSTOP_BIT(X2, MAX);
|
479
|
570
|
#else
|
480
|
|
- if (X_MAX_TEST) UPDATE_ENDSTOP(X, MAX);
|
|
571
|
+ COPY_BIT(current_endstop_bits, X_MAX, X2_MAX);
|
481
|
572
|
#endif
|
|
573
|
+ test_dual_x_endstops(X_MAX, X2_MAX);
|
|
574
|
+ #else
|
|
575
|
+ if (X_MAX_TEST) UPDATE_ENDSTOP(X, MAX);
|
482
|
576
|
#endif
|
483
|
|
- }
|
|
577
|
+ #endif
|
484
|
578
|
}
|
|
579
|
+ }
|
485
|
580
|
|
486
|
|
- if (Y_MOVE_TEST) {
|
487
|
|
- if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
|
488
|
|
- #if HAS_Y_MIN
|
489
|
|
- #if ENABLED(Y_DUAL_ENDSTOPS)
|
490
|
|
- UPDATE_ENDSTOP_BIT(Y, MIN);
|
491
|
|
- #if HAS_Y2_MIN
|
492
|
|
- UPDATE_ENDSTOP_BIT(Y2, MIN);
|
493
|
|
- #else
|
494
|
|
- COPY_BIT(current_endstop_bits, Y_MIN, Y2_MIN);
|
495
|
|
- #endif
|
496
|
|
- test_dual_y_endstops(Y_MIN, Y2_MIN);
|
|
581
|
+ if (Y_MOVE_TEST) {
|
|
582
|
+ if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
|
|
583
|
+ #if HAS_Y_MIN
|
|
584
|
+ #if ENABLED(Y_DUAL_ENDSTOPS)
|
|
585
|
+ UPDATE_ENDSTOP_BIT(Y, MIN);
|
|
586
|
+ #if HAS_Y2_MIN
|
|
587
|
+ UPDATE_ENDSTOP_BIT(Y2, MIN);
|
497
|
588
|
#else
|
498
|
|
- UPDATE_ENDSTOP(Y, MIN);
|
|
589
|
+ COPY_BIT(current_endstop_bits, Y_MIN, Y2_MIN);
|
499
|
590
|
#endif
|
|
591
|
+ test_dual_y_endstops(Y_MIN, Y2_MIN);
|
|
592
|
+ #else
|
|
593
|
+ UPDATE_ENDSTOP(Y, MIN);
|
500
|
594
|
#endif
|
501
|
|
- }
|
502
|
|
- else { // +direction
|
503
|
|
- #if HAS_Y_MAX
|
504
|
|
- #if ENABLED(Y_DUAL_ENDSTOPS)
|
505
|
|
- UPDATE_ENDSTOP_BIT(Y, MAX);
|
506
|
|
- #if HAS_Y2_MAX
|
507
|
|
- UPDATE_ENDSTOP_BIT(Y2, MAX);
|
508
|
|
- #else
|
509
|
|
- COPY_BIT(current_endstop_bits, Y_MAX, Y2_MAX);
|
510
|
|
- #endif
|
511
|
|
- test_dual_y_endstops(Y_MAX, Y2_MAX);
|
|
595
|
+ #endif
|
|
596
|
+ }
|
|
597
|
+ else { // +direction
|
|
598
|
+ #if HAS_Y_MAX
|
|
599
|
+ #if ENABLED(Y_DUAL_ENDSTOPS)
|
|
600
|
+ UPDATE_ENDSTOP_BIT(Y, MAX);
|
|
601
|
+ #if HAS_Y2_MAX
|
|
602
|
+ UPDATE_ENDSTOP_BIT(Y2, MAX);
|
512
|
603
|
#else
|
513
|
|
- UPDATE_ENDSTOP(Y, MAX);
|
|
604
|
+ COPY_BIT(current_endstop_bits, Y_MAX, Y2_MAX);
|
514
|
605
|
#endif
|
|
606
|
+ test_dual_y_endstops(Y_MAX, Y2_MAX);
|
|
607
|
+ #else
|
|
608
|
+ UPDATE_ENDSTOP(Y, MAX);
|
515
|
609
|
#endif
|
516
|
|
- }
|
|
610
|
+ #endif
|
517
|
611
|
}
|
|
612
|
+ }
|
518
|
613
|
|
519
|
|
- if (Z_MOVE_TEST) {
|
520
|
|
- if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
|
521
|
|
- #if HAS_Z_MIN
|
522
|
|
- #if ENABLED(Z_DUAL_ENDSTOPS)
|
523
|
|
- UPDATE_ENDSTOP_BIT(Z, MIN);
|
524
|
|
- #if HAS_Z2_MIN
|
525
|
|
- UPDATE_ENDSTOP_BIT(Z2, MIN);
|
526
|
|
- #else
|
527
|
|
- COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
|
528
|
|
- #endif
|
529
|
|
- test_dual_z_endstops(Z_MIN, Z2_MIN);
|
|
614
|
+ if (Z_MOVE_TEST) {
|
|
615
|
+ if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
|
|
616
|
+ #if HAS_Z_MIN
|
|
617
|
+ #if ENABLED(Z_DUAL_ENDSTOPS)
|
|
618
|
+ UPDATE_ENDSTOP_BIT(Z, MIN);
|
|
619
|
+ #if HAS_Z2_MIN
|
|
620
|
+ UPDATE_ENDSTOP_BIT(Z2, MIN);
|
|
621
|
+ #else
|
|
622
|
+ COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
|
|
623
|
+ #endif
|
|
624
|
+ test_dual_z_endstops(Z_MIN, Z2_MIN);
|
|
625
|
+ #else
|
|
626
|
+ #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
627
|
+ if (z_probe_enabled) UPDATE_ENDSTOP(Z, MIN);
|
530
|
628
|
#else
|
531
|
|
- #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
532
|
|
- if (z_probe_enabled) UPDATE_ENDSTOP(Z, MIN);
|
533
|
|
- #else
|
534
|
|
- UPDATE_ENDSTOP(Z, MIN);
|
535
|
|
- #endif
|
|
629
|
+ UPDATE_ENDSTOP(Z, MIN);
|
536
|
630
|
#endif
|
537
|
631
|
#endif
|
|
632
|
+ #endif
|
538
|
633
|
|
539
|
|
- // When closing the gap check the enabled probe
|
540
|
|
- #if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
541
|
|
- if (z_probe_enabled) {
|
542
|
|
- UPDATE_ENDSTOP(Z, MIN_PROBE);
|
543
|
|
- if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE);
|
544
|
|
- }
|
545
|
|
- #endif
|
546
|
|
- }
|
547
|
|
- else { // Z +direction. Gantry up, bed down.
|
548
|
|
- #if HAS_Z_MAX
|
549
|
|
- // Check both Z dual endstops
|
550
|
|
- #if ENABLED(Z_DUAL_ENDSTOPS)
|
551
|
|
- UPDATE_ENDSTOP_BIT(Z, MAX);
|
552
|
|
- #if HAS_Z2_MAX
|
553
|
|
- UPDATE_ENDSTOP_BIT(Z2, MAX);
|
554
|
|
- #else
|
555
|
|
- COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
|
556
|
|
- #endif
|
557
|
|
- test_dual_z_endstops(Z_MAX, Z2_MAX);
|
558
|
|
- // If this pin is not hijacked for the bed probe
|
559
|
|
- // then it belongs to the Z endstop
|
560
|
|
- #elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
|
561
|
|
- UPDATE_ENDSTOP(Z, MAX);
|
|
634
|
+ // When closing the gap check the enabled probe
|
|
635
|
+ #if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
636
|
+ if (z_probe_enabled) {
|
|
637
|
+ UPDATE_ENDSTOP(Z, MIN_PROBE);
|
|
638
|
+ if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE);
|
|
639
|
+ }
|
|
640
|
+ #endif
|
|
641
|
+ }
|
|
642
|
+ else { // Z +direction. Gantry up, bed down.
|
|
643
|
+ #if HAS_Z_MAX
|
|
644
|
+ // Check both Z dual endstops
|
|
645
|
+ #if ENABLED(Z_DUAL_ENDSTOPS)
|
|
646
|
+ UPDATE_ENDSTOP_BIT(Z, MAX);
|
|
647
|
+ #if HAS_Z2_MAX
|
|
648
|
+ UPDATE_ENDSTOP_BIT(Z2, MAX);
|
|
649
|
+ #else
|
|
650
|
+ COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
|
562
|
651
|
#endif
|
|
652
|
+ test_dual_z_endstops(Z_MAX, Z2_MAX);
|
|
653
|
+ // If this pin is not hijacked for the bed probe
|
|
654
|
+ // then it belongs to the Z endstop
|
|
655
|
+ #elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
|
|
656
|
+ UPDATE_ENDSTOP(Z, MAX);
|
563
|
657
|
#endif
|
564
|
|
- }
|
|
658
|
+ #endif
|
565
|
659
|
}
|
566
|
|
-
|
567
|
|
- } // stepper.current_block
|
568
|
|
-
|
569
|
|
- old_endstop_bits = current_endstop_bits;
|
570
|
|
-
|
|
660
|
+ }
|
571
|
661
|
} // Endstops::update()
|
572
|
662
|
|
573
|
663
|
#if ENABLED(PINS_DEBUGGING)
|