Generalize and simplify 'triggered when stowed test`
The `PROBE_IS_TRIGGERED_WHEN_STOWED_TEST` is able to detect if a probe is successfully deployed/stowed. It was part of the Allen Key probes code only. Now the function is generally available. Currently this test is compulsory for Allen Key probes to not alter the used behaviour If you want to add the test for an other type of probe simply add ``` #define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST ``` to your config.
This commit is contained in:
parent
5126cce7fd
commit
8555816a11
@ -753,6 +753,10 @@
|
|||||||
|
|
||||||
#define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED)
|
#define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED)
|
||||||
|
|
||||||
|
#if ENABLED(Z_PROBE_ALLEN_KEY)
|
||||||
|
#define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bed Probe dependencies
|
* Bed Probe dependencies
|
||||||
*/
|
*/
|
||||||
|
@ -1955,6 +1955,15 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
|
|
||||||
|
// TRIGGERED_WHEN_STOWED_TEST can easily be extended to servo probes, ... if needed.
|
||||||
|
#if ENABLED(PROBE_IS_TRIGGERED_WHEN_STOWED_TEST)
|
||||||
|
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
||||||
|
#define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING)
|
||||||
|
#else
|
||||||
|
#define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static void deploy_z_probe() {
|
static void deploy_z_probe() {
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
@ -1966,6 +1975,14 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
// Make room for probe
|
// Make room for probe
|
||||||
do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
||||||
|
|
||||||
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
||||||
|
// If endstop is already false, the Z probe is deployed
|
||||||
|
if (_TRIGGERED_WHEN_STOWED_TEST) { // 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.
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(Z_PROBE_SLED)
|
#if ENABLED(Z_PROBE_SLED)
|
||||||
|
|
||||||
dock_sled(false);
|
dock_sled(false);
|
||||||
@ -1976,37 +1993,8 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
DEPLOY_Z_SERVO();
|
DEPLOY_Z_SERVO();
|
||||||
|
|
||||||
#elif ENABLED(Z_PROBE_ALLEN_KEY)
|
#elif ENABLED(Z_PROBE_ALLEN_KEY)
|
||||||
float old_feedrate = feedrate;
|
|
||||||
|
|
||||||
feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE;
|
|
||||||
|
|
||||||
// If endstop is already false, the Z probe is deployed
|
|
||||||
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
||||||
bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING);
|
|
||||||
if (z_probe_endstop)
|
|
||||||
#else
|
|
||||||
bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
|
||||||
if (z_min_endstop)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
run_deploy_moves_script();
|
run_deploy_moves_script();
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
||||||
z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING);
|
|
||||||
if (z_probe_endstop)
|
|
||||||
#else
|
|
||||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
|
||||||
if (z_min_endstop)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (IsRunning()) {
|
|
||||||
SERIAL_ERROR_START;
|
|
||||||
SERIAL_ERRORLNPGM("Z-Probe failed to engage!");
|
|
||||||
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
|
||||||
}
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -2014,6 +2002,19 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
||||||
|
}; // opened before the probe specific actions
|
||||||
|
|
||||||
|
if (_TRIGGERED_WHEN_STOWED_TEST) {
|
||||||
|
if (IsRunning()) {
|
||||||
|
SERIAL_ERROR_START;
|
||||||
|
SERIAL_ERRORLNPGM("Z-Probe failed");
|
||||||
|
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
||||||
|
}
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
endstops.enable_z_probe();
|
endstops.enable_z_probe();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2027,6 +2028,13 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
// Make more room for the servo
|
// Make more room for the servo
|
||||||
do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
||||||
|
|
||||||
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
||||||
|
// If endstop is already false, the Z probe is deployed
|
||||||
|
if (!_TRIGGERED_WHEN_STOWED_TEST) { // 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.
|
||||||
|
|
||||||
#if ENABLED(Z_PROBE_SLED)
|
#if ENABLED(Z_PROBE_SLED)
|
||||||
|
|
||||||
dock_sled(true);
|
dock_sled(true);
|
||||||
@ -2040,28 +2048,25 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
|
|
||||||
run_stow_moves_script();
|
run_stow_moves_script();
|
||||||
|
|
||||||
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
||||||
bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING);
|
|
||||||
if (!z_probe_endstop)
|
|
||||||
#else
|
|
||||||
bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
|
||||||
if (!z_min_endstop)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (IsRunning()) {
|
|
||||||
SERIAL_ERROR_START;
|
|
||||||
SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
|
|
||||||
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
|
||||||
}
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Nothing to do here. Just clear endstops.z_probe_enabled
|
// Nothing to do here. Just clear endstops.z_probe_enabled
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
||||||
|
}; // opened before the probe specific actions
|
||||||
|
if (!_TRIGGERED_WHEN_STOWED_TEST) {
|
||||||
|
if (IsRunning()) {
|
||||||
|
SERIAL_ERROR_START;
|
||||||
|
SERIAL_ERRORLNPGM("Z-Probe failed!");
|
||||||
|
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
||||||
|
}
|
||||||
|
stop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
endstops.enable_z_probe(false);
|
endstops.enable_z_probe(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user