parent
c36efd3106
commit
0fff79c24b
@ -62,6 +62,12 @@
|
|||||||
#endif
|
#endif
|
||||||
#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.
|
* G29: Detailed Z probe, probes the bed at 3 or more points.
|
||||||
* Will fail if the printer has not been homed with G28.
|
* 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.
|
* 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)
|
#if ENABLED(DEBUG_LEVELING_FEATURE) || ENABLED(PROBE_MANUALLY)
|
||||||
const bool seenQ = parser.seen('Q');
|
const bool seenQ = parser.seen('Q');
|
||||||
@ -154,7 +160,7 @@ void GcodeSuite::G29() {
|
|||||||
}
|
}
|
||||||
marlin_debug_flags = old_debug_flags;
|
marlin_debug_flags = old_debug_flags;
|
||||||
#if DISABLED(PROBE_MANUALLY)
|
#if DISABLED(PROBE_MANUALLY)
|
||||||
if (seenQ) return;
|
if (seenQ) G29_RETURN(false);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -174,7 +180,7 @@ void GcodeSuite::G29() {
|
|||||||
;
|
;
|
||||||
|
|
||||||
// Don't allow auto-leveling without homing first
|
// 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 (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
@ -183,7 +189,7 @@ void GcodeSuite::G29() {
|
|||||||
SERIAL_ECHOLNPGM("<<< G29");
|
SERIAL_ECHOLNPGM("<<< G29");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define local vars 'static' for manual probing, 'auto' otherwise
|
// Define local vars 'static' for manual probing, 'auto' otherwise
|
||||||
@ -285,14 +291,14 @@ void GcodeSuite::G29() {
|
|||||||
if (!leveling_is_valid()) {
|
if (!leveling_is_valid()) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ERRORLNPGM("No bilinear grid");
|
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];
|
const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position[Z_AXIS];
|
||||||
if (!WITHIN(rz, -10, 10)) {
|
if (!WITHIN(rz, -10, 10)) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ERRORLNPGM("Bad Z value");
|
SERIAL_ERRORLNPGM("Bad Z value");
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
|
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
|
||||||
@ -316,7 +322,7 @@ void GcodeSuite::G29() {
|
|||||||
set_bed_leveling_enabled(abl_should_enable);
|
set_bed_leveling_enabled(abl_should_enable);
|
||||||
if (abl_should_enable) report_current_position();
|
if (abl_should_enable) report_current_position();
|
||||||
}
|
}
|
||||||
return;
|
G29_RETURN(false);
|
||||||
} // parser.seen('W')
|
} // parser.seen('W')
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -328,13 +334,13 @@ void GcodeSuite::G29() {
|
|||||||
// Jettison bed leveling data
|
// Jettison bed leveling data
|
||||||
if (!seen_w && parser.seen('J')) {
|
if (!seen_w && parser.seen('J')) {
|
||||||
reset_bed_level();
|
reset_bed_level();
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose_level = parser.intval('V');
|
verbose_level = parser.intval('V');
|
||||||
if (!WITHIN(verbose_level, 0, 4)) {
|
if (!WITHIN(verbose_level, 0, 4)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
|
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
dryrun = parser.boolval('D')
|
dryrun = parser.boolval('D')
|
||||||
@ -355,11 +361,11 @@ void GcodeSuite::G29() {
|
|||||||
|
|
||||||
if (!WITHIN(abl_grid_points_x, 2, GRID_MAX_POINTS_X)) {
|
if (!WITHIN(abl_grid_points_x, 2, GRID_MAX_POINTS_X)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Probe points (X) is implausible (2-" STRINGIFY(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)) {
|
if (!WITHIN(abl_grid_points_y, 2, GRID_MAX_POINTS_Y)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Probe points (Y) is implausible (2-" STRINGIFY(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;
|
abl_points = abl_grid_points_x * abl_grid_points_y;
|
||||||
@ -392,7 +398,7 @@ void GcodeSuite::G29() {
|
|||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
SERIAL_PROTOCOLLNPGM("? (L,R,F,B) out of bounds.");
|
SERIAL_PROTOCOLLNPGM("? (L,R,F,B) out of bounds.");
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// probe at the points of a lattice grid
|
// probe at the points of a lattice grid
|
||||||
@ -417,7 +423,7 @@ void GcodeSuite::G29() {
|
|||||||
// Deploy the probe. Probe will raise if needed.
|
// Deploy the probe. Probe will raise if needed.
|
||||||
if (DEPLOY_PROBE()) {
|
if (DEPLOY_PROBE()) {
|
||||||
set_bed_leveling_enabled(abl_should_enable);
|
set_bed_leveling_enabled(abl_should_enable);
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -494,7 +500,7 @@ void GcodeSuite::G29() {
|
|||||||
SERIAL_PROTOCOLLNPGM("idle");
|
SERIAL_PROTOCOLLNPGM("idle");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_action) return;
|
if (no_action) G29_RETURN(false);
|
||||||
|
|
||||||
if (abl_probe_index == 0) {
|
if (abl_probe_index == 0) {
|
||||||
// For the initial G29 S2 save software endstop state
|
// 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
|
// If G29 is not completed, they will not be re-enabled
|
||||||
soft_endstops_enabled = false;
|
soft_endstops_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -610,7 +616,7 @@ void GcodeSuite::G29() {
|
|||||||
// If G29 is not completed, they will not be re-enabled
|
// If G29 is not completed, they will not be re-enabled
|
||||||
soft_endstops_enabled = false;
|
soft_endstops_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
return;
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -990,6 +996,8 @@ void GcodeSuite::G29() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
report_current_position();
|
report_current_position();
|
||||||
|
|
||||||
|
G29_RETURN(isnan(measured_z));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OLDSCHOOL_ABL
|
#endif // OLDSCHOOL_ABL
|
||||||
|
@ -61,11 +61,6 @@ bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES;
|
|||||||
float GcodeSuite::coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
|
float GcodeSuite::coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_LEVELING && ENABLED(G29_RETRY_AND_RECOVER)
|
|
||||||
#include "../feature/bedlevel/bedlevel.h"
|
|
||||||
#include "../module/planner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set target_extruder from the T parameter or the active_extruder
|
* Set target_extruder from the T parameter or the active_extruder
|
||||||
*
|
*
|
||||||
@ -136,34 +131,37 @@ void GcodeSuite::dwell(millis_t time) {
|
|||||||
*/
|
*/
|
||||||
#if HAS_LEVELING && ENABLED(G29_RETRY_AND_RECOVER)
|
#if HAS_LEVELING && ENABLED(G29_RETRY_AND_RECOVER)
|
||||||
|
|
||||||
|
#ifndef G29_MAX_RETRIES
|
||||||
|
#define G29_MAX_RETRIES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
void GcodeSuite::G29_with_retry() {
|
void GcodeSuite::G29_with_retry() {
|
||||||
set_bed_leveling_enabled(false);
|
uint8_t retries = G29_MAX_RETRIES;
|
||||||
for (uint8_t retries_left = G29_MAX_RETRIES;;) {
|
while (G29()) { // G29 should return true for failed probes ONLY
|
||||||
G29();
|
if (retries--) {
|
||||||
if (planner.leveling_active || !retries_left--) break;
|
#ifdef G29_ACTION_ON_RECOVER
|
||||||
#ifdef G29_ACTION_ON_RECOVER
|
SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_RECOVER);
|
||||||
SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_RECOVER);
|
#endif
|
||||||
#endif
|
#ifdef G29_RECOVER_COMMANDS
|
||||||
#ifdef G29_RECOVER_COMMANDS
|
process_subcommands_now_P(PSTR(G29_RECOVER_COMMANDS));
|
||||||
process_subcommands_now_P(PSTR(G29_RECOVER_COMMANDS));
|
#endif
|
||||||
#endif
|
}
|
||||||
}
|
else {
|
||||||
if (planner.leveling_active) {
|
#ifdef G29_FAILURE_COMMANDS
|
||||||
#ifdef G29_SUCCESS_COMMANDS
|
process_subcommands_now_P(PSTR(G29_FAILURE_COMMANDS));
|
||||||
process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS));
|
#endif
|
||||||
#endif
|
#ifdef G29_ACTION_ON_FAILURE
|
||||||
}
|
SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_FAILURE);
|
||||||
else {
|
#endif
|
||||||
#ifdef G29_FAILURE_COMMANDS
|
#if ENABLED(G29_HALT_ON_FAILURE)
|
||||||
process_subcommands_now_P(PSTR(G29_FAILURE_COMMANDS));
|
kill(PSTR(MSG_ERR_PROBING_FAILED));
|
||||||
#endif
|
#endif
|
||||||
#ifdef G29_ACTION_ON_FAILURE
|
return;
|
||||||
SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_FAILURE);
|
}
|
||||||
#endif
|
|
||||||
#if ENABLED(G29_HALT_ON_FAILURE)
|
|
||||||
kill(PSTR(MSG_ERR_PROBING_FAILED));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#ifdef G29_SUCCESS_COMMANDS
|
||||||
|
process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_LEVELING && G29_RETRY_AND_RECOVER
|
#endif // HAS_LEVELING && G29_RETRY_AND_RECOVER
|
||||||
|
@ -387,10 +387,13 @@ private:
|
|||||||
static void G28(const bool always_home_all);
|
static void G28(const bool always_home_all);
|
||||||
|
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
static void G29();
|
|
||||||
#if ENABLED(G29_RETRY_AND_RECOVER)
|
#if ENABLED(G29_RETRY_AND_RECOVER)
|
||||||
static void G29_with_retry();
|
static void G29_with_retry();
|
||||||
|
#define G29_TYPE bool
|
||||||
|
#else
|
||||||
|
#define G29_TYPE void
|
||||||
#endif
|
#endif
|
||||||
|
static G29_TYPE G29();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
|
@ -936,6 +936,10 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE,
|
|||||||
#error "MESH_EDIT_GFX_OVERLAY requires AUTO_BED_LEVELING_UBL and a Graphical LCD."
|
#error "MESH_EDIT_GFX_OVERLAY requires AUTO_BED_LEVELING_UBL and a Graphical LCD."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(G29_RETRY_AND_RECOVER) && HAS_LEVELING && !OLDSCHOOL_ABL
|
||||||
|
#error "G29_RETRY_AND_RECOVER currently only supports ABL"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LCD_BED_LEVELING requirements
|
* LCD_BED_LEVELING requirements
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user