From c7df96114472b09ba4d109f59a90f9a307baf081 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 20 Apr 2016 13:01:58 -0700 Subject: [PATCH 1/2] Fix G92 so it only sets the plan position once --- Marlin/Marlin_main.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ecd9f9e38..7f49d8b5b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1427,6 +1427,7 @@ inline void sync_plan_position() { #endif plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); } +inline void sync_plan_position_e() { plan_set_e_position(current_position[E_AXIS]); } inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); } inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); } @@ -3642,8 +3643,9 @@ inline void gcode_G28() { * G92: Set current position to given X Y Z E */ inline void gcode_G92() { - if (!code_seen(axis_codes[E_AXIS])) - st_synchronize(); + bool didE = code_seen(axis_codes[E_AXIS]); + + if (!didE) st_synchronize(); bool didXYZ = false; for (int i = 0; i < NUM_AXIS; i++) { @@ -3653,14 +3655,11 @@ inline void gcode_G92() { current_position[i] = v; - if (i == E_AXIS) - plan_set_e_position(v); - else { + if (i != E_AXIS) { position_shift[i] += v - p; // Offset the coordinate space update_software_endstops((AxisEnum)i); - didXYZ = true; - } + } } } if (didXYZ) { @@ -3670,6 +3669,9 @@ inline void gcode_G92() { sync_plan_position(); #endif } + else if (didE) { + sync_plan_position_e(); + } } #if ENABLED(ULTIPANEL) From 1caa2628da8cb2cfda3eb5e2f47ebe8183c8b267 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 20 Apr 2016 13:02:19 -0700 Subject: [PATCH 2/2] Use sync_plan_position_e function elsewhere --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 7f49d8b5b..66e84843c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2321,7 +2321,7 @@ static void homeaxis(AxisEnum axis) { feedrate = retract_feedrate * 60; current_position[E_AXIS] += (swapping ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder]; - plan_set_e_position(current_position[E_AXIS]); + sync_plan_position_e(); prepare_move(); if (retract_zlift > 0.01) { @@ -2349,7 +2349,7 @@ static void homeaxis(AxisEnum axis) { feedrate = retract_recover_feedrate * 60; float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length; current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder]; - plan_set_e_position(current_position[E_AXIS]); + sync_plan_position_e(); prepare_move(); } @@ -2440,7 +2440,7 @@ inline void gcode_G0_G1() { // Is this move an attempt to retract or recover? if ((echange < -MIN_RETRACT && !retracted[active_extruder]) || (echange > MIN_RETRACT && retracted[active_extruder])) { current_position[E_AXIS] = destination[E_AXIS]; // hide the slicer-generated retract/recover from calculations - plan_set_e_position(current_position[E_AXIS]); // AND from the planner + sync_plan_position_e(); // AND from the planner retract(!retracted[active_extruder]); return; } @@ -6108,7 +6108,7 @@ inline void gcode_M503() { #endif current_position[E_AXIS] = destination[E_AXIS]; //the long retract of L is compensated by manual filament feeding - plan_set_e_position(current_position[E_AXIS]); + sync_plan_position_e(); RUNPLAN; //should do nothing