From 5768ee0f9ebb09b69b6e3acfe4f1b4876291f169 Mon Sep 17 00:00:00 2001 From: wmariz <11435639+wmariz@users.noreply.github.com> Date: Wed, 18 Nov 2020 00:54:21 -0300 Subject: [PATCH] Probe Wizard XY position (#20167) --- Marlin/Configuration_adv.h | 3 ++- Marlin/src/inc/Conditionals_post.h | 1 + Marlin/src/lcd/marlinui.h | 2 +- Marlin/src/lcd/menu/menu.h | 2 +- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/lcd/menu/menu_probe_offset.cpp | 31 +++++++++++++++-------- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2c9ac1aea4..0951dfaa6d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1085,6 +1085,7 @@ //#define PROBE_OFFSET_WIZARD #if ENABLED(PROBE_OFFSET_WIZARD) #define PROBE_OFFSET_START -4.0 // Estimated nozzle-to-probe Z offset, plus a little extra + //#define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER // Set a convenient position to do the measurement #endif #endif @@ -3447,7 +3448,7 @@ #define GANTRY_CALIBRATION_FEEDRATE 500 // Feedrate for correction move //#define GANTRY_CALIBRATION_TO_MIN // Enable to calibrate Z in the MIN direction - //#define GANTRY_CALIBRATION_SAFE_POSITION { X_CENTER, Y_CENTER } // Safe position for nozzle + //#define GANTRY_CALIBRATION_SAFE_POSITION XY_CENTER // Safe position for nozzle //#define GANTRY_CALIBRATION_XY_PARK_FEEDRATE 3000 // XY Park Feedrate - MMM //#define GANTRY_CALIBRATION_COMMANDS_PRE "" #define GANTRY_CALIBRATION_COMMANDS_POST "G28" // G28 highly recommended to ensure an accurate position diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index f8727dd963..acb5cc2351 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -100,6 +100,7 @@ #define _Y_HALF_BED ((Y_BED_SIZE) / 2) #define X_CENTER TERN(BED_CENTER_AT_0_0, 0, _X_HALF_BED) #define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED) +#define XY_CENTER { X_CENTER, Y_CENTER } // Get the linear boundaries of the bed #define X_MIN_BED (X_CENTER - _X_HALF_BED) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 0445c641ba..6ce59132bf 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -622,7 +622,7 @@ public: // // Special handling if a move is underway // - #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)) + #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)) || (ENABLED(PROBE_OFFSET_WIZARD) && defined(PROBE_OFFSET_WIZARD_XY_POS)) #define LCD_HAS_WAIT_FOR_MOVE 1 static bool wait_for_move; #else diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 4dd66637f1..66fe73cec1 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -220,7 +220,7 @@ void _lcd_draw_homing(); #endif #if ENABLED(PROBE_OFFSET_WIZARD) - void goto_probe_offset_wizard(); + void home_and_goto_probe_offset_wizard(); #endif #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index fdddf1781a..12f9d57b46 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -488,7 +488,7 @@ void menu_backlash(); EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); #if ENABLED(PROBE_OFFSET_WIZARD) - SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard); + SUBMENU(MSG_PROBE_WIZARD, home_and_goto_probe_offset_wizard); #endif END_MENU(); diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 8a6cbaaf31..9f21550098 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -36,6 +36,7 @@ #include "menu_item.h" #include "menu_addon.h" +#include "../../gcode/queue.h" #include "../../module/motion.h" #include "../../module/planner.h" #include "../../module/probe.h" @@ -120,22 +121,32 @@ void probe_offset_wizard_menu() { END_MENU(); } -void goto_probe_offset_wizard() { - ui.defer_status_screen(); +#ifdef PROBE_OFFSET_WIZARD_XY_POS - prepare_for_calibration(); + #define HAS_PROBE_OFFSET_WIZARD_XY_POS 1 - probe.offset.z = PROBE_OFFSET_START; + inline void goto_probe_offset_wizard() { + if (ui.wait_for_move) return; + constexpr xy_pos_t wizard_pos = PROBE_OFFSET_WIZARD_XY_POS; + current_position = wizard_pos; + ui.wait_for_move = true; + line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY)); // Could invoke idle() + ui.wait_for_move = false; + ui.synchronize(); + prepare_for_calibration(); + probe.offset.z = PROBE_OFFSET_START; + ui.goto_screen(probe_offset_wizard_menu); + ui.defer_status_screen(); + } - set_all_unhomed(); +#endif + +void home_and_goto_probe_offset_wizard() { queue.inject_P(G28_STR); - ui.goto_screen([]{ _lcd_draw_homing(); - if (all_axes_homed()) { - ui.goto_screen(probe_offset_wizard_menu); - ui.defer_status_screen(); - } + if (all_axes_homed()) + ui.goto_screen(TERN(HAS_PROBE_OFFSET_WIZARD_XY_POS, goto_probe_offset_wizard, probe_offset_wizard_menu)); }); }