From 522ac98d5402c1d80154a249414086872ec48af2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 2 Jan 2021 19:01:09 -0600 Subject: [PATCH] Add ALL_AXES manual move for UBL mesh editing Co-Authored-By: Jason Smith <20053467+sjasonsmith@users.noreply.github.com> #20620 --- Marlin/src/lcd/marlinui.cpp | 15 +++++++++++---- Marlin/src/lcd/marlinui.h | 15 +++++++++++++++ Marlin/src/lcd/menu/menu_ubl.cpp | 7 +++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 3c2f930e68ab3..e59b72f47d8a9 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -684,8 +684,11 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { millis_t ManualMove::start_time = 0; float ManualMove::menu_scale = 1; - TERN_(IS_KINEMATIC, float ManualMove::offset = 0); - TERN_(IS_KINEMATIC, bool ManualMove::processing = false); + #if IS_KINEMATIC + float ManualMove::offset = 0; + xyze_pos_t ManualMove::all_axes_destination = { 0 }; + bool ManualMove::processing = false; + #endif TERN_(MULTI_MANUAL, int8_t ManualMove::e_index = 0); AxisEnum ManualMove::axis = NO_AXIS; @@ -725,8 +728,12 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #endif // Apply a linear offset to a single axis - destination = current_position; - if (axis <= XYZE) destination[axis] += offset; + if (axis == ALL_AXES) + destination = all_axes_destination; + else if (axis <= XYZE) { + destination = current_position; + destination[axis] += offset; + } // Reset for the next move offset = 0; diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index d7285927a3053..a926dd58f45d4 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -23,6 +23,8 @@ #include "../inc/MarlinConfig.h" +#include "../module/motion.h" + #if HAS_BUZZER #include "../libs/buzzer.h" #endif @@ -270,9 +272,22 @@ static int8_t constexpr e_index = 0; #endif static millis_t start_time; + TERN_(IS_KINEMATIC, static xyze_pos_t all_axes_destination); public: static float menu_scale; TERN_(IS_KINEMATIC, static float offset); + template + void set_destination(const T& dest) { + #if IS_KINEMATIC + // Moves are segmented, so the entire move is not submitted at once. + // Using a separate variable prevents corrupting the in-progress move. + all_axes_destination = current_position; + all_axes_destination.set(dest); + #else + // Moves are submitted as single line to the planner using buffer_line. + current_position.set(dest); + #endif + } #if IS_KINEMATIC static bool processing; #else diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 9b78416717928..52b7b1ccb0ae6 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -426,10 +426,9 @@ void ubl_map_move_to_xy() { } #endif - // Do an internal move to the mesh point - destination.set(ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot)); - constexpr feedRate_t fr_mm_s = MMM_TO_MMS(XY_PROBE_SPEED); - prepare_internal_move_to_destination(fr_mm_s); // Set current_position from destination + // Use the built-in manual move handler to move to the mesh point. + ui.manual_move.set_destination(xy); + ui.manual_move.soon(ALL_AXES); } inline int32_t grid_index(const uint8_t x, const uint8_t y) {