Browse Source

ARRAY_BY_EXTRUDERS, shorthand to sync planner

- Add some documentation to planner and stepper headers
- Patch up RAMBO pins with undefs
- Add `sync_plan_position` inline to set current XYZE
- Swap indices in `extruder_offset` to fix initialization values
Scott Lahteine 9 years ago
parent
commit
afff968e88
5 changed files with 111 additions and 136 deletions
  1. 76
    129
      Marlin/Marlin_main.cpp
  2. 12
    0
      Marlin/pins_RAMBO.h
  3. 1
    1
      Marlin/planner.cpp
  4. 21
    5
      Marlin/planner.h
  5. 1
    1
      Marlin/stepper.cpp

+ 76
- 129
Marlin/Marlin_main.cpp View File

@@ -211,72 +211,37 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
211 211
 int feedmultiply = 100; //100->1 200->2
212 212
 int saved_feedmultiply;
213 213
 int extrudemultiply = 100; //100->1 200->2
214
-int extruder_multiply[EXTRUDERS] = { 100
215
-  #if EXTRUDERS > 1
216
-    , 100
217
-    #if EXTRUDERS > 2
218
-      , 100
219
-      #if EXTRUDERS > 3
220
-        , 100
221
-      #endif
222
-    #endif
223
-  #endif
224
-};
214
+int extruder_multiply[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100, 100, 100, 100);
225 215
 bool volumetric_enabled = false;
226
-float filament_size[EXTRUDERS] = { DEFAULT_NOMINAL_FILAMENT_DIA
227
-  #if EXTRUDERS > 1
228
-      , DEFAULT_NOMINAL_FILAMENT_DIA
229
-    #if EXTRUDERS > 2
230
-       , DEFAULT_NOMINAL_FILAMENT_DIA
231
-      #if EXTRUDERS > 3
232
-        , DEFAULT_NOMINAL_FILAMENT_DIA
233
-      #endif
234
-    #endif
235
-  #endif
236
-};
237
-float volumetric_multiplier[EXTRUDERS] = {1.0
238
-  #if EXTRUDERS > 1
239
-    , 1.0
240
-    #if EXTRUDERS > 2
241
-      , 1.0
242
-      #if EXTRUDERS > 3
243
-        , 1.0
244
-      #endif
245
-    #endif
246
-  #endif
247
-};
248
-float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
249
-float home_offset[3] = { 0, 0, 0 };
216
+float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA);
217
+float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0, 1.0, 1.0, 1.0);
218
+float current_position[NUM_AXIS] = { 0.0 };
219
+float home_offset[3] = { 0 };
250 220
 #ifdef DELTA
251
-  float endstop_adj[3] = { 0, 0, 0 };
221
+  float endstop_adj[3] = { 0 };
252 222
 #elif defined(Z_DUAL_ENDSTOPS)
253 223
   float z_endstop_adj = 0;
254 224
 #endif
255 225
 
256 226
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
257 227
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
258
-bool axis_known_position[3] = { false, false, false };
228
+bool axis_known_position[3] = { false };
259 229
 
260 230
 // Extruder offset
261 231
 #if EXTRUDERS > 1
262
-#ifndef DUAL_X_CARRIAGE
263
-  #define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
264
-#else
265
-  #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
266
-#endif
267
-float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
268
-  #if defined(EXTRUDER_OFFSET_X)
269
-    EXTRUDER_OFFSET_X
270
-  #else
271
-    0
232
+  #ifndef EXTRUDER_OFFSET_X
233
+    #define EXTRUDER_OFFSET_X 0
272 234
   #endif
273
-  ,
274
-  #if defined(EXTRUDER_OFFSET_Y)
275
-    EXTRUDER_OFFSET_Y
235
+  #ifndef EXTRUDER_OFFSET_Y
236
+    #define EXTRUDER_OFFSET_Y 0
237
+  #endif
238
+  #ifndef DUAL_X_CARRIAGE
239
+    #define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
276 240
   #else
277
-    0
241
+    #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
278 242
   #endif
279
-};
243
+  #define _EXY { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y }
244
+  float extruder_offset[EXTRUDERS][NUM_EXTRUDER_OFFSETS] = ARRAY_BY_EXTRUDERS(_EXY, _EXY, _EXY, _EXY);
280 245
 #endif
281 246
 
282 247
 uint8_t active_extruder = 0;
@@ -295,28 +260,8 @@ int fanSpeed = 0;
295 260
 #ifdef FWRETRACT
296 261
 
297 262
   bool autoretract_enabled = false;
298
-  bool retracted[EXTRUDERS] = { false
299
-    #if EXTRUDERS > 1
300
-      , false
301
-      #if EXTRUDERS > 2
302
-        , false
303
-        #if EXTRUDERS > 3
304
-          , false
305
-        #endif
306
-      #endif
307
-    #endif
308
-  };
309
-  bool retracted_swap[EXTRUDERS] = { false
310
-    #if EXTRUDERS > 1
311
-      , false
312
-      #if EXTRUDERS > 2
313
-        , false
314
-        #if EXTRUDERS > 3
315
-          , false
316
-        #endif
317
-      #endif
318
-    #endif
319
-  };
263
+  bool retracted[EXTRUDERS] = { false };
264
+  bool retracted_swap[EXTRUDERS] = { false };
320 265
 
321 266
   float retract_length = RETRACT_LENGTH;
322 267
   float retract_length_swap = RETRACT_LENGTH_SWAP;
@@ -385,9 +330,9 @@ const char errormagic[] PROGMEM = "Error:";
385 330
 const char echomagic[] PROGMEM = "echo:";
386 331
 
387 332
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
388
-static float destination[NUM_AXIS] = { 0, 0, 0, 0 };
333
+static float destination[NUM_AXIS] = { 0 };
389 334
 
390
-static float offset[3] = { 0, 0, 0 };
335
+static float offset[3] = { 0 };
391 336
 
392 337
 #ifndef DELTA
393 338
   static bool home_all_axis = true;
@@ -993,7 +938,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir,  HOME_DIR);
993 938
       // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
994 939
       // This allow soft recalibration of the second extruder offset position without firmware reflash
995 940
       // (through the M218 command).
996
-      return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
941
+      return (extruder_offset[1][X_AXIS] > 0) ? extruder_offset[1][X_AXIS] : X2_HOME_POS;
997 942
   }
998 943
 
999 944
   static int x_home_dir(int extruder) {
@@ -1017,14 +962,14 @@ static void axis_is_at_home(int axis) {
1017 962
       if (active_extruder != 0) {
1018 963
         current_position[X_AXIS] = x_home_pos(active_extruder);
1019 964
         min_pos[X_AXIS] = X2_MIN_POS;
1020
-        max_pos[X_AXIS] = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
965
+        max_pos[X_AXIS] = max(extruder_offset[1][X_AXIS], X2_MAX_POS);
1021 966
         return;
1022 967
       }
1023 968
       else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
1024 969
         current_position[X_AXIS] = base_home_pos(X_AXIS) + home_offset[X_AXIS];
1025 970
         min_pos[X_AXIS] = base_min_pos(X_AXIS) + home_offset[X_AXIS];
1026 971
         max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + home_offset[X_AXIS],
1027
-                                max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
972
+                                max(extruder_offset[1][X_AXIS], X2_MAX_POS) - duplicate_extruder_x_offset);
1028 973
         return;
1029 974
       }
1030 975
     }
@@ -1077,12 +1022,18 @@ static void axis_is_at_home(int axis) {
1077 1022
   #endif
1078 1023
 }
1079 1024
 
1025
+/**
1026
+ * Shorthand to tell the planner our current position (in mm).
1027
+ */
1028
+inline void sync_plan_position() {
1029
+  plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1030
+}
1031
+
1080 1032
 #ifdef ENABLE_AUTO_BED_LEVELING
1081 1033
 #ifdef AUTO_BED_LEVELING_GRID
1082 1034
 
1083 1035
 #ifndef DELTA
1084
-static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
1085
-{
1036
+  static void set_bed_level_equation_lsq(double *plane_equation_coefficients) {
1086 1037
     vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
1087 1038
     planeNormal.debug("planeNormal");
1088 1039
     plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
@@ -1093,13 +1044,13 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
1093 1044
     //uncorrected_position.debug("position before");
1094 1045
 
1095 1046
     vector_3 corrected_position = plan_get_position();
1096
-//    corrected_position.debug("position after");
1047
+    //corrected_position.debug("position after");
1097 1048
     current_position[X_AXIS] = corrected_position.x;
1098 1049
     current_position[Y_AXIS] = corrected_position.y;
1099
-    current_position[Z_AXIS] = corrected_position.z;
1050
+    current_position[Z_AXIS] = zprobe_zoffset; // was: corrected_position.z
1100 1051
 
1101
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1102
-}
1052
+    sync_plan_position();
1053
+  }
1103 1054
 #endif
1104 1055
 
1105 1056
 #else // not AUTO_BED_LEVELING_GRID
@@ -1124,9 +1075,9 @@ static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float
1124 1075
     vector_3 corrected_position = plan_get_position();
1125 1076
     current_position[X_AXIS] = corrected_position.x;
1126 1077
     current_position[Y_AXIS] = corrected_position.y;
1127
-    current_position[Z_AXIS] = corrected_position.z;
1078
+    current_position[Z_AXIS] = zprobe_zoffset; // was: corrected_position.z
1128 1079
 
1129
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1080
+    sync_plan_position();
1130 1081
 }
1131 1082
 
1132 1083
 #endif // AUTO_BED_LEVELING_GRID
@@ -1172,18 +1123,14 @@ static void run_z_probe() {
1172 1123
     endstops_hit_on_purpose();
1173 1124
 
1174 1125
     // move back down slowly to find bed
1175
-    
1176
-    if (homing_bump_divisor[Z_AXIS] >= 1)
1177
-    {
1178
-        feedrate = homing_feedrate[Z_AXIS]/homing_bump_divisor[Z_AXIS];
1126
+    if (homing_bump_divisor[Z_AXIS] >= 1) {
1127
+      feedrate = homing_feedrate[Z_AXIS]/homing_bump_divisor[Z_AXIS];
1179 1128
     } 
1180
-    else
1181
-    {
1182
-        feedrate = homing_feedrate[Z_AXIS]/10;
1183
-        SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less then 1");
1129
+    else {
1130
+      feedrate = homing_feedrate[Z_AXIS]/10;
1131
+      SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less then 1");
1184 1132
     }
1185 1133
 
1186
-    
1187 1134
     zPosition -= home_retract_mm(Z_AXIS) * 2;
1188 1135
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1189 1136
     st_synchronize();
@@ -1191,7 +1138,7 @@ static void run_z_probe() {
1191 1138
 
1192 1139
     current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
1193 1140
     // make sure the planner knows where we are as it may be a bit different than we last said to move to
1194
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1141
+    sync_plan_position();
1195 1142
     
1196 1143
   #endif
1197 1144
 }
@@ -1471,7 +1418,7 @@ static void homeaxis(int axis) {
1471 1418
 #endif
1472 1419
 
1473 1420
     current_position[axis] = 0;
1474
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1421
+    sync_plan_position();
1475 1422
 
1476 1423
 
1477 1424
 #ifndef Z_PROBE_SLED
@@ -1497,7 +1444,7 @@ static void homeaxis(int axis) {
1497 1444
     st_synchronize();
1498 1445
 
1499 1446
     current_position[axis] = 0;
1500
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1447
+    sync_plan_position();
1501 1448
     destination[axis] = -home_retract_mm(axis) * axis_home_dir;
1502 1449
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1503 1450
     st_synchronize();
@@ -1520,7 +1467,7 @@ static void homeaxis(int axis) {
1520 1467
       if (axis==Z_AXIS)
1521 1468
       {
1522 1469
         feedrate = homing_feedrate[axis];
1523
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1470
+        sync_plan_position();
1524 1471
         if (axis_home_dir > 0)
1525 1472
         {
1526 1473
           destination[axis] = (-1) * fabs(z_endstop_adj);
@@ -1540,7 +1487,7 @@ static void homeaxis(int axis) {
1540 1487
 #ifdef DELTA
1541 1488
     // retrace by the amount specified in endstop_adj
1542 1489
     if (endstop_adj[axis] * axis_home_dir < 0) {
1543
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1490
+      sync_plan_position();
1544 1491
       destination[axis] = endstop_adj[axis];
1545 1492
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1546 1493
       st_synchronize();
@@ -1596,7 +1543,7 @@ void refresh_cmd_timeout(void)
1596 1543
          calculate_delta(current_position); // change cartesian kinematic to  delta kinematic;
1597 1544
          plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
1598 1545
 #else
1599
-         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1546
+         sync_plan_position();
1600 1547
 #endif
1601 1548
          prepare_move();
1602 1549
       }
@@ -1612,7 +1559,7 @@ void refresh_cmd_timeout(void)
1612 1559
          calculate_delta(current_position); // change cartesian kinematic  to  delta kinematic;
1613 1560
          plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
1614 1561
 #else
1615
-         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1562
+         sync_plan_position();
1616 1563
 #endif
1617 1564
          //prepare_move();
1618 1565
       }
@@ -1789,7 +1736,7 @@ inline void gcode_G28() {
1789 1736
 
1790 1737
     // Move all carriages up together until the first endstop is hit.
1791 1738
     for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 0;
1792
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1739
+    sync_plan_position();
1793 1740
 
1794 1741
     for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * Z_MAX_LENGTH;
1795 1742
     feedrate = 1.732 * homing_feedrate[X_AXIS];
@@ -1829,7 +1776,7 @@ inline void gcode_G28() {
1829 1776
           extruder_duplication_enabled = false;
1830 1777
         #endif
1831 1778
 
1832
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1779
+        sync_plan_position();
1833 1780
         destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;
1834 1781
         destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
1835 1782
         feedrate = homing_feedrate[X_AXIS];
@@ -1844,7 +1791,7 @@ inline void gcode_G28() {
1844 1791
 
1845 1792
         axis_is_at_home(X_AXIS);
1846 1793
         axis_is_at_home(Y_AXIS);
1847
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1794
+        sync_plan_position();
1848 1795
         destination[X_AXIS] = current_position[X_AXIS];
1849 1796
         destination[Y_AXIS] = current_position[Y_AXIS];
1850 1797
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
@@ -1921,7 +1868,7 @@ inline void gcode_G28() {
1921 1868
           feedrate = XY_TRAVEL_SPEED / 60;
1922 1869
           current_position[Z_AXIS] = 0;
1923 1870
 
1924
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1871
+          sync_plan_position();
1925 1872
           plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1926 1873
           st_synchronize();
1927 1874
           current_position[X_AXIS] = destination[X_AXIS];
@@ -1973,7 +1920,7 @@ inline void gcode_G28() {
1973 1920
       if (home_all_axis || code_seen(axis_codes[Z_AXIS]))
1974 1921
         current_position[Z_AXIS] += zprobe_zoffset;  //Add Z_Probe offset (the distance is negative)
1975 1922
     #endif
1976
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1923
+    sync_plan_position();
1977 1924
 
1978 1925
   #endif // else DELTA
1979 1926
 
@@ -1998,7 +1945,7 @@ inline void gcode_G28() {
1998 1945
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1999 1946
       st_synchronize();
2000 1947
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2001
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1948
+      sync_plan_position();
2002 1949
       mbl.active = 1;
2003 1950
     }
2004 1951
   #endif
@@ -2069,7 +2016,7 @@ inline void gcode_G28() {
2069 2016
       int ix, iy;
2070 2017
       if (probe_point == 0) {
2071 2018
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2072
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2019
+        sync_plan_position();
2073 2020
       } else {
2074 2021
         ix = (probe_point-1) % MESH_NUM_X_POINTS;
2075 2022
         iy = (probe_point-1) / MESH_NUM_X_POINTS;
@@ -2242,7 +2189,7 @@ inline void gcode_G28() {
2242 2189
         current_position[X_AXIS] = uncorrected_position.x;
2243 2190
         current_position[Y_AXIS] = uncorrected_position.y;
2244 2191
         current_position[Z_AXIS] = uncorrected_position.z;
2245
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2192
+        sync_plan_position();
2246 2193
 
2247 2194
       #endif
2248 2195
     }
@@ -2443,7 +2390,7 @@ inline void gcode_G28() {
2443 2390
 
2444 2391
         apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2445 2392
         current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2446
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2393
+        sync_plan_position();
2447 2394
       }
2448 2395
     #endif // !DELTA
2449 2396
 
@@ -2504,7 +2451,7 @@ inline void gcode_G92() {
2504 2451
         didXYZ = true;
2505 2452
     }
2506 2453
   }
2507
-  if (didXYZ) plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2454
+  if (didXYZ) sync_plan_position();
2508 2455
 }
2509 2456
 
2510 2457
 #ifdef ULTIPANEL
@@ -3762,23 +3709,23 @@ inline void gcode_M206() {
3762 3709
   inline void gcode_M218() {
3763 3710
     if (setTargetedHotend(218)) return;
3764 3711
 
3765
-    if (code_seen('X')) extruder_offset[X_AXIS][tmp_extruder] = code_value();
3766
-    if (code_seen('Y')) extruder_offset[Y_AXIS][tmp_extruder] = code_value();
3712
+    if (code_seen('X')) extruder_offset[tmp_extruder][X_AXIS] = code_value();
3713
+    if (code_seen('Y')) extruder_offset[tmp_extruder][Y_AXIS] = code_value();
3767 3714
 
3768 3715
     #ifdef DUAL_X_CARRIAGE
3769
-      if (code_seen('Z')) extruder_offset[Z_AXIS][tmp_extruder] = code_value();
3716
+      if (code_seen('Z')) extruder_offset[tmp_extruder][Z_AXIS] = code_value();
3770 3717
     #endif
3771 3718
 
3772 3719
     SERIAL_ECHO_START;
3773 3720
     SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
3774 3721
     for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) {
3775 3722
       SERIAL_ECHO(" ");
3776
-      SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
3723
+      SERIAL_ECHO(extruder_offset[tmp_extruder][X_AXIS]);
3777 3724
       SERIAL_ECHO(",");
3778
-      SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
3725
+      SERIAL_ECHO(extruder_offset[tmp_extruder][Y_AXIS]);
3779 3726
       #ifdef DUAL_X_CARRIAGE
3780 3727
         SERIAL_ECHO(",");
3781
-        SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
3728
+        SERIAL_ECHO(extruder_offset[tmp_extruder][Z_AXIS]);
3782 3729
       #endif
3783 3730
     }
3784 3731
     SERIAL_EOL;
@@ -4469,13 +4416,13 @@ inline void gcode_M503() {
4469 4416
         SERIAL_ECHO_START;
4470 4417
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
4471 4418
         SERIAL_ECHO(" ");
4472
-        SERIAL_ECHO(extruder_offset[X_AXIS][0]);
4419
+        SERIAL_ECHO(extruder_offset[0][X_AXIS]);
4473 4420
         SERIAL_ECHO(",");
4474
-        SERIAL_ECHO(extruder_offset[Y_AXIS][0]);
4421
+        SERIAL_ECHO(extruder_offset[0][Y_AXIS]);
4475 4422
         SERIAL_ECHO(" ");
4476 4423
         SERIAL_ECHO(duplicate_extruder_x_offset);
4477 4424
         SERIAL_ECHO(",");
4478
-        SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]);
4425
+        SERIAL_ECHOLN(extruder_offset[1][Y_AXIS]);
4479 4426
         break;
4480 4427
       case DXC_FULL_CONTROL_MODE:
4481 4428
       case DXC_AUTO_PARK_MODE:
@@ -4610,11 +4557,11 @@ inline void gcode_T() {
4610 4557
 
4611 4558
           // apply Y & Z extruder offset (x offset is already used in determining home pos)
4612 4559
           current_position[Y_AXIS] = current_position[Y_AXIS] -
4613
-                       extruder_offset[Y_AXIS][active_extruder] +
4614
-                       extruder_offset[Y_AXIS][tmp_extruder];
4560
+                       extruder_offset[active_extruder][Y_AXIS] +
4561
+                       extruder_offset[tmp_extruder][Y_AXIS];
4615 4562
           current_position[Z_AXIS] = current_position[Z_AXIS] -
4616
-                       extruder_offset[Z_AXIS][active_extruder] +
4617
-                       extruder_offset[Z_AXIS][tmp_extruder];
4563
+                       extruder_offset[active_extruder][Z_AXIS] +
4564
+                       extruder_offset[tmp_extruder][Z_AXIS];
4618 4565
 
4619 4566
           active_extruder = tmp_extruder;
4620 4567
 
@@ -4644,7 +4591,7 @@ inline void gcode_T() {
4644 4591
         #else // !DUAL_X_CARRIAGE
4645 4592
           // Offset extruder (only by XY)
4646 4593
           for (int i=X_AXIS; i<=Y_AXIS; i++)
4647
-            current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
4594
+            current_position[i] += extruder_offset[tmp_extruder][i] - extruder_offset[active_extruder][i];
4648 4595
           // Set the new active extruder and position
4649 4596
           active_extruder = tmp_extruder;
4650 4597
         #endif // !DUAL_X_CARRIAGE
@@ -4653,7 +4600,7 @@ inline void gcode_T() {
4653 4600
           //sent position to plan_set_position();
4654 4601
           plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]);
4655 4602
         #else
4656
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
4603
+          sync_plan_position();
4657 4604
         #endif
4658 4605
         // Move to the old position if 'F' was in the parameters
4659 4606
         if (make_move && !Stopped) prepare_move();
@@ -5494,7 +5441,7 @@ for (int s = 1; s <= steps; s++) {
5494 5441
       plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5495 5442
       plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
5496 5443
           current_position[E_AXIS], max_feedrate[X_AXIS], 1);
5497
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5444
+      sync_plan_position();
5498 5445
       st_synchronize();
5499 5446
       extruder_duplication_enabled = true;
5500 5447
       active_extruder_parked = false;

+ 12
- 0
Marlin/pins_RAMBO.h View File

@@ -22,6 +22,17 @@
22 22
   #endif
23 23
 #endif
24 24
 
25
+#undef X_MS1_PIN
26
+#undef X_MS2_PIN
27
+#undef Y_MS1_PIN
28
+#undef Y_MS2_PIN
29
+#undef Z_MS1_PIN
30
+#undef Z_MS2_PIN
31
+#undef E0_MS1_PIN
32
+#undef E0_MS2_PIN
33
+#undef E1_MS1_PIN
34
+#undef E1_MS2_PIN
35
+ 
25 36
 #define X_STEP_PIN 37
26 37
 #define X_DIR_PIN 48
27 38
 #define X_MIN_PIN 12
@@ -75,6 +86,7 @@
75 86
 #define E1_MS1_PIN 63
76 87
 #define E1_MS2_PIN 64
77 88
 
89
+#undef DIGIPOTSS_PIN
78 90
 #define DIGIPOTSS_PIN 38
79 91
 #define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
80 92
 

+ 1
- 1
Marlin/planner.cpp View File

@@ -342,7 +342,7 @@ void planner_recalculate_trapezoids() {
342 342
 //     b. No speed reduction within one block requires faster deceleration than the one, true constant 
343 343
 //        acceleration.
344 344
 //   2. Go over every block in chronological order and dial down junction speed reduction values if 
345
-//     a. The speed increase within one block would require faster accelleration than the one, true 
345
+//     a. The speed increase within one block would require faster acceleration than the one, true 
346 346
 //        constant acceleration.
347 347
 //
348 348
 // When these stages are complete all blocks have an entry_factor that will allow all speed changes to 

+ 21
- 5
Marlin/planner.h View File

@@ -80,21 +80,37 @@ extern volatile unsigned char block_buffer_tail;
80 80
 FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
81 81
 
82 82
 #if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
83
+
83 84
   #if defined(ENABLE_AUTO_BED_LEVELING)
84 85
     #include "vector_3.h"
85
-    // this holds the required transform to compensate for bed level
86
+
87
+    // Transform required to compensate for bed level
86 88
     extern matrix_3x3 plan_bed_level_matrix;
87
-    // Get the position applying the bed level matrix if enabled
89
+
90
+    /**
91
+     * Get the position applying the bed level matrix
92
+     */
88 93
     vector_3 plan_get_position();
89 94
   #endif  // ENABLE_AUTO_BED_LEVELING
90
-  // Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in 
91
-  // millimeters. Feed rate specifies the speed of the motion.
95
+
96
+  /**
97
+   * Add a new linear movement to the buffer. x, y, z are the signed, absolute target position in
98
+   * millimeters. Feed rate specifies the (target) speed of the motion.
99
+   */
92 100
   void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder);
93
-  // Set position. Used for G92 instructions.
101
+
102
+  /**
103
+   * Set the planner positions. Used for G92 instructions.
104
+   * Multiplies by axis_steps_per_unit[] to set stepper positions.
105
+   * Clears previous speed values.
106
+   */
94 107
   void plan_set_position(float x, float y, float z, const float &e);
108
+
95 109
 #else
110
+
96 111
   void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
97 112
   void plan_set_position(const float &x, const float &y, const float &z, const float &e);
113
+
98 114
 #endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
99 115
 
100 116
 void plan_set_e_position(const float &e);

+ 1
- 1
Marlin/stepper.cpp View File

@@ -1205,7 +1205,7 @@ void microstep_init() {
1205 1205
     pinMode(E0_MS1_PIN,OUTPUT);
1206 1206
     pinMode(E0_MS2_PIN,OUTPUT);
1207 1207
     const uint8_t microstep_modes[] = MICROSTEP_MODES;
1208
-    for (int i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
1208
+    for (uint16_t i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
1209 1209
       microstep_mode(i, microstep_modes[i]);
1210 1210
   #endif
1211 1211
 }

Loading…
Cancel
Save