|
|
@ -62,6 +62,12 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(G29_RETRY_AND_RECOVER) |
|
|
|
#define G29_RETURN(b) return b; |
|
|
|
#else |
|
|
|
#define G29_RETURN(b) return; |
|
|
|
#endif |
|
|
|
|
|
|
|
/**
|
|
|
|
* G29: Detailed Z probe, probes the bed at 3 or more points. |
|
|
|
* Will fail if the printer has not been homed with G28. |
|
|
@ -136,7 +142,7 @@ |
|
|
|
* There's no extra effect if you have a fixed Z probe. |
|
|
|
* |
|
|
|
*/ |
|
|
|
void GcodeSuite::G29() { |
|
|
|
G29_TYPE GcodeSuite::G29() { |
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) || ENABLED(PROBE_MANUALLY) |
|
|
|
const bool seenQ = parser.seen('Q'); |
|
|
@ -154,7 +160,7 @@ void GcodeSuite::G29() { |
|
|
|
} |
|
|
|
marlin_debug_flags = old_debug_flags; |
|
|
|
#if DISABLED(PROBE_MANUALLY) |
|
|
|
if (seenQ) return; |
|
|
|
if (seenQ) G29_RETURN(false); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
@ -174,7 +180,7 @@ void GcodeSuite::G29() { |
|
|
|
; |
|
|
|
|
|
|
|
// Don't allow auto-leveling without homing first
|
|
|
|
if (axis_unhomed_error()) return; |
|
|
|
if (axis_unhomed_error()) G29_RETURN(false); |
|
|
|
|
|
|
|
if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE) |
|
|
@ -183,7 +189,7 @@ void GcodeSuite::G29() { |
|
|
|
SERIAL_ECHOLNPGM("<<< G29"); |
|
|
|
} |
|
|
|
#endif |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
// Define local vars 'static' for manual probing, 'auto' otherwise
|
|
|
@ -285,14 +291,14 @@ void GcodeSuite::G29() { |
|
|
|
if (!leveling_is_valid()) { |
|
|
|
SERIAL_ERROR_START(); |
|
|
|
SERIAL_ERRORLNPGM("No bilinear grid"); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position[Z_AXIS]; |
|
|
|
if (!WITHIN(rz, -10, 10)) { |
|
|
|
SERIAL_ERROR_START(); |
|
|
|
SERIAL_ERRORLNPGM("Bad Z value"); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)), |
|
|
@ -316,7 +322,7 @@ void GcodeSuite::G29() { |
|
|
|
set_bed_leveling_enabled(abl_should_enable); |
|
|
|
if (abl_should_enable) report_current_position(); |
|
|
|
} |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} // parser.seen('W')
|
|
|
|
|
|
|
|
#else |
|
|
@ -328,13 +334,13 @@ void GcodeSuite::G29() { |
|
|
|
// Jettison bed leveling data
|
|
|
|
if (!seen_w && parser.seen('J')) { |
|
|
|
reset_bed_level(); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
verbose_level = parser.intval('V'); |
|
|
|
if (!WITHIN(verbose_level, 0, 4)) { |
|
|
|
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4)."); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
dryrun = parser.boolval('D') |
|
|
@ -355,11 +361,11 @@ void GcodeSuite::G29() { |
|
|
|
|
|
|
|
if (!WITHIN(abl_grid_points_x, 2, GRID_MAX_POINTS_X)) { |
|
|
|
SERIAL_PROTOCOLLNPGM("?Probe points (X) is implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ")."); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
if (!WITHIN(abl_grid_points_y, 2, GRID_MAX_POINTS_Y)) { |
|
|
|
SERIAL_PROTOCOLLNPGM("?Probe points (Y) is implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ")."); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
abl_points = abl_grid_points_x * abl_grid_points_y; |
|
|
@ -392,7 +398,7 @@ void GcodeSuite::G29() { |
|
|
|
#endif |
|
|
|
) { |
|
|
|
SERIAL_PROTOCOLLNPGM("? (L,R,F,B) out of bounds."); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
|
|
|
|
// probe at the points of a lattice grid
|
|
|
@ -417,7 +423,7 @@ void GcodeSuite::G29() { |
|
|
|
// Deploy the probe. Probe will raise if needed.
|
|
|
|
if (DEPLOY_PROBE()) { |
|
|
|
set_bed_leveling_enabled(abl_should_enable); |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
@ -494,7 +500,7 @@ void GcodeSuite::G29() { |
|
|
|
SERIAL_PROTOCOLLNPGM("idle"); |
|
|
|
} |
|
|
|
|
|
|
|
if (no_action) return; |
|
|
|
if (no_action) G29_RETURN(false); |
|
|
|
|
|
|
|
if (abl_probe_index == 0) { |
|
|
|
// For the initial G29 S2 save software endstop state
|
|
|
@ -584,7 +590,7 @@ void GcodeSuite::G29() { |
|
|
|
// If G29 is not completed, they will not be re-enabled
|
|
|
|
soft_endstops_enabled = false; |
|
|
|
#endif |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
@ -610,7 +616,7 @@ void GcodeSuite::G29() { |
|
|
|
// If G29 is not completed, they will not be re-enabled
|
|
|
|
soft_endstops_enabled = false; |
|
|
|
#endif |
|
|
|
return; |
|
|
|
G29_RETURN(false); |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
@ -990,6 +996,8 @@ void GcodeSuite::G29() { |
|
|
|
#endif |
|
|
|
|
|
|
|
report_current_position(); |
|
|
|
|
|
|
|
G29_RETURN(isnan(measured_z)); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // OLDSCHOOL_ABL
|
|
|
|