From be5ca3421543a3c88b2141b1ee45e9f1600292c4 Mon Sep 17 00:00:00 2001 From: Roxy-3D Date: Tue, 15 Aug 2017 17:04:52 -0500 Subject: [PATCH] Allow G29 to work correctly even if nozzle is off the mesh. (#7512) * work around previous regressions... --- Marlin/ubl_G29.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index bc645fb2c4..2bdc14a69e 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -1132,15 +1132,12 @@ SERIAL_PROTOCOLLNPGM("Both X & Y locations must be specified.\n"); err_flag = true; } - if (!WITHIN(RAW_X_POSITION(g29_x_pos), X_MIN_BED, X_MAX_BED)) { - SERIAL_PROTOCOLLNPGM("Invalid X location specified.\n"); - err_flag = true; - } - if (!WITHIN(RAW_Y_POSITION(g29_y_pos), Y_MIN_BED, Y_MAX_BED)) { - SERIAL_PROTOCOLLNPGM("Invalid Y location specified.\n"); - err_flag = true; - } + if (!WITHIN(RAW_X_POSITION(g29_x_pos), X_MIN_BED, X_MAX_BED)) // if X & Y are not valid, use center of the bed values + g29_x_pos = (X_MIN_BED + X_MAX_BED) / 2.0; + + if (!WITHIN(RAW_Y_POSITION(g29_y_pos), Y_MIN_BED, Y_MAX_BED)) // if X & Y are not valid, use center of the bed values + g29_y_pos = (Y_MIN_BED + Y_MAX_BED) / 2.0; if (err_flag) return UBL_ERR;