1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 22:08:02 +00:00

Merge pull request #3577 from thinkyhead/rc_fix_G92_set_e_twice

Fix G92 setting E twice
This commit is contained in:
Scott Lahteine 2016-04-20 20:52:09 -07:00
commit cfd10fcba1

View File

@ -1427,6 +1427,7 @@ inline void sync_plan_position() {
#endif #endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); 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_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); } inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
@ -2320,7 +2321,7 @@ static void homeaxis(AxisEnum axis) {
feedrate = retract_feedrate * 60; feedrate = retract_feedrate * 60;
current_position[E_AXIS] += (swapping ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder]; 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(); prepare_move();
if (retract_zlift > 0.01) { if (retract_zlift > 0.01) {
@ -2348,7 +2349,7 @@ static void homeaxis(AxisEnum axis) {
feedrate = retract_recover_feedrate * 60; feedrate = retract_recover_feedrate * 60;
float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length; 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]; current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
plan_set_e_position(current_position[E_AXIS]); sync_plan_position_e();
prepare_move(); prepare_move();
} }
@ -2439,7 +2440,7 @@ inline void gcode_G0_G1() {
// Is this move an attempt to retract or recover? // Is this move an attempt to retract or recover?
if ((echange < -MIN_RETRACT && !retracted[active_extruder]) || (echange > MIN_RETRACT && retracted[active_extruder])) { 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 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]); retract(!retracted[active_extruder]);
return; return;
} }
@ -3642,8 +3643,9 @@ inline void gcode_G28() {
* G92: Set current position to given X Y Z E * G92: Set current position to given X Y Z E
*/ */
inline void gcode_G92() { inline void gcode_G92() {
if (!code_seen(axis_codes[E_AXIS])) bool didE = code_seen(axis_codes[E_AXIS]);
st_synchronize();
if (!didE) st_synchronize();
bool didXYZ = false; bool didXYZ = false;
for (int i = 0; i < NUM_AXIS; i++) { for (int i = 0; i < NUM_AXIS; i++) {
@ -3653,12 +3655,9 @@ inline void gcode_G92() {
current_position[i] = v; current_position[i] = v;
if (i == E_AXIS) if (i != E_AXIS) {
plan_set_e_position(v);
else {
position_shift[i] += v - p; // Offset the coordinate space position_shift[i] += v - p; // Offset the coordinate space
update_software_endstops((AxisEnum)i); update_software_endstops((AxisEnum)i);
didXYZ = true; didXYZ = true;
} }
} }
@ -3670,6 +3669,9 @@ inline void gcode_G92() {
sync_plan_position(); sync_plan_position();
#endif #endif
} }
else if (didE) {
sync_plan_position_e();
}
} }
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
@ -6106,7 +6108,7 @@ inline void gcode_M503() {
#endif #endif
current_position[E_AXIS] = destination[E_AXIS]; //the long retract of L is compensated by manual filament feeding 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 RUNPLAN; //should do nothing