Clean up PROBE_TRIGGERED_WHEN_STOWED_TEST (#12232)

2.0.x
Scott Lahteine 6 years ago committed by GitHub
parent 3028a620af
commit ab8425f1b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -545,7 +545,7 @@
#undef Z_MIN_PROBE_ENDSTOP #undef Z_MIN_PROBE_ENDSTOP
#elif ENABLED(Z_PROBE_ALLEN_KEY) #elif ENABLED(Z_PROBE_ALLEN_KEY)
// Extra test for Allen Key Probe // Extra test for Allen Key Probe
#define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST #define PROBE_TRIGGERED_WHEN_STOWED_TEST
#endif #endif
#define HOMING_Z_WITH_PROBE (HAS_BED_PROBE && Z_HOME_DIR < 0 && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) #define HOMING_Z_WITH_PROBE (HAS_BED_PROBE && Z_HOME_DIR < 0 && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN))

@ -363,17 +363,52 @@ inline void do_probe_raise(const float z_raise) {
do_blocking_move_to_z(z_dest); do_blocking_move_to_z(z_dest);
} }
// returns false for ok and true for failure FORCE_INLINE void probe_specific_action(const bool deploy) {
bool set_probe_deployed(const bool deploy) { #if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
// Can be extended to servo probes, if needed. BUZZ(100, 659);
#if ENABLED(PROBE_IS_TRIGGERED_WHEN_STOWED_TEST) BUZZ(100, 698);
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
#define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW);
#else lcd_setstatusPGM(ds_str);
#define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) serialprintPGM(ds_str);
SERIAL_EOL();
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
while (wait_for_user) idle();
lcd_reset_status();
KEEPALIVE_STATE(IN_HANDLER);
#endif // PAUSE_BEFORE_DEPLOY_STOW
#if ENABLED(SOLENOID_PROBE)
#if HAS_SOLENOID_1
WRITE(SOL1_PIN, deploy);
#endif #endif
#elif ENABLED(Z_PROBE_SLED)
dock_sled(!deploy);
#elif HAS_Z_SERVO_PROBE && DISABLED(BLTOUCH)
MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]);
#elif ENABLED(Z_PROBE_ALLEN_KEY)
deploy ? run_deploy_moves_script() : run_stow_moves_script();
#elif ENABLED(RACK_AND_PINION_PROBE)
do_blocking_move_to_x(deploy ? Z_PROBE_DEPLOY_X : Z_PROBE_RETRACT_X);
#endif #endif
}
// returns false for ok and true for failure
bool set_probe_deployed(const bool deploy) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -420,65 +455,24 @@ bool set_probe_deployed(const bool deploy) {
const float oldXpos = current_position[X_AXIS], const float oldXpos = current_position[X_AXIS],
oldYpos = current_position[Y_AXIS]; oldYpos = current_position[Y_AXIS];
#ifdef _TRIGGERED_WHEN_STOWED_TEST #if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST)
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
#define PROBE_STOWED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING)
#else
#define PROBE_STOWED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING)
#endif
#endif
// If endstop is already false, the Z probe is deployed #ifdef PROBE_STOWED
if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { // closed after the probe specific actions.
// Would a goto be less ugly?
//while (!_TRIGGERED_WHEN_STOWED_TEST) idle(); // would offer the opportunity
// for a triggered when stowed manual probe.
// Only deploy/stow if needed
if (PROBE_STOWED() == deploy) {
if (!deploy) endstops.enable_z_probe(false); // Switch off triggered when stowed probes early if (!deploy) endstops.enable_z_probe(false); // Switch off triggered when stowed probes early
// otherwise an Allen-Key probe can't be stowed. // otherwise an Allen-Key probe can't be stowed.
#endif probe_specific_action(deploy);
}
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
BUZZ(100, 659);
BUZZ(100, 698);
PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW);
lcd_setstatusPGM(ds_str);
serialprintPGM(ds_str);
SERIAL_EOL();
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
while (wait_for_user) idle();
lcd_reset_status();
KEEPALIVE_STATE(IN_HANDLER);
#endif // PAUSE_BEFORE_DEPLOY_STOW
#if ENABLED(SOLENOID_PROBE)
#if HAS_SOLENOID_1
WRITE(SOL1_PIN, deploy);
#endif
#elif ENABLED(Z_PROBE_SLED)
dock_sled(!deploy);
#elif HAS_Z_SERVO_PROBE && DISABLED(BLTOUCH)
MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]);
#elif ENABLED(Z_PROBE_ALLEN_KEY)
deploy ? run_deploy_moves_script() : run_stow_moves_script();
#elif ENABLED(RACK_AND_PINION_PROBE)
do_blocking_move_to_x(deploy ? Z_PROBE_DEPLOY_X : Z_PROBE_RETRACT_X);
#endif
#ifdef _TRIGGERED_WHEN_STOWED_TEST
} // _TRIGGERED_WHEN_STOWED_TEST == deploy
if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { // State hasn't changed?
if (PROBE_STOWED() == deploy) { // Unchanged after deploy/stow action?
if (IsRunning()) { if (IsRunning()) {
SERIAL_ERROR_START(); SERIAL_ERROR_START();
SERIAL_ERRORLNPGM("Z-Probe failed"); SERIAL_ERRORLNPGM("Z-Probe failed");
@ -486,8 +480,11 @@ bool set_probe_deployed(const bool deploy) {
} }
stop(); stop();
return true; return true;
}
#else
} // _TRIGGERED_WHEN_STOWED_TEST == deploy probe_specific_action(deploy);
#endif #endif

Loading…
Cancel
Save