Browse Source

Merge pull request #2978 from thinkyhead/tool_offset_abl_rcbugfix

Apply bed leveling matrix when switching extruders
Scott Lahteine 8 years ago
parent
commit
14f3ca1b2e
1 changed files with 18 additions and 3 deletions
  1. 18
    3
      Marlin/Marlin_main.cpp

+ 18
- 3
Marlin/Marlin_main.cpp View File

@@ -5651,9 +5651,24 @@ inline void gcode_T(uint8_t tmp_extruder) {
5651 5651
             delayed_move_time = 0;
5652 5652
           }
5653 5653
         #else // !DUAL_X_CARRIAGE
5654
-          // Offset extruder (only by XY)
5655
-          for (int i = X_AXIS; i <= Y_AXIS; i++)
5656
-            current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
5654
+          #if ENABLED(AUTO_BED_LEVELING_FEATURE)
5655
+            // Offset extruder, make sure to apply the bed level rotation matrix
5656
+            vector_3 tmp_offset_vec = vector_3(extruder_offset[X_AXIS][tmp_extruder],
5657
+                                               extruder_offset[Y_AXIS][tmp_extruder],
5658
+                                               extruder_offset[Z_AXIS][tmp_extruder]),
5659
+                     act_offset_vec = vector_3(extruder_offset[X_AXIS][active_extruder],
5660
+                                               extruder_offset[Y_AXIS][active_extruder],
5661
+                                               extruder_offset[Z_AXIS][active_extruder]),
5662
+                     offset_vec = tmp_offset_vec - act_offset_vec;
5663
+            offset_vec.apply_rotation(plan_bed_level_matrix.transpose(plan_bed_level_matrix));
5664
+            current_position[X_AXIS] += offset_vec.x;
5665
+            current_position[Y_AXIS] += offset_vec.y;
5666
+            current_position[Z_AXIS] += offset_vec.z;
5667
+          #else // !AUTO_BED_LEVELING_FEATURE
5668
+            // Offset extruder (only by XY)
5669
+            for (int i=X_AXIS; i<=Y_AXIS; i++)
5670
+              current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
5671
+          #endif // !AUTO_BED_LEVELING_FEATURE
5657 5672
           // Set the new active extruder and position
5658 5673
           active_extruder = tmp_extruder;
5659 5674
         #endif // !DUAL_X_CARRIAGE

Loading…
Cancel
Save