Skip to content

Commit 96b8c28

Browse files
kisslorandthinkyhead
authored andcommitted
🚸 G30 move to logical XY (#24953)
1 parent db38655 commit 96b8c28

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Marlin/src/core/types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ typedef abce_float_t abce_pos_t;
309309
void toLogical(xy_pos_t &raw);
310310
void toLogical(xyz_pos_t &raw);
311311
void toLogical(xyze_pos_t &raw);
312-
void toNative(xy_pos_t &raw);
313-
void toNative(xyz_pos_t &raw);
314-
void toNative(xyze_pos_t &raw);
312+
void toNative(xy_pos_t &lpos);
313+
void toNative(xyz_pos_t &lpos);
314+
void toNative(xyze_pos_t &lpos);
315315

316316
//
317317
// Paired XY coordinates, counters, flags, etc.

Marlin/src/gcode/probe/G30.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,13 @@ void GcodeSuite::G30() {
5858
tool_change(0);
5959
#endif
6060

61-
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
62-
parser.linearval('Y', current_position.y + probe.offset_xy.y) };
61+
// Convert the given logical position to native position
62+
const xy_pos_t pos = {
63+
parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x,
64+
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y
65+
};
6366

64-
if (!probe.can_reach(pos)) {
65-
#if ENABLED(DWIN_LCD_PROUI)
66-
SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
67-
LCD_MESSAGE(MSG_ZPROBE_OUT);
68-
#endif
69-
}
70-
else {
67+
if (probe.can_reach(pos)) {
7168
// Disable leveling so the planner won't mess with us
7269
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
7370

@@ -83,7 +80,7 @@ void GcodeSuite::G30() {
8380
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
8481
TERN_(HAS_PTC, ptc.set_enabled(true));
8582
if (!isnan(measured_z)) {
86-
SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
83+
SERIAL_ECHOLNPGM("Bed X: ", pos.asLogical().x, " Y: ", pos.asLogical().y, " Z: ", measured_z);
8784
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
8885
char msg[31], str_1[6], str_2[6], str_3[6];
8986
sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
@@ -102,6 +99,12 @@ void GcodeSuite::G30() {
10299

103100
report_current_position();
104101
}
102+
else {
103+
#if ENABLED(DWIN_LCD_PROUI)
104+
SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
105+
LCD_MESSAGE(MSG_ZPROBE_OUT);
106+
#endif
107+
}
105108

106109
// Restore the active tool
107110
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));

0 commit comments

Comments
 (0)