EVENT_GCODE_BEFORE_G29 (#27566)

This commit is contained in:
Scott Lahteine 2025-01-08 23:03:41 -06:00 committed by GitHub
parent 7eee772f60
commit acd825972c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 8 deletions

View file

@ -2108,6 +2108,12 @@
//#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING
/**
* Commands to execute at the start of G29 probing,
* after switching to the PROBING_TOOL.
*/
//#define EVENT_GCODE_BEFORE_G29 "M300 P440 S200"
/**
* Commands to execute at the end of G29 probing.
* Useful to retract or move the Z probe out of the way.

View file

@ -297,7 +297,13 @@ G29_parameters_t unified_bed_leveling::param;
void unified_bed_leveling::G29() {
bool probe_deployed = false;
#ifdef EVENT_GCODE_AFTER_G29
bool probe_deployed = false;
#define SET_PROBE_DEPLOYED(N) probe_deployed = N
#else
#define SET_PROBE_DEPLOYED(N)
#endif
if (G29_parse_parameters()) return; // Abort on parameter error
const uint8_t p_val = parser.byteval('P');
@ -316,6 +322,11 @@ void unified_bed_leveling::G29() {
#endif
probe.use_probing_tool();
#ifdef EVENT_GCODE_BEFORE_G29
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Before G29 G-code: ", EVENT_GCODE_BEFORE_G29);
gcode.process_subcommands_now(F(EVENT_GCODE_BEFORE_G29));
#endif
// Position bed horizontally and Z probe vertically.
#if HAS_SAFE_BED_LEVELING
xyze_pos_t safe_position = current_position;
@ -430,7 +441,7 @@ void unified_bed_leveling::G29() {
do_blocking_move_to_xy(0.5f * ((MESH_MIN_X) + (MESH_MAX_X)), 0.5f * ((MESH_MIN_Y) + (MESH_MAX_Y)));
#endif
report_current_position();
probe_deployed = true;
SET_PROBE_DEPLOYED(true);
}
#endif // HAS_BED_PROBE
@ -465,7 +476,7 @@ void unified_bed_leveling::G29() {
probe_entire_mesh(param.XY_pos, parser.seen_test('T'), parser.seen_test('E'), parser.seen_test('U'));
report_current_position();
probe_deployed = true;
SET_PROBE_DEPLOYED(true);
} break;
#endif // HAS_BED_PROBE
@ -503,7 +514,7 @@ void unified_bed_leveling::G29() {
SERIAL_ECHOLNPGM("?Error in Business Card measurement.");
return;
}
probe_deployed = true;
SET_PROBE_DEPLOYED(true);
}
if (!position_is_reachable(param.XY_pos)) {
@ -681,13 +692,11 @@ void unified_bed_leveling::G29() {
#endif
#ifdef EVENT_GCODE_AFTER_G29
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", EVENT_GCODE_AFTER_G29);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("After G29 G-code: ", EVENT_GCODE_AFTER_G29);
if (probe_deployed) {
planner.synchronize();
gcode.process_subcommands_now(F(EVENT_GCODE_AFTER_G29));
}
#else
UNUSED(probe_deployed);
#endif
probe.use_probing_tool(false);

View file

@ -287,6 +287,11 @@ G29_TYPE GcodeSuite::G29() {
probe.use_probing_tool();
#ifdef EVENT_GCODE_BEFORE_G29
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Before G29 G-code: ", EVENT_GCODE_BEFORE_G29);
gcode.process_subcommands_now(F(EVENT_GCODE_BEFORE_G29));
#endif
#if ANY(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
abl.abl_probe_index = -1;
#endif
@ -1007,7 +1012,7 @@ G29_TYPE GcodeSuite::G29() {
TERN_(HAS_BED_PROBE, probe.move_z_after_probing());
#ifdef EVENT_GCODE_AFTER_G29
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", EVENT_GCODE_AFTER_G29);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("After G29 G-code: ", EVENT_GCODE_AFTER_G29);
planner.synchronize();
process_subcommands_now(F(EVENT_GCODE_AFTER_G29));
#endif