Browse Source

Merge pull request #1753 from thinkyhead/fix_extruder_offset

Fix EXTRUDER_OFFSET compiler error
Scott Lahteine 9 years ago
parent
commit
6ff1620fcb
2 changed files with 33 additions and 33 deletions
  1. 6
    6
      Marlin/Configuration.h
  2. 27
    27
      Marlin/Marlin_main.cpp

+ 6
- 6
Marlin/Configuration.h View File

@@ -72,6 +72,12 @@ Here are some standard links for getting your machine calibrated:
72 72
 // This defines the number of extruders
73 73
 #define EXTRUDERS 1
74 74
 
75
+// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
76
+// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
77
+// For the other hotends it is their distance from the extruder 0 hotend.
78
+//#define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis
79
+//#define EXTRUDER_OFFSET_Y {0.0, 5.00}  // (in mm) for each extruder, offset of the hotend on the Y axis
80
+
75 81
 //// The following define selects which power supply you have. Please choose the one that matches your setup
76 82
 // 1 = ATX
77 83
 // 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC)
@@ -516,12 +522,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
516 522
 #define DEFAULT_RETRACT_ACCELERATION  3000   // E acceleration in mm/s^2 for retracts
517 523
 #define DEFAULT_TRAVEL_ACCELERATION   3000    // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves
518 524
 
519
-// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
520
-// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
521
-// For the other hotends it is their distance from the extruder 0 hotend.
522
-// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis
523
-// #define EXTRUDER_OFFSET_Y {0.0, 5.00}  // (in mm) for each extruder, offset of the hotend on the Y axis
524
-
525 525
 // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
526 526
 #define DEFAULT_XYJERK                20.0    // (mm/sec)
527 527
 #define DEFAULT_ZJERK                 0.4     // (mm/sec)

+ 27
- 27
Marlin/Marlin_main.cpp View File

@@ -226,21 +226,21 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
226 226
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
227 227
 bool axis_known_position[3] = { false };
228 228
 
229
-// Extruder offset
229
+// Extruder offsets
230 230
 #if EXTRUDERS > 1
231 231
   #ifndef EXTRUDER_OFFSET_X
232
-    #define EXTRUDER_OFFSET_X 0
232
+    #define EXTRUDER_OFFSET_X { 0 }
233 233
   #endif
234 234
   #ifndef EXTRUDER_OFFSET_Y
235
-    #define EXTRUDER_OFFSET_Y 0
235
+    #define EXTRUDER_OFFSET_Y { 0 }
236 236
   #endif
237
-  #ifndef DUAL_X_CARRIAGE
238
-    #define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
239
-  #else
240
-    #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
241
-  #endif
242
-  #define _EXY { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y }
243
-  float extruder_offset[EXTRUDERS][NUM_EXTRUDER_OFFSETS] = ARRAY_BY_EXTRUDERS(_EXY, _EXY, _EXY, _EXY);
237
+  float extruder_offset[][EXTRUDERS] = {
238
+    EXTRUDER_OFFSET_X,
239
+    EXTRUDER_OFFSET_Y
240
+    #ifdef DUAL_X_CARRIAGE
241
+      , { 0 } // supports offsets in XYZ plane
242
+    #endif
243
+  };
244 244
 #endif
245 245
 
246 246
 uint8_t active_extruder = 0;
@@ -935,7 +935,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir,  HOME_DIR);
935 935
       // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
936 936
       // This allow soft recalibration of the second extruder offset position without firmware reflash
937 937
       // (through the M218 command).
938
-      return (extruder_offset[1][X_AXIS] > 0) ? extruder_offset[1][X_AXIS] : X2_HOME_POS;
938
+      return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
939 939
   }
940 940
 
941 941
   static int x_home_dir(int extruder) {
@@ -959,14 +959,14 @@ static void axis_is_at_home(int axis) {
959 959
       if (active_extruder != 0) {
960 960
         current_position[X_AXIS] = x_home_pos(active_extruder);
961 961
                  min_pos[X_AXIS] = X2_MIN_POS;
962
-                 max_pos[X_AXIS] = max(extruder_offset[1][X_AXIS], X2_MAX_POS);
962
+                 max_pos[X_AXIS] = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
963 963
         return;
964 964
       }
965 965
       else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
966 966
         float xoff = home_offset[X_AXIS];
967 967
         current_position[X_AXIS] = base_home_pos(X_AXIS) + xoff;
968 968
                  min_pos[X_AXIS] = base_min_pos(X_AXIS) + xoff;
969
-                 max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + xoff, max(extruder_offset[1][X_AXIS], X2_MAX_POS) - duplicate_extruder_x_offset);
969
+                 max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + xoff, max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
970 970
         return;
971 971
       }
972 972
     }
@@ -3780,23 +3780,23 @@ inline void gcode_M206() {
3780 3780
   inline void gcode_M218() {
3781 3781
     if (setTargetedHotend(218)) return;
3782 3782
 
3783
-    if (code_seen('X')) extruder_offset[tmp_extruder][X_AXIS] = code_value();
3784
-    if (code_seen('Y')) extruder_offset[tmp_extruder][Y_AXIS] = code_value();
3783
+    if (code_seen('X')) extruder_offset[X_AXIS][tmp_extruder] = code_value();
3784
+    if (code_seen('Y')) extruder_offset[Y_AXIS][tmp_extruder] = code_value();
3785 3785
 
3786 3786
     #ifdef DUAL_X_CARRIAGE
3787
-      if (code_seen('Z')) extruder_offset[tmp_extruder][Z_AXIS] = code_value();
3787
+      if (code_seen('Z')) extruder_offset[Z_AXIS][tmp_extruder] = code_value();
3788 3788
     #endif
3789 3789
 
3790 3790
     SERIAL_ECHO_START;
3791 3791
     SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
3792 3792
     for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) {
3793 3793
       SERIAL_ECHO(" ");
3794
-      SERIAL_ECHO(extruder_offset[tmp_extruder][X_AXIS]);
3794
+      SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
3795 3795
       SERIAL_ECHO(",");
3796
-      SERIAL_ECHO(extruder_offset[tmp_extruder][Y_AXIS]);
3796
+      SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
3797 3797
       #ifdef DUAL_X_CARRIAGE
3798 3798
         SERIAL_ECHO(",");
3799
-        SERIAL_ECHO(extruder_offset[tmp_extruder][Z_AXIS]);
3799
+        SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
3800 3800
       #endif
3801 3801
     }
3802 3802
     SERIAL_EOL;
@@ -4487,13 +4487,13 @@ inline void gcode_M503() {
4487 4487
         SERIAL_ECHO_START;
4488 4488
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
4489 4489
         SERIAL_ECHO(" ");
4490
-        SERIAL_ECHO(extruder_offset[0][X_AXIS]);
4490
+        SERIAL_ECHO(extruder_offset[X_AXIS][0]);
4491 4491
         SERIAL_ECHO(",");
4492
-        SERIAL_ECHO(extruder_offset[0][Y_AXIS]);
4492
+        SERIAL_ECHO(extruder_offset[Y_AXIS][0]);
4493 4493
         SERIAL_ECHO(" ");
4494 4494
         SERIAL_ECHO(duplicate_extruder_x_offset);
4495 4495
         SERIAL_ECHO(",");
4496
-        SERIAL_ECHOLN(extruder_offset[1][Y_AXIS]);
4496
+        SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]);
4497 4497
         break;
4498 4498
       case DXC_FULL_CONTROL_MODE:
4499 4499
       case DXC_AUTO_PARK_MODE:
@@ -4628,11 +4628,11 @@ inline void gcode_T() {
4628 4628
 
4629 4629
           // apply Y & Z extruder offset (x offset is already used in determining home pos)
4630 4630
           current_position[Y_AXIS] = current_position[Y_AXIS] -
4631
-                       extruder_offset[active_extruder][Y_AXIS] +
4632
-                       extruder_offset[tmp_extruder][Y_AXIS];
4631
+                       extruder_offset[Y_AXIS][active_extruder] +
4632
+                       extruder_offset[Y_AXIS][tmp_extruder];
4633 4633
           current_position[Z_AXIS] = current_position[Z_AXIS] -
4634
-                       extruder_offset[active_extruder][Z_AXIS] +
4635
-                       extruder_offset[tmp_extruder][Z_AXIS];
4634
+                       extruder_offset[Z_AXIS][active_extruder] +
4635
+                       extruder_offset[Z_AXIS][tmp_extruder];
4636 4636
 
4637 4637
           active_extruder = tmp_extruder;
4638 4638
 
@@ -4662,7 +4662,7 @@ inline void gcode_T() {
4662 4662
         #else // !DUAL_X_CARRIAGE
4663 4663
           // Offset extruder (only by XY)
4664 4664
           for (int i=X_AXIS; i<=Y_AXIS; i++)
4665
-            current_position[i] += extruder_offset[tmp_extruder][i] - extruder_offset[active_extruder][i];
4665
+            current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
4666 4666
           // Set the new active extruder and position
4667 4667
           active_extruder = tmp_extruder;
4668 4668
         #endif // !DUAL_X_CARRIAGE

Loading…
Cancel
Save