50
50
*/
51
51
void GcodeSuite::G30 () {
52
52
53
- xy_pos_t old_pos = current_position,
54
- probepos = current_position;
53
+ xy_pos_t probepos = current_position;
55
54
56
55
const bool seenX = parser.seenval (' X' );
57
56
if (seenX) probepos.x = RAW_X_POSITION (parser.value_linear_units ());
@@ -62,21 +61,28 @@ void GcodeSuite::G30() {
62
61
63
62
if (probe.can_reach (probepos)) {
64
63
65
- if (seenX) old_pos.x = probepos.x ;
66
- if (seenY) old_pos.y = probepos.y ;
67
-
68
64
// Disable leveling so the planner won't mess with us
69
65
TERN_ (HAS_LEVELING, set_bed_leveling_enabled (false ));
70
66
67
+ // Disable feedrate scaling so movement speeds are correct
71
68
remember_feedrate_scaling_off ();
72
69
70
+ // With VERBOSE_SINGLE_PROBE home only if needed
73
71
TERN_ (VERBOSE_SINGLE_PROBE, process_subcommands_now (F (" G28O" )));
74
72
73
+ // Raise after based on the 'E' parameter
75
74
const ProbePtRaise raise_after = parser.boolval (' E' , true ) ? PROBE_PT_STOW : PROBE_PT_NONE;
76
75
76
+ // Use 'C' to set Probe Temperature Compensation ON/OFF (on by default)
77
77
TERN_ (HAS_PTC, ptc.set_enabled (parser.boolval (' C' , true )));
78
+
79
+ // Probe the bed, optionally raise, and return the measured height
78
80
const float measured_z = probe.probe_at_point (probepos, raise_after);
81
+
82
+ // After probing always re-enable Probe Temperature Compensation
79
83
TERN_ (HAS_PTC, ptc.set_enabled (true ));
84
+
85
+ // Report a good probe result to the host and LCD
80
86
if (!isnan (measured_z)) {
81
87
const xy_pos_t lpos = probepos.asLogical ();
82
88
SString<30 > msg (
@@ -88,9 +94,11 @@ void GcodeSuite::G30() {
88
94
TERN_ (VERBOSE_SINGLE_PROBE, ui.set_status (msg));
89
95
}
90
96
97
+ // Restore feedrate scaling
91
98
restore_feedrate_and_scaling ();
92
99
93
- do_blocking_move_to (old_pos);
100
+ // Move the nozzle to the position of the probe
101
+ do_blocking_move_to (probepos);
94
102
95
103
if (raise_after == PROBE_PT_STOW)
96
104
probe.move_z_after_probing ();
0 commit comments