Skip to content

Commit

Permalink
Merge pull request #4204 from thinkyhead/rc_fix_gcode_t_position
Browse files Browse the repository at this point in the history
Additional patches for gcode_T position change
  • Loading branch information
thinkyhead authored Jul 4, 2016
2 parents 869b517 + c9e536c commit d70197f
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6501,6 +6501,13 @@ inline void gcode_T(uint8_t tmp_extruder) {
return;
}

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM(">>> gcode_T");
DEBUG_POS("BEFORE", current_position);
}
#endif

#if HOTENDS > 1

float old_feedrate = feedrate;
Expand Down Expand Up @@ -6583,11 +6590,6 @@ inline void gcode_T(uint8_t tmp_extruder) {
// Z software endstop. But this is technically correct (and
// there is no viable alternative).
//
float xydiff[2] = {
hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
};

#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// Offset extruder, make sure to apply the bed level rotation matrix
vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
Expand All @@ -6600,31 +6602,29 @@ inline void gcode_T(uint8_t tmp_extruder) {

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM(">>> gcode_T");
tmp_offset_vec.debug("tmp_offset_vec");
act_offset_vec.debug("act_offset_vec");
offset_vec.debug("offset_vec (BEFORE)");
DEBUG_POS("BEFORE rotation", current_position);
}
#endif

offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));

// Adjust the current position
current_position[X_AXIS] += offset_vec.x;
current_position[Y_AXIS] += offset_vec.y;
current_position[Z_AXIS] += offset_vec.z;

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
offset_vec.debug("offset_vec (AFTER)");
DEBUG_POS("AFTER rotation", current_position);
SERIAL_ECHOLNPGM("<<< gcode_T");
}
if (DEBUGGING(LEVELING)) offset_vec.debug("offset_vec (AFTER)");
#endif

// Adjustments to the current position
float xydiff[2] = { offset_vec.x, offset_vec.y };
current_position[Z_AXIS] += offset_vec.z;

#else // !AUTO_BED_LEVELING_FEATURE

float xydiff[2] = {
hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
};

#if ENABLED(MESH_BED_LEVELING)

if (mbl.active()) {
Expand All @@ -6635,12 +6635,11 @@ inline void gcode_T(uint8_t tmp_extruder) {

#endif // MESH_BED_LEVELING

// The newly-selected extruder XY is actually at...
current_position[X_AXIS] += xydiff[X_AXIS];
current_position[Y_AXIS] += xydiff[Y_AXIS];

#endif // !AUTO_BED_LEVELING_FEATURE

// The newly-selected extruder XY is actually at...
current_position[X_AXIS] += xydiff[X_AXIS];
current_position[Y_AXIS] += xydiff[Y_AXIS];
for (uint8_t i = X_AXIS; i <= Y_AXIS; i++) {
position_shift[i] += xydiff[i];
update_software_endstops((AxisEnum)i);
Expand Down Expand Up @@ -6674,6 +6673,13 @@ inline void gcode_T(uint8_t tmp_extruder) {

#endif

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
DEBUG_POS("AFTER", current_position);
SERIAL_ECHOLNPGM("<<< gcode_T");
}
#endif

SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
SERIAL_PROTOCOLLN((int)active_extruder);
Expand Down

0 comments on commit d70197f

Please sign in to comment.