Browse Source

Merge pull request #4204 from thinkyhead/rc_fix_gcode_t_position

Additional patches for gcode_T position change
Scott Lahteine 9 years ago
parent
commit
d70197f514
1 changed files with 27 additions and 21 deletions
  1. 27
    21
      Marlin/Marlin_main.cpp

+ 27
- 21
Marlin/Marlin_main.cpp View File

6501
     return;
6501
     return;
6502
   }
6502
   }
6503
 
6503
 
6504
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
6505
+    if (DEBUGGING(LEVELING)) {
6506
+      SERIAL_ECHOLNPGM(">>> gcode_T");
6507
+      DEBUG_POS("BEFORE", current_position);
6508
+    }
6509
+  #endif
6510
+
6504
   #if HOTENDS > 1
6511
   #if HOTENDS > 1
6505
 
6512
 
6506
     float old_feedrate = feedrate;
6513
     float old_feedrate = feedrate;
6583
         // Z software endstop. But this is technically correct (and
6590
         // Z software endstop. But this is technically correct (and
6584
         // there is no viable alternative).
6591
         // there is no viable alternative).
6585
         //
6592
         //
6586
-        float xydiff[2] = {
6587
-          hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
6588
-          hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
6589
-        };
6590
-
6591
         #if ENABLED(AUTO_BED_LEVELING_FEATURE)
6593
         #if ENABLED(AUTO_BED_LEVELING_FEATURE)
6592
           // Offset extruder, make sure to apply the bed level rotation matrix
6594
           // Offset extruder, make sure to apply the bed level rotation matrix
6593
           vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
6595
           vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
6600
 
6602
 
6601
           #if ENABLED(DEBUG_LEVELING_FEATURE)
6603
           #if ENABLED(DEBUG_LEVELING_FEATURE)
6602
             if (DEBUGGING(LEVELING)) {
6604
             if (DEBUGGING(LEVELING)) {
6603
-              SERIAL_ECHOLNPGM(">>> gcode_T");
6604
               tmp_offset_vec.debug("tmp_offset_vec");
6605
               tmp_offset_vec.debug("tmp_offset_vec");
6605
               act_offset_vec.debug("act_offset_vec");
6606
               act_offset_vec.debug("act_offset_vec");
6606
               offset_vec.debug("offset_vec (BEFORE)");
6607
               offset_vec.debug("offset_vec (BEFORE)");
6607
-              DEBUG_POS("BEFORE rotation", current_position);
6608
             }
6608
             }
6609
           #endif
6609
           #endif
6610
 
6610
 
6611
           offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));
6611
           offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));
6612
 
6612
 
6613
-          // Adjust the current position
6614
-          current_position[X_AXIS] += offset_vec.x;
6615
-          current_position[Y_AXIS] += offset_vec.y;
6616
-          current_position[Z_AXIS] += offset_vec.z;
6617
-
6618
           #if ENABLED(DEBUG_LEVELING_FEATURE)
6613
           #if ENABLED(DEBUG_LEVELING_FEATURE)
6619
-            if (DEBUGGING(LEVELING)) {
6620
-              offset_vec.debug("offset_vec (AFTER)");
6621
-              DEBUG_POS("AFTER rotation", current_position);
6622
-              SERIAL_ECHOLNPGM("<<< gcode_T");
6623
-            }
6614
+            if (DEBUGGING(LEVELING)) offset_vec.debug("offset_vec (AFTER)");
6624
           #endif
6615
           #endif
6625
 
6616
 
6617
+          // Adjustments to the current position
6618
+          float xydiff[2] = { offset_vec.x, offset_vec.y };
6619
+          current_position[Z_AXIS] += offset_vec.z;
6620
+
6626
         #else // !AUTO_BED_LEVELING_FEATURE
6621
         #else // !AUTO_BED_LEVELING_FEATURE
6627
 
6622
 
6623
+          float xydiff[2] = {
6624
+            hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
6625
+            hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
6626
+          };
6627
+
6628
           #if ENABLED(MESH_BED_LEVELING)
6628
           #if ENABLED(MESH_BED_LEVELING)
6629
 
6629
 
6630
             if (mbl.active()) {
6630
             if (mbl.active()) {
6635
 
6635
 
6636
           #endif // MESH_BED_LEVELING
6636
           #endif // MESH_BED_LEVELING
6637
 
6637
 
6638
-          // The newly-selected extruder XY is actually at...
6639
-          current_position[X_AXIS] += xydiff[X_AXIS];
6640
-          current_position[Y_AXIS] += xydiff[Y_AXIS];
6641
-
6642
         #endif // !AUTO_BED_LEVELING_FEATURE
6638
         #endif // !AUTO_BED_LEVELING_FEATURE
6643
 
6639
 
6640
+        // The newly-selected extruder XY is actually at...
6641
+        current_position[X_AXIS] += xydiff[X_AXIS];
6642
+        current_position[Y_AXIS] += xydiff[Y_AXIS];
6644
         for (uint8_t i = X_AXIS; i <= Y_AXIS; i++) {
6643
         for (uint8_t i = X_AXIS; i <= Y_AXIS; i++) {
6645
           position_shift[i] += xydiff[i];
6644
           position_shift[i] += xydiff[i];
6646
           update_software_endstops((AxisEnum)i);
6645
           update_software_endstops((AxisEnum)i);
6674
 
6673
 
6675
   #endif
6674
   #endif
6676
 
6675
 
6676
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
6677
+    if (DEBUGGING(LEVELING)) {
6678
+      DEBUG_POS("AFTER", current_position);
6679
+      SERIAL_ECHOLNPGM("<<< gcode_T");
6680
+    }
6681
+  #endif
6682
+
6677
   SERIAL_ECHO_START;
6683
   SERIAL_ECHO_START;
6678
   SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
6684
   SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
6679
   SERIAL_PROTOCOLLN((int)active_extruder);
6685
   SERIAL_PROTOCOLLN((int)active_extruder);

Loading…
Cancel
Save