From 211ff674405d1291a177d071fb40f3da8c13c93c Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Sun, 6 Oct 2019 23:58:19 -0500
Subject: [PATCH] Patch blocking and manual moves

---
 Marlin/src/feature/bedlevel/bedlevel.cpp     |  6 ++--
 Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp  |  8 ++---
 Marlin/src/lcd/menu/menu_delta_calibrate.cpp |  2 +-
 Marlin/src/module/motion.cpp                 | 21 +++++++++++-
 Marlin/src/module/motion.h                   | 34 +++++++-------------
 5 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp
index d92f903a9f8..ef8cfd34553 100644
--- a/Marlin/src/feature/bedlevel/bedlevel.cpp
+++ b/Marlin/src/feature/bedlevel/bedlevel.cpp
@@ -228,14 +228,14 @@ void reset_bed_level() {
     #ifdef MANUAL_PROBE_START_Z
       constexpr float startz = _MAX(0, MANUAL_PROBE_START_Z);
       #if MANUAL_PROBE_HEIGHT > 0
-        do_blocking_move_to(pos, MANUAL_PROBE_HEIGHT);
+        do_blocking_move_to_xy_z(pos, MANUAL_PROBE_HEIGHT);
         do_blocking_move_to_z(startz);
       #else
-        do_blocking_move_to(pos, startz);
+        do_blocking_move_to_xy_z(pos, startz);
       #endif
     #elif MANUAL_PROBE_HEIGHT > 0
       const float prev_z = current_position.z;
-      do_blocking_move_to(pos, MANUAL_PROBE_HEIGHT);
+      do_blocking_move_to_xy_z(pos, MANUAL_PROBE_HEIGHT);
       do_blocking_move_to_z(prev_z);
     #else
       do_blocking_move_to_xy(pos);
diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
index 6005e9881f0..d016667e443 100644
--- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
+++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
@@ -892,7 +892,7 @@
       ui.capture();
 
       save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
-      do_blocking_move_to(current_position.x, current_position.y, z_clearance);
+      do_blocking_move_to_xy_z(current_position, z_clearance);
 
       ui.return_to_status();
 
@@ -948,7 +948,7 @@
       if (do_ubl_mesh_map) display_map(g29_map_type);  // show user where we're probing
 
       restore_ubl_active_state_and_leave();
-      do_blocking_move_to(pos, Z_CLEARANCE_DEPLOY_PROBE);
+      do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE);
     }
 
     inline void set_message_with_feedback(PGM_P const msg_P) {
@@ -986,7 +986,7 @@
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
       ui.capture();                                         // Take over control of the LCD encoder
 
-      do_blocking_move_to(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
+      do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
 
       #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
         do_blocking_move_to_z(h_offset);                    // Move Z to the given 'H' offset
@@ -1055,7 +1055,7 @@
       if (do_ubl_mesh_map) display_map(g29_map_type);
       restore_ubl_active_state_and_leave();
 
-      do_blocking_move_to(pos, Z_CLEARANCE_BETWEEN_PROBES);
+      do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES);
 
       LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
       SERIAL_ECHOLNPGM("Done Editing Mesh");
diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp
index 02e3c3b0449..42834b506bc 100644
--- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp
+++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp
@@ -41,7 +41,7 @@
 #endif
 
 void _man_probe_pt(const xy_pos_t &xy) {
-  do_blocking_move_to(xy, Z_CLEARANCE_BETWEEN_PROBES);
+  do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES);
   ui.synchronize();
   move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
   ui.goto_screen(lcd_move_z);
diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp
index 1abc5692c61..7d9e2fcda70 100644
--- a/Marlin/src/module/motion.cpp
+++ b/Marlin/src/module/motion.cpp
@@ -430,6 +430,17 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
 
   planner.synchronize();
 }
+
+void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) {
+  do_blocking_move_to(raw.x, raw.y, current_position.z, fr_mm_s);
+}
+void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) {
+  do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s);
+}
+void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) {
+  do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s);
+}
+
 void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s/*=0.0*/) {
   do_blocking_move_to(rx, current_position.y, current_position.z, fr_mm_s);
 }
@@ -437,11 +448,19 @@ void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) {
   do_blocking_move_to(current_position.x, ry, current_position.z, fr_mm_s);
 }
 void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s/*=0.0*/) {
-  do_blocking_move_to(current_position.x, current_position.y, rz, fr_mm_s);
+  do_blocking_move_to_xy_z(current_position, rz, fr_mm_s);
 }
+
 void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) {
   do_blocking_move_to(rx, ry, current_position.z, fr_mm_s);
 }
+void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) {
+  do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s);
+}
+
+void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s/*=0.0f*/) {
+  do_blocking_move_to(raw.x, raw.y, z, fr_mm_s);
+}
 
 //
 // Prepare to do endstop or probe moves with custom feedrates.
diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h
index ba37bebd469..5e07f710d4e 100644
--- a/Marlin/src/module/motion.h
+++ b/Marlin/src/module/motion.h
@@ -200,33 +200,23 @@ inline void prepare_internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f)
  * Blocking movement and shorthand functions
  */
 void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s=0.0f);
-
-FORCE_INLINE void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) {
-  do_blocking_move_to(raw.x, raw.y, current_position.z, fr_mm_s);
-}
-FORCE_INLINE void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) {
-  do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s);
-}
-FORCE_INLINE void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) {
-  do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s);
-}
-
-void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s=0.0f);
-
-FORCE_INLINE void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) {
-  do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s);
-}
-FORCE_INLINE void do_blocking_move_to_xy(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) {
-  do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s);
-}
-FORCE_INLINE void do_blocking_move_to_xy(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) {
-  do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s);
-}
+void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
+void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
+void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
 
 void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s=0.0f);
 void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s=0.0f);
 void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s=0.0f);
 
+void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s=0.0f);
+void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
+FORCE_INLINE void do_blocking_move_to_xy(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f)  { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); }
+FORCE_INLINE void do_blocking_move_to_xy(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); }
+
+void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f);
+FORCE_INLINE void do_blocking_move_to_xy_z(const xyz_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f)  { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); }
+FORCE_INLINE void do_blocking_move_to_xy_z(const xyze_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); }
+
 void remember_feedrate_and_scaling();
 void remember_feedrate_scaling_off();
 void restore_feedrate_and_scaling();