|
@@ -226,7 +226,7 @@ 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
|
232
|
#define EXTRUDER_OFFSET_X { 0 }
|
|
@@ -234,12 +234,13 @@ bool axis_known_position[3] = { false };
|
234
|
234
|
#ifndef EXTRUDER_OFFSET_Y
|
235
|
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
|
|
- float extruder_offset[EXTRUDERS][NUM_EXTRUDER_OFFSETS];
|
|
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
|
+ };
|
243
|
244
|
#endif
|
244
|
245
|
|
245
|
246
|
uint8_t active_extruder = 0;
|
|
@@ -568,13 +569,6 @@ void servo_init()
|
568
|
569
|
|
569
|
570
|
void setup()
|
570
|
571
|
{
|
571
|
|
- #if EXTRUDERS > 1
|
572
|
|
- float offset[3][EXTRUDERS] = { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y, ARRAY_BY_EXTRUDERS(0,0,0,0) };
|
573
|
|
- for (int e=0; e<EXTRUDERS; e++)
|
574
|
|
- for (int i=0; i<NUM_EXTRUDER_OFFSETS; i++)
|
575
|
|
- extruder_offset[e][i] = offset[i][e];
|
576
|
|
- #endif
|
577
|
|
-
|
578
|
572
|
setup_killpin();
|
579
|
573
|
setup_filrunoutpin();
|
580
|
574
|
setup_powerhold();
|
|
@@ -941,7 +935,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
941
|
935
|
// second X-carriage offset when homed - otherwise X2_HOME_POS is used.
|
942
|
936
|
// This allow soft recalibration of the second extruder offset position without firmware reflash
|
943
|
937
|
// (through the M218 command).
|
944
|
|
- 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;
|
945
|
939
|
}
|
946
|
940
|
|
947
|
941
|
static int x_home_dir(int extruder) {
|
|
@@ -965,14 +959,14 @@ static void axis_is_at_home(int axis) {
|
965
|
959
|
if (active_extruder != 0) {
|
966
|
960
|
current_position[X_AXIS] = x_home_pos(active_extruder);
|
967
|
961
|
min_pos[X_AXIS] = X2_MIN_POS;
|
968
|
|
- 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);
|
969
|
963
|
return;
|
970
|
964
|
}
|
971
|
965
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
|
972
|
966
|
float xoff = home_offset[X_AXIS];
|
973
|
967
|
current_position[X_AXIS] = base_home_pos(X_AXIS) + xoff;
|
974
|
968
|
min_pos[X_AXIS] = base_min_pos(X_AXIS) + xoff;
|
975
|
|
- 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);
|
976
|
970
|
return;
|
977
|
971
|
}
|
978
|
972
|
}
|
|
@@ -3786,23 +3780,23 @@ inline void gcode_M206() {
|
3786
|
3780
|
inline void gcode_M218() {
|
3787
|
3781
|
if (setTargetedHotend(218)) return;
|
3788
|
3782
|
|
3789
|
|
- if (code_seen('X')) extruder_offset[tmp_extruder][X_AXIS] = code_value();
|
3790
|
|
- 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();
|
3791
|
3785
|
|
3792
|
3786
|
#ifdef DUAL_X_CARRIAGE
|
3793
|
|
- 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();
|
3794
|
3788
|
#endif
|
3795
|
3789
|
|
3796
|
3790
|
SERIAL_ECHO_START;
|
3797
|
3791
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
3798
|
3792
|
for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) {
|
3799
|
3793
|
SERIAL_ECHO(" ");
|
3800
|
|
- SERIAL_ECHO(extruder_offset[tmp_extruder][X_AXIS]);
|
|
3794
|
+ SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
|
3801
|
3795
|
SERIAL_ECHO(",");
|
3802
|
|
- SERIAL_ECHO(extruder_offset[tmp_extruder][Y_AXIS]);
|
|
3796
|
+ SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
|
3803
|
3797
|
#ifdef DUAL_X_CARRIAGE
|
3804
|
3798
|
SERIAL_ECHO(",");
|
3805
|
|
- SERIAL_ECHO(extruder_offset[tmp_extruder][Z_AXIS]);
|
|
3799
|
+ SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
|
3806
|
3800
|
#endif
|
3807
|
3801
|
}
|
3808
|
3802
|
SERIAL_EOL;
|
|
@@ -4493,13 +4487,13 @@ inline void gcode_M503() {
|
4493
|
4487
|
SERIAL_ECHO_START;
|
4494
|
4488
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
4495
|
4489
|
SERIAL_ECHO(" ");
|
4496
|
|
- SERIAL_ECHO(extruder_offset[0][X_AXIS]);
|
|
4490
|
+ SERIAL_ECHO(extruder_offset[X_AXIS][0]);
|
4497
|
4491
|
SERIAL_ECHO(",");
|
4498
|
|
- SERIAL_ECHO(extruder_offset[0][Y_AXIS]);
|
|
4492
|
+ SERIAL_ECHO(extruder_offset[Y_AXIS][0]);
|
4499
|
4493
|
SERIAL_ECHO(" ");
|
4500
|
4494
|
SERIAL_ECHO(duplicate_extruder_x_offset);
|
4501
|
4495
|
SERIAL_ECHO(",");
|
4502
|
|
- SERIAL_ECHOLN(extruder_offset[1][Y_AXIS]);
|
|
4496
|
+ SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]);
|
4503
|
4497
|
break;
|
4504
|
4498
|
case DXC_FULL_CONTROL_MODE:
|
4505
|
4499
|
case DXC_AUTO_PARK_MODE:
|
|
@@ -4634,11 +4628,11 @@ inline void gcode_T() {
|
4634
|
4628
|
|
4635
|
4629
|
// apply Y & Z extruder offset (x offset is already used in determining home pos)
|
4636
|
4630
|
current_position[Y_AXIS] = current_position[Y_AXIS] -
|
4637
|
|
- extruder_offset[active_extruder][Y_AXIS] +
|
4638
|
|
- extruder_offset[tmp_extruder][Y_AXIS];
|
|
4631
|
+ extruder_offset[Y_AXIS][active_extruder] +
|
|
4632
|
+ extruder_offset[Y_AXIS][tmp_extruder];
|
4639
|
4633
|
current_position[Z_AXIS] = current_position[Z_AXIS] -
|
4640
|
|
- extruder_offset[active_extruder][Z_AXIS] +
|
4641
|
|
- extruder_offset[tmp_extruder][Z_AXIS];
|
|
4634
|
+ extruder_offset[Z_AXIS][active_extruder] +
|
|
4635
|
+ extruder_offset[Z_AXIS][tmp_extruder];
|
4642
|
4636
|
|
4643
|
4637
|
active_extruder = tmp_extruder;
|
4644
|
4638
|
|
|
@@ -4668,7 +4662,7 @@ inline void gcode_T() {
|
4668
|
4662
|
#else // !DUAL_X_CARRIAGE
|
4669
|
4663
|
// Offset extruder (only by XY)
|
4670
|
4664
|
for (int i=X_AXIS; i<=Y_AXIS; i++)
|
4671
|
|
- 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];
|
4672
|
4666
|
// Set the new active extruder and position
|
4673
|
4667
|
active_extruder = tmp_extruder;
|
4674
|
4668
|
#endif // !DUAL_X_CARRIAGE
|