From 13599a73c7d2c356b20695e2e1556952b2f5d3cf Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 May 2017 19:03:00 -0400 Subject: [PATCH] Add `G7` gcode command to move between UBL mesh points - can be augmented in the future to enable for other leveling systems Quite simple, but did not want to modify `G1` as the additional checking would slow it down. Tested & working. --- Marlin/Marlin_main.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 352c01eb6..1d2985366 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3395,6 +3395,34 @@ inline void gcode_G4() { #endif // BEZIER_CURVE_SUPPORT +#if ENABLED(AUTO_BED_LEVELING_UBL) //todo: enable for other leveling systems? +/** + * G7: Move X & Y axes to mesh coordinates + */ +inline void gcode_G7( + #if IS_SCARA + bool fast_move=false + #endif +) { + if (IsRunning()) { + destination[X_AXIS] = code_seen('I') ? pgm_read_float(&ubl.mesh_index_to_xpos[code_has_value() ? code_value_int() : 0]) : current_position[X_AXIS]; + destination[Y_AXIS] = code_seen('J') ? pgm_read_float(&ubl.mesh_index_to_ypos[code_has_value() ? code_value_int() : 0]) : current_position[Y_AXIS]; + destination[Z_AXIS] = current_position[Z_AXIS]; //todo: perhaps add Z-move support? + destination[E_AXIS] = current_position[E_AXIS]; + + if (code_seen('F') && code_value_linear_units() > 0.0) + feedrate_mm_s = MMM_TO_MMS(code_value_linear_units()); + + #if IS_SCARA + fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination(); + #else + prepare_move_to_destination(); + #endif + } +} +#endif + + #if ENABLED(FWRETRACT) /** @@ -9982,6 +10010,16 @@ void process_next_command() { break; #endif // BEZIER_CURVE_SUPPORT + #if ENABLED(AUTO_BED_LEVELING_UBL) + case 7: + #if IS_SCARA + gcode_G7(codenum == 0); + #else + gcode_G7(); + #endif + break; + #endif + #if ENABLED(FWRETRACT) case 10: // G10: retract case 11: // G11: retract_recover