|
@@ -1735,7 +1735,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
1735
|
1735
|
|
1736
|
1736
|
#endif //HAS_BED_PROBE
|
1737
|
1737
|
|
1738
|
|
-#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE
|
|
1738
|
+#if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE
|
1739
|
1739
|
static bool axis_unhomed_error(const bool x, const bool y, const bool z) {
|
1740
|
1740
|
const bool xx = x && !axis_homed[X_AXIS],
|
1741
|
1741
|
yy = y && !axis_homed[Y_AXIS],
|
|
@@ -1783,16 +1783,10 @@ static void clean_up_after_endstop_or_probe_move() {
|
1783
|
1783
|
}
|
1784
|
1784
|
#endif
|
1785
|
1785
|
|
1786
|
|
- if (axis_unhomed_error(true, false, false)) return;
|
1787
|
|
-
|
1788
|
|
- float oldXpos = current_position[X_AXIS]; // save x position
|
1789
|
|
-
|
1790
|
1786
|
// Dock sled a bit closer to ensure proper capturing
|
1791
|
1787
|
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
|
1792
|
1788
|
digitalWrite(SLED_PIN, !stow); // switch solenoid
|
1793
|
1789
|
|
1794
|
|
- do_blocking_move_to_x(oldXpos); // return to position before docking
|
1795
|
|
-
|
1796
|
1790
|
}
|
1797
|
1791
|
|
1798
|
1792
|
#endif // Z_PROBE_SLED
|
|
@@ -1964,102 +1958,59 @@ static void clean_up_after_endstop_or_probe_move() {
|
1964
|
1958
|
#endif
|
1965
|
1959
|
#endif
|
1966
|
1960
|
|
1967
|
|
- static void deploy_z_probe() {
|
|
1961
|
+ #define DEPLOY_PROBE() set_probe_deployed( true )
|
|
1962
|
+ #define STOW_PROBE() set_probe_deployed( false )
|
|
1963
|
+
|
|
1964
|
+ // returns false for ok and true for failure
|
|
1965
|
+ static bool set_probe_deployed(bool deploy) {
|
1968
|
1966
|
|
1969
|
1967
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1970
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("deploy_z_probe", current_position);
|
|
1968
|
+ if (DEBUGGING(LEVELING)) {
|
|
1969
|
+ DEBUG_POS("set_probe_deployed", current_position);
|
|
1970
|
+ SERIAL_ECHOPAIR("deploy: ", deploy);
|
|
1971
|
+ }
|
1971
|
1972
|
#endif
|
1972
|
1973
|
|
1973
|
|
- if (endstops.z_probe_enabled) return;
|
|
1974
|
+ if (endstops.z_probe_enabled == deploy) return false;
|
1974
|
1975
|
|
1975
|
1976
|
// Make room for probe
|
1976
|
1977
|
do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
1977
|
1978
|
|
1978
|
|
- #ifdef _TRIGGERED_WHEN_STOWED_TEST
|
1979
|
|
- // If endstop is already false, the Z probe is deployed
|
1980
|
|
- if (_TRIGGERED_WHEN_STOWED_TEST) { // closed after the probe specific actions.
|
1981
|
|
- // Would a goto be less ugly?
|
1982
|
|
- //while (!_TRIGGERED_WHEN_STOWED_TEST) { idle(); // would offer the opportunity
|
1983
|
|
- // for a triggered when stowed manual probe.
|
1984
|
|
- #endif
|
1985
|
|
-
|
1986
|
1979
|
#if ENABLED(Z_PROBE_SLED)
|
1987
|
|
-
|
1988
|
|
- dock_sled(false);
|
1989
|
|
-
|
1990
|
|
- #elif HAS_Z_SERVO_ENDSTOP
|
1991
|
|
-
|
1992
|
|
- // Engage Z Servo endstop if enabled
|
1993
|
|
- DEPLOY_Z_SERVO();
|
1994
|
|
-
|
|
1980
|
+ if (axis_unhomed_error(true, false, false)) { stop(); return true; }
|
1995
|
1981
|
#elif ENABLED(Z_PROBE_ALLEN_KEY)
|
1996
|
|
-
|
1997
|
|
- run_deploy_moves_script();
|
1998
|
|
-
|
1999
|
|
- #else
|
2000
|
|
-
|
2001
|
|
- // Nothing to be done. Just enable_z_probe below...
|
2002
|
|
-
|
|
1982
|
+ if (axis_unhomed_error(true, true, true )) { stop(); return true; }
|
2003
|
1983
|
#endif
|
2004
|
1984
|
|
2005
|
|
- #ifdef _TRIGGERED_WHEN_STOWED_TEST
|
2006
|
|
- }; // opened before the probe specific actions
|
2007
|
|
-
|
2008
|
|
- if (_TRIGGERED_WHEN_STOWED_TEST) {
|
2009
|
|
- if (IsRunning()) {
|
2010
|
|
- SERIAL_ERROR_START;
|
2011
|
|
- SERIAL_ERRORLNPGM("Z-Probe failed");
|
2012
|
|
- LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
2013
|
|
- }
|
2014
|
|
- stop();
|
2015
|
|
- }
|
2016
|
|
- #endif
|
2017
|
|
-
|
2018
|
|
- endstops.enable_z_probe();
|
2019
|
|
- }
|
2020
|
|
-
|
2021
|
|
- static void stow_z_probe() {
|
2022
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2023
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("stow_z_probe", current_position);
|
2024
|
|
- #endif
|
2025
|
|
-
|
2026
|
|
- if (!endstops.z_probe_enabled) return;
|
2027
|
|
-
|
2028
|
|
- // Make more room for the servo
|
2029
|
|
- do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
|
1985
|
+ float oldXpos = current_position[X_AXIS]; // save x position
|
|
1986
|
+ float oldYpos = current_position[Y_AXIS]; // save y position
|
2030
|
1987
|
|
2031
|
1988
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
2032
|
1989
|
// If endstop is already false, the Z probe is deployed
|
2033
|
|
- if (!_TRIGGERED_WHEN_STOWED_TEST) { // closed after the probe specific actions.
|
2034
|
|
- // Would a goto be less ugly?
|
|
1990
|
+ if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { // closed after the probe specific actions.
|
|
1991
|
+ // Would a goto be less ugly?
|
2035
|
1992
|
//while (!_TRIGGERED_WHEN_STOWED_TEST) { idle(); // would offer the opportunity
|
2036
|
1993
|
// for a triggered when stowed manual probe.
|
|
1994
|
+ #endif
|
2037
|
1995
|
|
2038
|
|
- #if ENABLED(Z_PROBE_SLED)
|
2039
|
|
-
|
2040
|
|
- dock_sled(true);
|
2041
|
|
-
|
|
1996
|
+ #if ENABLED(Z_PROBE_SLED)
|
|
1997
|
+ dock_sled(!deploy);
|
2042
|
1998
|
#elif HAS_Z_SERVO_ENDSTOP
|
2043
|
|
-
|
2044
|
|
- // Change the Z servo angle
|
2045
|
|
- STOW_Z_SERVO();
|
2046
|
|
-
|
|
1999
|
+ servo[Z_ENDSTOP_SERVO_NR].move(z_servo_angle[((deploy) ? 0 : 1)]);
|
2047
|
2000
|
#elif ENABLED(Z_PROBE_ALLEN_KEY)
|
2048
|
|
-
|
2049
|
|
- run_stow_moves_script();
|
2050
|
|
-
|
2051
|
|
- #else
|
2052
|
|
-
|
2053
|
|
- // Nothing to do here. Just clear endstops.z_probe_enabled
|
2054
|
|
-
|
|
2001
|
+ if (!deploy) run_stow_moves_script();
|
|
2002
|
+ else run_deploy_moves_script();
|
|
2003
|
+ #else
|
|
2004
|
+ // Nothing to be done. Just enable_z_probe below...
|
2055
|
2005
|
#endif
|
2056
|
2006
|
|
2057
|
2007
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
2058
|
2008
|
}; // opened before the probe specific actions
|
2059
|
|
- if (!_TRIGGERED_WHEN_STOWED_TEST) {
|
|
2009
|
+
|
|
2010
|
+ if (_TRIGGERED_WHEN_STOWED_TEST == deploy) {
|
2060
|
2011
|
if (IsRunning()) {
|
2061
|
2012
|
SERIAL_ERROR_START;
|
2062
|
|
- SERIAL_ERRORLNPGM("Z-Probe failed!");
|
|
2013
|
+ SERIAL_ERRORLNPGM("Z-Probe failed");
|
2063
|
2014
|
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
|
2064
|
2015
|
}
|
2065
|
2016
|
stop();
|
|
@@ -2067,7 +2018,9 @@ static void clean_up_after_endstop_or_probe_move() {
|
2067
|
2018
|
}
|
2068
|
2019
|
#endif
|
2069
|
2020
|
|
2070
|
|
- endstops.enable_z_probe(false);
|
|
2021
|
+ do_blocking_move_to(oldXpos, oldYpos, current_position[Z_AXIS]); // return to position before deploy
|
|
2022
|
+ endstops.enable_z_probe( deploy );
|
|
2023
|
+ return false;
|
2071
|
2024
|
}
|
2072
|
2025
|
|
2073
|
2026
|
// Do a single Z probe and return with current_position[Z_AXIS]
|
|
@@ -2200,7 +2153,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2200
|
2153
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2201
|
2154
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2202
|
2155
|
#endif
|
2203
|
|
- deploy_z_probe();
|
|
2156
|
+ if (DEPLOY_PROBE()) return NAN;
|
2204
|
2157
|
|
2205
|
2158
|
float measured_z = run_z_probe();
|
2206
|
2159
|
|
|
@@ -2208,7 +2161,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2208
|
2161
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2209
|
2162
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2210
|
2163
|
#endif
|
2211
|
|
- stow_z_probe();
|
|
2164
|
+ if (STOW_PROBE()) return NAN;
|
2212
|
2165
|
}
|
2213
|
2166
|
else {
|
2214
|
2167
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -2416,7 +2369,7 @@ static void homeaxis(AxisEnum axis) {
|
2416
|
2369
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2417
|
2370
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2418
|
2371
|
#endif
|
2419
|
|
- deploy_z_probe();
|
|
2372
|
+ if (DEPLOY_PROBE()) return;
|
2420
|
2373
|
}
|
2421
|
2374
|
#endif
|
2422
|
2375
|
|
|
@@ -2543,7 +2496,7 @@ static void homeaxis(AxisEnum axis) {
|
2543
|
2496
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2544
|
2497
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2545
|
2498
|
#endif
|
2546
|
|
- stow_z_probe();
|
|
2499
|
+ if (STOW_PROBE()) return;
|
2547
|
2500
|
}
|
2548
|
2501
|
#endif
|
2549
|
2502
|
|
|
@@ -3457,12 +3410,7 @@ inline void gcode_G28() {
|
3457
|
3410
|
}
|
3458
|
3411
|
|
3459
|
3412
|
bool dryrun = code_seen('D');
|
3460
|
|
-
|
3461
|
|
- #if ENABLED(Z_PROBE_ALLEN_KEY)
|
3462
|
|
- const bool stow_probe_after_each = false;
|
3463
|
|
- #else
|
3464
|
|
- bool stow_probe_after_each = code_seen('E');
|
3465
|
|
- #endif
|
|
3413
|
+ bool stow_probe_after_each = code_seen('E');
|
3466
|
3414
|
|
3467
|
3415
|
#if ENABLED(AUTO_BED_LEVELING_GRID)
|
3468
|
3416
|
|
|
@@ -3561,8 +3509,8 @@ inline void gcode_G28() {
|
3561
|
3509
|
|
3562
|
3510
|
setup_for_endstop_or_probe_move();
|
3563
|
3511
|
|
3564
|
|
- // Deploy the probe. Servo will raise if needed.
|
3565
|
|
- deploy_z_probe();
|
|
3512
|
+ // Deploy the probe. Probe will raise if needed.
|
|
3513
|
+ if (DEPLOY_PROBE()) return;
|
3566
|
3514
|
|
3567
|
3515
|
bed_leveling_in_progress = true;
|
3568
|
3516
|
|
|
@@ -3667,7 +3615,7 @@ inline void gcode_G28() {
|
3667
|
3615
|
#endif // !AUTO_BED_LEVELING_GRID
|
3668
|
3616
|
|
3669
|
3617
|
// Raise to _Z_RAISE_PROBE_DEPLOY_STOW. Stow the probe.
|
3670
|
|
- stow_z_probe();
|
|
3618
|
+ if (STOW_PROBE()) return;
|
3671
|
3619
|
|
3672
|
3620
|
// Restore state after probing
|
3673
|
3621
|
clean_up_after_endstop_or_probe_move();
|
|
@@ -3874,12 +3822,12 @@ inline void gcode_G28() {
|
3874
|
3822
|
/**
|
3875
|
3823
|
* G31: Deploy the Z probe
|
3876
|
3824
|
*/
|
3877
|
|
- inline void gcode_G31() { deploy_z_probe(); }
|
|
3825
|
+ inline void gcode_G31() { DEPLOY_PROBE(); }
|
3878
|
3826
|
|
3879
|
3827
|
/**
|
3880
|
3828
|
* G32: Stow the Z probe
|
3881
|
3829
|
*/
|
3882
|
|
- inline void gcode_G32() { stow_z_probe(); }
|
|
3830
|
+ inline void gcode_G32() { STOW_PROBE(); }
|
3883
|
3831
|
|
3884
|
3832
|
#endif // Z_PROBE_SLED
|
3885
|
3833
|
|
|
@@ -4220,11 +4168,7 @@ inline void gcode_M42() {
|
4220
|
4168
|
float X_current = current_position[X_AXIS],
|
4221
|
4169
|
Y_current = current_position[Y_AXIS];
|
4222
|
4170
|
|
4223
|
|
- #if ENABLED(Z_PROBE_ALLEN_KEY)
|
4224
|
|
- const bool stow_probe_after_each = false;
|
4225
|
|
- #else
|
4226
|
|
- bool stow_probe_after_each = code_seen('E');
|
4227
|
|
- #endif
|
|
4171
|
+ bool stow_probe_after_each = code_seen('E');
|
4228
|
4172
|
|
4229
|
4173
|
float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
|
4230
|
4174
|
#if DISABLED(DELTA)
|
|
@@ -4391,7 +4335,7 @@ inline void gcode_M42() {
|
4391
|
4335
|
|
4392
|
4336
|
} // End of probe loop
|
4393
|
4337
|
|
4394
|
|
- stow_z_probe();
|
|
4338
|
+ if (STOW_PROBE()) return;
|
4395
|
4339
|
|
4396
|
4340
|
if (verbose_level > 0) {
|
4397
|
4341
|
SERIAL_PROTOCOLPGM("Mean: ");
|
|
@@ -5967,12 +5911,12 @@ inline void gcode_M400() { stepper.synchronize(); }
|
5967
|
5911
|
/**
|
5968
|
5912
|
* M401: Engage Z Servo endstop if available
|
5969
|
5913
|
*/
|
5970
|
|
- inline void gcode_M401() { deploy_z_probe(); }
|
|
5914
|
+ inline void gcode_M401() { DEPLOY_PROBE(); }
|
5971
|
5915
|
|
5972
|
5916
|
/**
|
5973
|
5917
|
* M402: Retract Z Servo endstop if enabled
|
5974
|
5918
|
*/
|
5975
|
|
- inline void gcode_M402() { stow_z_probe(); }
|
|
5919
|
+ inline void gcode_M402() { STOW_PROBE(); }
|
5976
|
5920
|
|
5977
|
5921
|
#endif // HAS_BED_PROBE
|
5978
|
5922
|
|