From 96b8c28376fbefa92ebd71119bda1db66daa20ea Mon Sep 17 00:00:00 2001 From: kisslorand <50251547+kisslorand@users.noreply.github.com> Date: Fri, 2 Dec 2022 08:19:34 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20G30=20move=20to=20logical=20XY?= =?UTF-8?q?=20(#24953)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 6 +++--- Marlin/src/gcode/probe/G30.cpp | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 0281dea08c..61c182448e 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -309,9 +309,9 @@ typedef abce_float_t abce_pos_t; void toLogical(xy_pos_t &raw); void toLogical(xyz_pos_t &raw); void toLogical(xyze_pos_t &raw); -void toNative(xy_pos_t &raw); -void toNative(xyz_pos_t &raw); -void toNative(xyze_pos_t &raw); +void toNative(xy_pos_t &lpos); +void toNative(xyz_pos_t &lpos); +void toNative(xyze_pos_t &lpos); // // Paired XY coordinates, counters, flags, etc. diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index e474ffe9d6..6893d4bec2 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -58,16 +58,13 @@ void GcodeSuite::G30() { tool_change(0); #endif - const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x), - parser.linearval('Y', current_position.y + probe.offset_xy.y) }; + // Convert the given logical position to native position + const xy_pos_t pos = { + parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x, + parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y + }; - if (!probe.can_reach(pos)) { - #if ENABLED(DWIN_LCD_PROUI) - SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); - LCD_MESSAGE(MSG_ZPROBE_OUT); - #endif - } - else { + if (probe.can_reach(pos)) { // Disable leveling so the planner won't mess with us TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); @@ -83,7 +80,7 @@ void GcodeSuite::G30() { const float measured_z = probe.probe_at_point(pos, raise_after, 1); TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) { - SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); + SERIAL_ECHOLNPGM("Bed X: ", pos.asLogical().x, " Y: ", pos.asLogical().y, " Z: ", measured_z); #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) char msg[31], str_1[6], str_2[6], str_3[6]; sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), @@ -102,6 +99,12 @@ void GcodeSuite::G30() { report_current_position(); } + else { + #if ENABLED(DWIN_LCD_PROUI) + SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); + LCD_MESSAGE(MSG_ZPROBE_OUT); + #endif + } // Restore the active tool TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));