|
@@ -677,7 +677,44 @@ XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH);
|
677
|
677
|
XYZ_CONSTS_FROM_CONFIG(float, home_retract_mm, HOME_RETRACT_MM);
|
678
|
678
|
XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
679
|
679
|
|
|
680
|
+#ifdef DUAL_X_CARRIAGE
|
|
681
|
+ #if EXTRUDERS == 1 || defined(COREXY) \
|
|
682
|
+ || !defined(X2_ENABLE_PIN) || !defined(X2_STEP_PIN) || !defined(X2_DIR_PIN) \
|
|
683
|
+ || !defined(X2_HOME_POS) || !defined(X2_MIN_POS) || !defined(X2_MAX_POS) \
|
|
684
|
+ || !defined(X_MAX_PIN) || X_MAX_PIN < 0
|
|
685
|
+ #error "Missing or invalid definitions for DUAL_X_CARRIAGE mode."
|
|
686
|
+ #endif
|
|
687
|
+ #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
|
|
688
|
+ #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
|
|
689
|
+ #endif
|
|
690
|
+
|
|
691
|
+static float x_home_pos(int extruder) {
|
|
692
|
+ if (extruder == 0)
|
|
693
|
+ return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
694
|
+ else
|
|
695
|
+ // In dual carriage mode the extruder offset provides an override of the
|
|
696
|
+ // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
|
|
697
|
+ // This allow soft recalibration of the second extruder offset position without firmware reflash
|
|
698
|
+ // (through the M218 command).
|
|
699
|
+ return (extruder_offset[X_AXIS][1] != 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
|
|
700
|
+}
|
|
701
|
+
|
|
702
|
+static int x_home_dir(int extruder) {
|
|
703
|
+ return (extruder == 0) ? X_HOME_DIR : X2_HOME_DIR;
|
|
704
|
+}
|
|
705
|
+
|
|
706
|
+static float inactive_x_carriage_pos = X2_MAX_POS;
|
|
707
|
+#endif
|
|
708
|
+
|
680
|
709
|
static void axis_is_at_home(int axis) {
|
|
710
|
+#ifdef DUAL_X_CARRIAGE
|
|
711
|
+ if (axis == X_AXIS && active_extruder != 0) {
|
|
712
|
+ current_position[X_AXIS] = x_home_pos(active_extruder);
|
|
713
|
+ min_pos[X_AXIS] = X2_MIN_POS;
|
|
714
|
+ max_pos[X_AXIS] = X2_MAX_POS;
|
|
715
|
+ return;
|
|
716
|
+ }
|
|
717
|
+#endif
|
681
|
718
|
current_position[axis] = base_home_pos(axis) + add_homeing[axis];
|
682
|
719
|
min_pos[axis] = base_min_pos(axis) + add_homeing[axis];
|
683
|
720
|
max_pos[axis] = base_max_pos(axis) + add_homeing[axis];
|
|
@@ -686,10 +723,16 @@ static void axis_is_at_home(int axis) {
|
686
|
723
|
static void homeaxis(int axis) {
|
687
|
724
|
#define HOMEAXIS_DO(LETTER) \
|
688
|
725
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
|
726
|
+
|
689
|
727
|
if (axis==X_AXIS ? HOMEAXIS_DO(X) :
|
690
|
728
|
axis==Y_AXIS ? HOMEAXIS_DO(Y) :
|
691
|
729
|
axis==Z_AXIS ? HOMEAXIS_DO(Z) :
|
692
|
730
|
0) {
|
|
731
|
+ int axis_home_dir = home_dir(axis);
|
|
732
|
+#ifdef DUAL_X_CARRIAGE
|
|
733
|
+ if (axis == X_AXIS)
|
|
734
|
+ axis_home_dir = x_home_dir(active_extruder);
|
|
735
|
+#endif
|
693
|
736
|
|
694
|
737
|
// Engage Servo endstop if enabled
|
695
|
738
|
#ifdef SERVO_ENDSTOPS
|
|
@@ -700,18 +743,18 @@ static void homeaxis(int axis) {
|
700
|
743
|
|
701
|
744
|
current_position[axis] = 0;
|
702
|
745
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
703
|
|
- destination[axis] = 1.5 * max_length(axis) * home_dir(axis);
|
|
746
|
+ destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
704
|
747
|
feedrate = homing_feedrate[axis];
|
705
|
748
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
706
|
749
|
st_synchronize();
|
707
|
750
|
|
708
|
751
|
current_position[axis] = 0;
|
709
|
752
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
710
|
|
- destination[axis] = -home_retract_mm(axis) * home_dir(axis);
|
|
753
|
+ destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
711
|
754
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
712
|
755
|
st_synchronize();
|
713
|
756
|
|
714
|
|
- destination[axis] = 2*home_retract_mm(axis) * home_dir(axis);
|
|
757
|
+ destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
715
|
758
|
feedrate = homing_feedrate[axis]/2 ;
|
716
|
759
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
717
|
760
|
st_synchronize();
|
|
@@ -851,7 +894,7 @@ void process_commands()
|
851
|
894
|
|
852
|
895
|
#else // NOT DELTA
|
853
|
896
|
|
854
|
|
- home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
|
897
|
+ home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
855
|
898
|
|
856
|
899
|
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
857
|
900
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -864,8 +907,14 @@ void process_commands()
|
864
|
907
|
{
|
865
|
908
|
current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;
|
866
|
909
|
|
|
910
|
+ #ifdef DUAL_X_CARRIAGE
|
|
911
|
+ int x_axis_home_dir = home_dir(X_AXIS);
|
|
912
|
+ #else
|
|
913
|
+ int x_axis_home_dir = x_home_dir(active_extruder);
|
|
914
|
+ #endif
|
|
915
|
+
|
867
|
916
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
868
|
|
- destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
|
|
917
|
+ destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
|
869
|
918
|
feedrate = homing_feedrate[X_AXIS];
|
870
|
919
|
if(homing_feedrate[Y_AXIS]<feedrate)
|
871
|
920
|
feedrate =homing_feedrate[Y_AXIS];
|
|
@@ -890,6 +939,13 @@ void process_commands()
|
890
|
939
|
|
891
|
940
|
if((home_all_axis) || (code_seen(axis_codes[X_AXIS])))
|
892
|
941
|
{
|
|
942
|
+ #ifdef DUAL_X_CARRIAGE
|
|
943
|
+ int tmp_extruder = active_extruder;
|
|
944
|
+ active_extruder = !active_extruder;
|
|
945
|
+ HOMEAXIS(X);
|
|
946
|
+ inactive_x_carriage_pos = current_position[X_AXIS];
|
|
947
|
+ active_extruder = tmp_extruder;
|
|
948
|
+ #endif
|
893
|
949
|
HOMEAXIS(X);
|
894
|
950
|
}
|
895
|
951
|
|
|
@@ -922,7 +978,7 @@ void process_commands()
|
922
|
978
|
}
|
923
|
979
|
}
|
924
|
980
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
925
|
|
-#endif // DELTA
|
|
981
|
+#endif // else DELTA
|
926
|
982
|
|
927
|
983
|
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
928
|
984
|
enable_endstops(false);
|
|
@@ -2001,6 +2057,20 @@ void process_commands()
|
2001
|
2057
|
if(tmp_extruder != active_extruder) {
|
2002
|
2058
|
// Save current position to return to after applying extruder offset
|
2003
|
2059
|
memcpy(destination, current_position, sizeof(destination));
|
|
2060
|
+ #ifdef DUAL_X_CARRIAGE
|
|
2061
|
+ // only apply Y extruder offset in dual x carriage mode (x offset is already used in determining home pos)
|
|
2062
|
+ current_position[Y_AXIS] = current_position[Y_AXIS] -
|
|
2063
|
+ extruder_offset[Y_AXIS][active_extruder] +
|
|
2064
|
+ extruder_offset[Y_AXIS][tmp_extruder];
|
|
2065
|
+
|
|
2066
|
+ float tmp_x_pos = current_position[X_AXIS];
|
|
2067
|
+
|
|
2068
|
+ // Set the new active extruder and position
|
|
2069
|
+ active_extruder = tmp_extruder;
|
|
2070
|
+ axis_is_at_home(X_AXIS); //this function updates X min/max values.
|
|
2071
|
+ current_position[X_AXIS] = inactive_x_carriage_pos;
|
|
2072
|
+ inactive_x_carriage_pos = tmp_x_pos;
|
|
2073
|
+ #else
|
2004
|
2074
|
// Offset extruder (only by XY)
|
2005
|
2075
|
int i;
|
2006
|
2076
|
for(i = 0; i < 2; i++) {
|
|
@@ -2010,6 +2080,7 @@ void process_commands()
|
2010
|
2080
|
}
|
2011
|
2081
|
// Set the new active extruder and position
|
2012
|
2082
|
active_extruder = tmp_extruder;
|
|
2083
|
+ #endif //else DUAL_X_CARRIAGE
|
2013
|
2084
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2014
|
2085
|
// Move to the old position if 'F' was in the parameters
|
2015
|
2086
|
if(make_move && Stopped == false) {
|
|
@@ -2254,6 +2325,9 @@ void controllerFan()
|
2254
|
2325
|
|| !READ(E2_ENABLE_PIN)
|
2255
|
2326
|
#endif
|
2256
|
2327
|
#if EXTRUDER > 1
|
|
2328
|
+ #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
|
2329
|
+ || !READ(X2_ENABLE_PIN)
|
|
2330
|
+ #endif
|
2257
|
2331
|
|| !READ(E1_ENABLE_PIN)
|
2258
|
2332
|
#endif
|
2259
|
2333
|
|| !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
|