From 80359c9937c98bf6a3e9f218814a44b68b04f6f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 20 Feb 2019 14:51:26 -0600 Subject: [PATCH] Add more parameters to M240 Co-Authored-By: shitcreek <45380455+shitcreek@users.noreply.github.com> --- Marlin/src/gcode/feature/camera/M240.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/feature/camera/M240.cpp b/Marlin/src/gcode/feature/camera/M240.cpp index 689252a35..4c376be5b 100644 --- a/Marlin/src/gcode/feature/camera/M240.cpp +++ b/Marlin/src/gcode/feature/camera/M240.cpp @@ -76,6 +76,9 @@ * configured position, delay, and retract length. * * PHOTO_POSITION parameters: + * A - X offset to the return position + * B - Y offset to the return position + * F - Override the XY movement feedrate * R - Retract/recover length (current units) * S - Retract/recover feedrate (mm/m) * X - Move to X before triggering the shutter @@ -94,7 +97,11 @@ void GcodeSuite::M240() { if (axis_unhomed_error()) return; - const float old_pos[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] }; + const float old_pos[XYZ] = { + current_position[X_AXIS] + parser.linearval('A'), + current_position[Y_AXIS] + parser.linearval('B'), + current_position[Z_AXIS] + }; #ifdef PHOTO_RETRACT_MM constexpr float rfr = (MMS_TO_MMM( @@ -111,6 +118,9 @@ void GcodeSuite::M240() { e_move_m240(-rval, sval); #endif + float fr_mm_s = MMM_TO_MMS(parser.linearval('F')); + if (fr_mm_s) NOLESS(fr_mm_s, 10.0f); + constexpr float photo_position[XYZ] = PHOTO_POSITION; float raw[XYZ] = { parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : photo_position[X_AXIS], @@ -118,7 +128,7 @@ void GcodeSuite::M240() { (parser.seenval('Z') ? parser.value_linear_units() : photo_position[Z_AXIS]) + current_position[Z_AXIS] }; clamp_to_software_endstops(raw); - do_blocking_move_to(raw); + do_blocking_move_to(raw, fr_mm_s); #ifdef PHOTO_SWITCH_POSITION constexpr float photo_switch_position[2] = PHOTO_SWITCH_POSITION; @@ -152,7 +162,7 @@ void GcodeSuite::M240() { #if PHOTO_DELAY_MS > 0 safe_delay(parser.intval('P', PHOTO_DELAY_MS)); #endif - do_blocking_move_to(old_pos); + do_blocking_move_to(old_pos, fr_mm_s); #ifdef PHOTO_RETRACT_MM e_move_m240(rval, sval); #endif