Skip to content

Commit 7901eb9

Browse files
committed
⚡️ G30 optimize and comment
1 parent 7aaba66 commit 7901eb9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Marlin/src/gcode/probe/G30.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
*/
5151
void GcodeSuite::G30() {
5252

53-
xy_pos_t old_pos = current_position,
54-
probepos = current_position;
53+
xy_pos_t probepos = current_position;
5554

5655
const bool seenX = parser.seenval('X');
5756
if (seenX) probepos.x = RAW_X_POSITION(parser.value_linear_units());
@@ -62,21 +61,28 @@ void GcodeSuite::G30() {
6261

6362
if (probe.can_reach(probepos)) {
6463

65-
if (seenX) old_pos.x = probepos.x;
66-
if (seenY) old_pos.y = probepos.y;
67-
6864
// Disable leveling so the planner won't mess with us
6965
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
7066

67+
// Disable feedrate scaling so movement speeds are correct
7168
remember_feedrate_scaling_off();
7269

70+
// With VERBOSE_SINGLE_PROBE home only if needed
7371
TERN_(VERBOSE_SINGLE_PROBE, process_subcommands_now(F("G28O")));
7472

73+
// Raise after based on the 'E' parameter
7574
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
7675

76+
// Use 'C' to set Probe Temperature Compensation ON/OFF (on by default)
7777
TERN_(HAS_PTC, ptc.set_enabled(parser.boolval('C', true)));
78+
79+
// Probe the bed, optionally raise, and return the measured height
7880
const float measured_z = probe.probe_at_point(probepos, raise_after);
81+
82+
// After probing always re-enable Probe Temperature Compensation
7983
TERN_(HAS_PTC, ptc.set_enabled(true));
84+
85+
// Report a good probe result to the host and LCD
8086
if (!isnan(measured_z)) {
8187
const xy_pos_t lpos = probepos.asLogical();
8288
SString<30> msg(
@@ -88,9 +94,11 @@ void GcodeSuite::G30() {
8894
TERN_(VERBOSE_SINGLE_PROBE, ui.set_status(msg));
8995
}
9096

97+
// Restore feedrate scaling
9198
restore_feedrate_and_scaling();
9299

93-
do_blocking_move_to(old_pos);
100+
// Move the nozzle to the position of the probe
101+
do_blocking_move_to(probepos);
94102

95103
if (raise_after == PROBE_PT_STOW)
96104
probe.move_z_after_probing();

0 commit comments

Comments
 (0)