From 5660fcffb08841742103e67f32eb3cd3da30ae23 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 30 Dec 2019 14:49:07 +0100 Subject: [PATCH] Do not enqueue a E/Z moves unless requested Do not unconditionally enqueue a Z move if no move has been requested. Since Z is calculated using the absolute current (saved) position and scheduled for later execution, the queue order becomes relevant. --- Firmware/Marlin_main.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3327f8f8..c8e142c4 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10238,23 +10238,29 @@ void stop_and_save_print_to_ram(float z_move, float e_move) // move away from the print. char buf[48]; - // First unretract (relative extrusion) - if(!saved_extruder_relative_mode){ - enquecommand(PSTR("M83"), true); - } - //retract 45mm/s - // A single sprintf may not be faster, but is definitely 20B shorter - // than a sequence of commands building the string piece by piece - // A snprintf would have been a safer call, but since it is not used - // in the whole program, its implementation would bring more bytes to the total size - // The behavior of dtostrf 8,3 should be roughly the same as %-0.3 - sprintf_P(buf, PSTR("G1 E%-0.3f F2700"), e_move); - enquecommand(buf, false); + if(e_move) + { + // First unretract (relative extrusion) + if(!saved_extruder_relative_mode){ + enquecommand(PSTR("M83"), true); + } + //retract 45mm/s + // A single sprintf may not be faster, but is definitely 20B shorter + // than a sequence of commands building the string piece by piece + // A snprintf would have been a safer call, but since it is not used + // in the whole program, its implementation would bring more bytes to the total size + // The behavior of dtostrf 8,3 should be roughly the same as %-0.3 + sprintf_P(buf, PSTR("G1 E%-0.3f F2700"), e_move); + enquecommand(buf, false); + } + + if(z_move) + { + // Then lift Z axis + sprintf_P(buf, PSTR("G1 Z%-0.3f F%-0.3f"), saved_pos[Z_AXIS] + z_move, homing_feedrate[Z_AXIS]); + enquecommand(buf, false); + } - // Then lift Z axis - sprintf_P(buf, PSTR("G1 Z%-0.3f F%-0.3f"), saved_pos[Z_AXIS] + z_move, homing_feedrate[Z_AXIS]); - // At this point the command queue is empty. - enquecommand(buf, false); // If this call is invoked from the main Arduino loop() function, let the caller know that the command // in the command queue is not the original command, but a new one, so it should not be removed from the queue. repeatcommand_front();