|
@@ -37,9 +37,9 @@
|
37
|
37
|
#endif
|
38
|
38
|
|
39
|
39
|
#if HAS_BED_PROBE
|
40
|
|
- #define ENDSTOPS_ENABLED (endstops.enabled || endstops.z_probe_enabled)
|
|
40
|
+ #define ENDSTOPS_ENABLED (enabled || z_probe_enabled)
|
41
|
41
|
#else
|
42
|
|
- #define ENDSTOPS_ENABLED endstops.enabled
|
|
42
|
+ #define ENDSTOPS_ENABLED enabled
|
43
|
43
|
#endif
|
44
|
44
|
|
45
|
45
|
Endstops endstops;
|
|
@@ -223,17 +223,17 @@ void Endstops::init() {
|
223
|
223
|
} // Endstops::init
|
224
|
224
|
|
225
|
225
|
// Called from ISR. A change was detected. Find out what happened!
|
226
|
|
-void Endstops::check_possible_change() { if (ENDSTOPS_ENABLED) endstops.update(); }
|
|
226
|
+void Endstops::check_possible_change() { if (ENDSTOPS_ENABLED) update(); }
|
227
|
227
|
|
228
|
228
|
// Called from ISR: Poll endstop state if required
|
229
|
229
|
void Endstops::poll() {
|
230
|
230
|
|
231
|
231
|
#if ENABLED(PINS_DEBUGGING)
|
232
|
|
- endstops.run_monitor(); // report changes in endstop status
|
|
232
|
+ run_monitor(); // report changes in endstop status
|
233
|
233
|
#endif
|
234
|
234
|
|
235
|
235
|
#if DISABLED(ENDSTOP_INTERRUPTS_FEATURE) || ENABLED(ENDSTOP_NOISE_FILTER)
|
236
|
|
- if (ENDSTOPS_ENABLED) endstops.update();
|
|
236
|
+ if (ENDSTOPS_ENABLED) update();
|
237
|
237
|
#endif
|
238
|
238
|
}
|
239
|
239
|
|
|
@@ -241,7 +241,7 @@ void Endstops::enable_globally(const bool onoff) {
|
241
|
241
|
enabled_globally = enabled = onoff;
|
242
|
242
|
|
243
|
243
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
244
|
|
- if (onoff) endstops.update(); // If enabling, update state now
|
|
244
|
+ if (onoff) update(); // If enabling, update state now
|
245
|
245
|
#endif
|
246
|
246
|
}
|
247
|
247
|
|
|
@@ -250,17 +250,16 @@ void Endstops::enable(const bool onoff) {
|
250
|
250
|
enabled = onoff;
|
251
|
251
|
|
252
|
252
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
253
|
|
- if (onoff) endstops.update(); // If enabling, update state now
|
|
253
|
+ if (onoff) update(); // If enabling, update state now
|
254
|
254
|
#endif
|
255
|
255
|
}
|
256
|
256
|
|
257
|
|
-
|
258
|
257
|
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
|
259
|
258
|
void Endstops::not_homing() {
|
260
|
259
|
enabled = enabled_globally;
|
261
|
260
|
|
262
|
261
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
263
|
|
- if (enabled) endstops.update(); // If enabling, update state now
|
|
262
|
+ if (enabled) update(); // If enabling, update state now
|
264
|
263
|
#endif
|
265
|
264
|
}
|
266
|
265
|
|
|
@@ -269,7 +268,7 @@ void Endstops::hit_on_purpose() {
|
269
|
268
|
hit_state = 0;
|
270
|
269
|
|
271
|
270
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
272
|
|
- if (enabled) endstops.update(); // If enabling, update state now
|
|
271
|
+ if (enabled) update(); // If enabling, update state now
|
273
|
272
|
#endif
|
274
|
273
|
}
|
275
|
274
|
|
|
@@ -279,7 +278,7 @@ void Endstops::hit_on_purpose() {
|
279
|
278
|
z_probe_enabled = onoff;
|
280
|
279
|
|
281
|
280
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
282
|
|
- if (enabled) endstops.update(); // If enabling, update state now
|
|
281
|
+ if (enabled) update(); // If enabling, update state now
|
283
|
282
|
#endif
|
284
|
283
|
}
|
285
|
284
|
#endif
|
|
@@ -417,89 +416,37 @@ void Endstops::update() {
|
417
|
416
|
if (G38_move) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
|
418
|
417
|
#endif
|
419
|
418
|
|
420
|
|
- /**
|
421
|
|
- * Define conditions for checking endstops
|
422
|
|
- */
|
423
|
|
-
|
424
|
|
- #if IS_CORE
|
425
|
|
- #define S_(N) stepper.movement_non_null(CORE_AXIS_##N)
|
426
|
|
- #define D_(N) stepper.motor_direction(CORE_AXIS_##N)
|
|
419
|
+ // With Dual X, endstops are only checked in the homing direction for the active extruder
|
|
420
|
+ #if ENABLED(DUAL_X_CARRIAGE)
|
|
421
|
+ #define E0_ACTIVE stepper.movement_extruder() == 0
|
|
422
|
+ #define X_MIN_TEST ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE))
|
|
423
|
+ #define X_MAX_TEST ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE))
|
|
424
|
+ #else
|
|
425
|
+ #define X_MIN_TEST true
|
|
426
|
+ #define X_MAX_TEST true
|
427
|
427
|
#endif
|
428
|
428
|
|
|
429
|
+ // Use HEAD for core axes, AXIS for others
|
429
|
430
|
#if CORE_IS_XY || CORE_IS_XZ
|
430
|
|
- /**
|
431
|
|
- * Head direction in -X axis for CoreXY and CoreXZ bots.
|
432
|
|
- *
|
433
|
|
- * If steps differ, both axes are moving.
|
434
|
|
- * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
|
435
|
|
- * If DeltaA == DeltaB, the movement is only in the 1st axis (X)
|
436
|
|
- */
|
437
|
|
- #if ENABLED(COREXY) || ENABLED(COREXZ)
|
438
|
|
- #define X_CMP ==
|
439
|
|
- #else
|
440
|
|
- #define X_CMP !=
|
441
|
|
- #endif
|
442
|
|
- #define X_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) X_CMP D_(2)) )
|
443
|
431
|
#define X_AXIS_HEAD X_HEAD
|
444
|
432
|
#else
|
445
|
|
- #define X_MOVE_TEST stepper.movement_non_null(X_AXIS)
|
446
|
433
|
#define X_AXIS_HEAD X_AXIS
|
447
|
434
|
#endif
|
448
|
|
-
|
449
|
435
|
#if CORE_IS_XY || CORE_IS_YZ
|
450
|
|
- /**
|
451
|
|
- * Head direction in -Y axis for CoreXY / CoreYZ bots.
|
452
|
|
- *
|
453
|
|
- * If steps differ, both axes are moving
|
454
|
|
- * If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y)
|
455
|
|
- * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
|
456
|
|
- */
|
457
|
|
- #if ENABLED(COREYX) || ENABLED(COREYZ)
|
458
|
|
- #define Y_CMP ==
|
459
|
|
- #else
|
460
|
|
- #define Y_CMP !=
|
461
|
|
- #endif
|
462
|
|
- #define Y_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Y_CMP D_(2)) )
|
463
|
436
|
#define Y_AXIS_HEAD Y_HEAD
|
464
|
437
|
#else
|
465
|
|
- #define Y_MOVE_TEST stepper.movement_non_null(Y_AXIS)
|
466
|
438
|
#define Y_AXIS_HEAD Y_AXIS
|
467
|
439
|
#endif
|
468
|
|
-
|
469
|
440
|
#if CORE_IS_XZ || CORE_IS_YZ
|
470
|
|
- /**
|
471
|
|
- * Head direction in -Z axis for CoreXZ or CoreYZ bots.
|
472
|
|
- *
|
473
|
|
- * If steps differ, both axes are moving
|
474
|
|
- * If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
|
475
|
|
- * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
|
476
|
|
- */
|
477
|
|
- #if ENABLED(COREZX) || ENABLED(COREZY)
|
478
|
|
- #define Z_CMP ==
|
479
|
|
- #else
|
480
|
|
- #define Z_CMP !=
|
481
|
|
- #endif
|
482
|
|
- #define Z_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Z_CMP D_(2)) )
|
483
|
441
|
#define Z_AXIS_HEAD Z_HEAD
|
484
|
442
|
#else
|
485
|
|
- #define Z_MOVE_TEST stepper.movement_non_null(Z_AXIS)
|
486
|
443
|
#define Z_AXIS_HEAD Z_AXIS
|
487
|
444
|
#endif
|
488
|
445
|
|
489
|
|
- // With Dual X, endstops are only checked in the homing direction for the active extruder
|
490
|
|
- #if ENABLED(DUAL_X_CARRIAGE)
|
491
|
|
- #define E0_ACTIVE stepper.movement_extruder() == 0
|
492
|
|
- #define X_MIN_TEST ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE))
|
493
|
|
- #define X_MAX_TEST ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE))
|
494
|
|
- #else
|
495
|
|
- #define X_MIN_TEST true
|
496
|
|
- #define X_MAX_TEST true
|
497
|
|
- #endif
|
498
|
|
-
|
499
|
446
|
/**
|
500
|
447
|
* Check and update endstops according to conditions
|
501
|
448
|
*/
|
502
|
|
- if (X_MOVE_TEST) {
|
|
449
|
+ if (stepper.axis_is_moving(X_AXIS)) {
|
503
|
450
|
if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
|
504
|
451
|
#if HAS_X_MIN
|
505
|
452
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
|
@@ -530,7 +477,7 @@ void Endstops::update() {
|
530
|
477
|
}
|
531
|
478
|
}
|
532
|
479
|
|
533
|
|
- if (Y_MOVE_TEST) {
|
|
480
|
+ if (stepper.axis_is_moving(Y_AXIS)) {
|
534
|
481
|
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
|
535
|
482
|
#if HAS_Y_MIN
|
536
|
483
|
#if ENABLED(Y_DUAL_ENDSTOPS)
|
|
@@ -561,7 +508,7 @@ void Endstops::update() {
|
561
|
508
|
}
|
562
|
509
|
}
|
563
|
510
|
|
564
|
|
- if (Z_MOVE_TEST) {
|
|
511
|
+ if (stepper.axis_is_moving(Z_AXIS)) {
|
565
|
512
|
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
|
566
|
513
|
#if HAS_Z_MIN
|
567
|
514
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
|
@@ -582,9 +529,7 @@ void Endstops::update() {
|
582
|
529
|
|
583
|
530
|
// When closing the gap check the enabled probe
|
584
|
531
|
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
585
|
|
- if (z_probe_enabled) {
|
586
|
|
- UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
|
587
|
|
- }
|
|
532
|
+ if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
|
588
|
533
|
#endif
|
589
|
534
|
}
|
590
|
535
|
else { // Z +direction. Gantry up, bed down.
|
|
@@ -660,16 +605,16 @@ void Endstops::update() {
|
660
|
605
|
// If G38 command is active check Z_MIN_PROBE for ALL movement
|
661
|
606
|
if (G38_move) {
|
662
|
607
|
if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
|
663
|
|
- if (stepper.movement_non_null(_AXIS(X))) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(_AXIS(X)); }
|
664
|
|
- else if (stepper.movement_non_null(_AXIS(Y))) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(_AXIS(Y)); }
|
665
|
|
- else if (stepper.movement_non_null(_AXIS(Z))) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(_AXIS(Z)); }
|
|
608
|
+ if (stepper.axis_is_moving(_AXIS(X))) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(_AXIS(X)); }
|
|
609
|
+ else if (stepper.axis_is_moving(_AXIS(Y))) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(_AXIS(Y)); }
|
|
610
|
+ else if (stepper.axis_is_moving(_AXIS(Z))) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(_AXIS(Z)); }
|
666
|
611
|
G38_endstop_hit = true;
|
667
|
612
|
}
|
668
|
613
|
}
|
669
|
614
|
#endif
|
670
|
615
|
|
671
|
616
|
// Now, we must signal, after validation, if an endstop limit is pressed or not
|
672
|
|
- if (X_MOVE_TEST) {
|
|
617
|
+ if (stepper.axis_is_moving(X_AXIS)) {
|
673
|
618
|
if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
|
674
|
619
|
#if HAS_X_MIN
|
675
|
620
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
|
@@ -690,7 +635,7 @@ void Endstops::update() {
|
690
|
635
|
}
|
691
|
636
|
}
|
692
|
637
|
|
693
|
|
- if (Y_MOVE_TEST) {
|
|
638
|
+ if (stepper.axis_is_moving(Y_AXIS)) {
|
694
|
639
|
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
|
695
|
640
|
#if HAS_Y_MIN
|
696
|
641
|
#if ENABLED(Y_DUAL_ENDSTOPS)
|
|
@@ -711,7 +656,7 @@ void Endstops::update() {
|
711
|
656
|
}
|
712
|
657
|
}
|
713
|
658
|
|
714
|
|
- if (Z_MOVE_TEST) {
|
|
659
|
+ if (stepper.axis_is_moving(Z_AXIS)) {
|
715
|
660
|
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
|
716
|
661
|
#if HAS_Z_MIN
|
717
|
662
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|