|
|
@ -278,12 +278,16 @@ void Endstops::update() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(COREXY) || ENABLED(COREXZ)
|
|
|
|
/**
|
|
|
|
#define CORE_X_CMP ==
|
|
|
|
* Define conditions for checking endstops
|
|
|
|
#elif ENABLED(COREYX) || ENABLED(COREZX)
|
|
|
|
*/
|
|
|
|
#define CORE_X_CMP !=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#if IS_CORE
|
|
|
|
|
|
|
|
#define S_(N) stepper.current_block->steps[CORE_AXIS_##N]
|
|
|
|
|
|
|
|
#define D_(N) stepper.motor_direction(CORE_AXIS_##N)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if CORE_IS_XY || CORE_IS_XZ
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Head direction in -X axis for CoreXY and CoreXZ bots.
|
|
|
|
* Head direction in -X axis for CoreXY and CoreXZ bots.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -291,52 +295,16 @@ void Endstops::update() {
|
|
|
|
* If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
|
|
|
|
* If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
|
|
|
|
* If DeltaA == DeltaB, the movement is only in the 1st axis (X)
|
|
|
|
* If DeltaA == DeltaB, the movement is only in the 1st axis (X)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#if CORE_IS_XY || CORE_IS_XZ
|
|
|
|
#if ENABLED(COREXY) || ENABLED(COREXZ)
|
|
|
|
if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
|
|
|
|
#define X_CMP ==
|
|
|
|
|| ( stepper.current_block->steps[CORE_AXIS_1] > 0
|
|
|
|
|
|
|
|
&& stepper.motor_direction(CORE_AXIS_1) CORE_X_CMP stepper.motor_direction(CORE_AXIS_2)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (stepper.motor_direction(X_HEAD))
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
if (stepper.current_block->steps[X_AXIS] > 0)
|
|
|
|
#define X_CMP !=
|
|
|
|
if (stepper.motor_direction(X_AXIS)) // stepping along -X axis (regular Cartesian bot)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
{ // -direction
|
|
|
|
#define X_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) X_CMP D_(2)) )
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
#define X_AXIS_HEAD X_HEAD
|
|
|
|
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
|
|
|
|
#else
|
|
|
|
if ( (stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0)
|
|
|
|
#define X_MOVE_TEST stepper.current_block->steps[X_AXIS] > 0
|
|
|
|
|| (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0)
|
|
|
|
#define X_AXIS_HEAD X_AXIS
|
|
|
|
)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAS_X_MIN
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(X, MIN);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else { // +direction
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
|
|
|
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
|
|
|
|
|
|
|
|
if ( (stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0)
|
|
|
|
|
|
|
|
|| (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAS_X_MAX
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(X, MAX);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CORE_IS_XY || CORE_IS_XZ
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle swapped vs. typical Core axis order
|
|
|
|
|
|
|
|
#if ENABLED(COREYX) || ENABLED(COREYZ)
|
|
|
|
|
|
|
|
#define CORE_YZ_CMP ==
|
|
|
|
|
|
|
|
#elif ENABLED(COREXY) || ENABLED(COREZY)
|
|
|
|
|
|
|
|
#define CORE_YZ_CMP !=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if CORE_IS_XY || CORE_IS_YZ
|
|
|
|
#if CORE_IS_XY || CORE_IS_YZ
|
|
|
@ -347,35 +315,16 @@ void Endstops::update() {
|
|
|
|
* If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y)
|
|
|
|
* If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y)
|
|
|
|
* If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
|
|
|
|
* If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
|
|
|
|
#if ENABLED(COREYX) || ENABLED(COREYZ)
|
|
|
|
|| ( stepper.current_block->steps[CORE_AXIS_1] > 0
|
|
|
|
#define Y_CMP ==
|
|
|
|
&& stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)
|
|
|
|
#else
|
|
|
|
)
|
|
|
|
#define Y_CMP !=
|
|
|
|
) {
|
|
|
|
#endif
|
|
|
|
if (stepper.motor_direction(Y_HEAD))
|
|
|
|
#define Y_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Y_CMP D_(2)) )
|
|
|
|
|
|
|
|
#define Y_AXIS_HEAD Y_HEAD
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
if (stepper.current_block->steps[Y_AXIS] > 0)
|
|
|
|
#define Y_MOVE_TEST stepper.current_block->steps[Y_AXIS] > 0
|
|
|
|
if (stepper.motor_direction(Y_AXIS)) // -direction
|
|
|
|
#define Y_AXIS_HEAD Y_AXIS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{ // -direction
|
|
|
|
|
|
|
|
#if HAS_Y_MIN
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Y, MIN);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else { // +direction
|
|
|
|
|
|
|
|
#if HAS_Y_MAX
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Y, MAX);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CORE_IS_XY || CORE_IS_YZ
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(COREZX) || ENABLED(COREZY)
|
|
|
|
|
|
|
|
#define CORE_YZ_CMP ==
|
|
|
|
|
|
|
|
#elif ENABLED(COREXZ) || ENABLED(COREYZ)
|
|
|
|
|
|
|
|
#define CORE_YZ_CMP !=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if CORE_IS_XZ || CORE_IS_YZ
|
|
|
|
#if CORE_IS_XZ || CORE_IS_YZ
|
|
|
@ -386,76 +335,119 @@ void Endstops::update() {
|
|
|
|
* If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
|
|
|
|
* If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
|
|
|
|
* If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
|
|
|
|
* If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
|
|
|
|
#if ENABLED(COREZX) || ENABLED(COREZY)
|
|
|
|
|| ( stepper.current_block->steps[CORE_AXIS_1] > 0
|
|
|
|
#define Z_CMP ==
|
|
|
|
&& stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)
|
|
|
|
#else
|
|
|
|
)
|
|
|
|
#define Z_CMP !=
|
|
|
|
) {
|
|
|
|
#endif
|
|
|
|
if (stepper.motor_direction(Z_HEAD))
|
|
|
|
#define Z_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Z_CMP D_(2)) )
|
|
|
|
|
|
|
|
#define Z_AXIS_HEAD Z_HEAD
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
if (stepper.current_block->steps[Z_AXIS] > 0)
|
|
|
|
#define Z_MOVE_TEST stepper.current_block->steps[Z_AXIS] > 0
|
|
|
|
if (stepper.motor_direction(Z_AXIS))
|
|
|
|
#define Z_AXIS_HEAD Z_AXIS
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
{ // Z -direction. Gantry down, bed up.
|
|
|
|
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
|
|
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP_BIT(Z, MIN);
|
|
|
|
// With Dual X, endstops are only checked in the homing direction for the active extruder
|
|
|
|
#if HAS_Z2_MIN
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
UPDATE_ENDSTOP_BIT(Z2, MIN);
|
|
|
|
#define E0_ACTIVE stepper.current_block->active_extruder == 0
|
|
|
|
#else
|
|
|
|
#define X_MIN_TEST ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE))
|
|
|
|
COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
|
|
|
|
#define X_MAX_TEST ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE))
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define X_MIN_TEST true
|
|
|
|
|
|
|
|
#define X_MAX_TEST true
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
test_dual_z_endstops(Z_MIN, Z2_MIN);
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check and update endstops according to conditions
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#else // !Z_DUAL_ENDSTOPS
|
|
|
|
if (X_MOVE_TEST) {
|
|
|
|
|
|
|
|
if (stepper.motor_direction(X_AXIS_HEAD)) {
|
|
|
|
|
|
|
|
if (X_MIN_TEST) { // -direction
|
|
|
|
|
|
|
|
#if HAS_X_MIN
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(X, MIN);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (X_MAX_TEST) { // +direction
|
|
|
|
|
|
|
|
#if HAS_X_MAX
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(X, MAX);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
|
|
if (Y_MOVE_TEST) {
|
|
|
|
if (z_probe_enabled) UPDATE_ENDSTOP(Z, MIN);
|
|
|
|
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
|
|
|
|
#else
|
|
|
|
#if HAS_Y_MIN
|
|
|
|
UPDATE_ENDSTOP(Z, MIN);
|
|
|
|
UPDATE_ENDSTOP(Y, MIN);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else { // +direction
|
|
|
|
|
|
|
|
#if HAS_Y_MAX
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Y, MAX);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !Z_DUAL_ENDSTOPS
|
|
|
|
if (Z_MOVE_TEST) {
|
|
|
|
|
|
|
|
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
|
|
|
|
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
|
|
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HAS_Z_MIN
|
|
|
|
UPDATE_ENDSTOP_BIT(Z, MIN);
|
|
|
|
|
|
|
|
#if HAS_Z2_MIN
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP_BIT(Z2, MIN);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// When closing the gap check the enabled probe
|
|
|
|
test_dual_z_endstops(Z_MIN, Z2_MIN);
|
|
|
|
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
|
|
|
|
|
|
if (z_probe_enabled) {
|
|
|
|
#else // !Z_DUAL_ENDSTOPS
|
|
|
|
UPDATE_ENDSTOP(Z, MIN_PROBE);
|
|
|
|
|
|
|
|
if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else { // Z +direction. Gantry up, bed down.
|
|
|
|
|
|
|
|
#if HAS_Z_MAX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check both Z dual endstops
|
|
|
|
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
|
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
|
|
|
if (z_probe_enabled) UPDATE_ENDSTOP(Z, MIN);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Z, MIN);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP_BIT(Z, MAX);
|
|
|
|
#endif // !Z_DUAL_ENDSTOPS
|
|
|
|
#if HAS_Z2_MAX
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP_BIT(Z2, MAX);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_dual_z_endstops(Z_MAX, Z2_MAX);
|
|
|
|
#endif // HAS_Z_MIN
|
|
|
|
|
|
|
|
|
|
|
|
// If this pin is not hijacked for the bed probe
|
|
|
|
// When closing the gap check the enabled probe
|
|
|
|
// then it belongs to the Z endstop
|
|
|
|
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
|
|
#elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
|
|
|
|
if (z_probe_enabled) {
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Z, MIN_PROBE);
|
|
|
|
|
|
|
|
if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else { // Z +direction. Gantry up, bed down.
|
|
|
|
|
|
|
|
#if HAS_Z_MAX
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Z, MAX);
|
|
|
|
// Check both Z dual endstops
|
|
|
|
|
|
|
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !Z_MIN_PROBE_PIN...
|
|
|
|
UPDATE_ENDSTOP_BIT(Z, MAX);
|
|
|
|
#endif // Z_MAX_PIN
|
|
|
|
#if HAS_Z2_MAX
|
|
|
|
}
|
|
|
|
UPDATE_ENDSTOP_BIT(Z2, MAX);
|
|
|
|
#if CORE_IS_XZ || CORE_IS_YZ
|
|
|
|
#else
|
|
|
|
|
|
|
|
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_dual_z_endstops(Z_MAX, Z2_MAX);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If this pin is not hijacked for the bed probe
|
|
|
|
|
|
|
|
// then it belongs to the Z endstop
|
|
|
|
|
|
|
|
#elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE_ENDSTOP(Z, MAX);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !Z_MIN_PROBE_PIN...
|
|
|
|
|
|
|
|
#endif // Z_MAX_PIN
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
old_endstop_bits = current_endstop_bits;
|
|
|
|
old_endstop_bits = current_endstop_bits;
|
|
|
|
|
|
|
|
|
|
|
|