|
@@ -194,6 +194,10 @@ int EtoPPressure=0;
|
194
|
194
|
float retract_recover_length=0, retract_recover_feedrate=8*60;
|
195
|
195
|
#endif
|
196
|
196
|
|
|
197
|
+#ifdef ULTIPANEL
|
|
198
|
+ bool powersupply = true;
|
|
199
|
+#endif
|
|
200
|
+
|
197
|
201
|
//===========================================================================
|
198
|
202
|
//=============================private variables=============================
|
199
|
203
|
//===========================================================================
|
|
@@ -677,7 +681,44 @@ XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH);
|
677
|
681
|
XYZ_CONSTS_FROM_CONFIG(float, home_retract_mm, HOME_RETRACT_MM);
|
678
|
682
|
XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
679
|
683
|
|
|
684
|
+#ifdef DUAL_X_CARRIAGE
|
|
685
|
+ #if EXTRUDERS == 1 || defined(COREXY) \
|
|
686
|
+ || !defined(X2_ENABLE_PIN) || !defined(X2_STEP_PIN) || !defined(X2_DIR_PIN) \
|
|
687
|
+ || !defined(X2_HOME_POS) || !defined(X2_MIN_POS) || !defined(X2_MAX_POS) \
|
|
688
|
+ || !defined(X_MAX_PIN) || X_MAX_PIN < 0
|
|
689
|
+ #error "Missing or invalid definitions for DUAL_X_CARRIAGE mode."
|
|
690
|
+ #endif
|
|
691
|
+ #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
|
|
692
|
+ #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
|
|
693
|
+ #endif
|
|
694
|
+
|
|
695
|
+static float x_home_pos(int extruder) {
|
|
696
|
+ if (extruder == 0)
|
|
697
|
+ return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
698
|
+ else
|
|
699
|
+ // In dual carriage mode the extruder offset provides an override of the
|
|
700
|
+ // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
|
|
701
|
+ // This allow soft recalibration of the second extruder offset position without firmware reflash
|
|
702
|
+ // (through the M218 command).
|
|
703
|
+ return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
|
|
704
|
+}
|
|
705
|
+
|
|
706
|
+static int x_home_dir(int extruder) {
|
|
707
|
+ return (extruder == 0) ? X_HOME_DIR : X2_HOME_DIR;
|
|
708
|
+}
|
|
709
|
+
|
|
710
|
+static float inactive_x_carriage_pos = X2_MAX_POS;
|
|
711
|
+#endif
|
|
712
|
+
|
680
|
713
|
static void axis_is_at_home(int axis) {
|
|
714
|
+#ifdef DUAL_X_CARRIAGE
|
|
715
|
+ if (axis == X_AXIS && active_extruder != 0) {
|
|
716
|
+ current_position[X_AXIS] = x_home_pos(active_extruder);
|
|
717
|
+ min_pos[X_AXIS] = X2_MIN_POS;
|
|
718
|
+ max_pos[X_AXIS] = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
|
|
719
|
+ return;
|
|
720
|
+ }
|
|
721
|
+#endif
|
681
|
722
|
current_position[axis] = base_home_pos(axis) + add_homeing[axis];
|
682
|
723
|
min_pos[axis] = base_min_pos(axis) + add_homeing[axis];
|
683
|
724
|
max_pos[axis] = base_max_pos(axis) + add_homeing[axis];
|
|
@@ -686,10 +727,16 @@ static void axis_is_at_home(int axis) {
|
686
|
727
|
static void homeaxis(int axis) {
|
687
|
728
|
#define HOMEAXIS_DO(LETTER) \
|
688
|
729
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
|
730
|
+
|
689
|
731
|
if (axis==X_AXIS ? HOMEAXIS_DO(X) :
|
690
|
732
|
axis==Y_AXIS ? HOMEAXIS_DO(Y) :
|
691
|
733
|
axis==Z_AXIS ? HOMEAXIS_DO(Z) :
|
692
|
734
|
0) {
|
|
735
|
+ int axis_home_dir = home_dir(axis);
|
|
736
|
+#ifdef DUAL_X_CARRIAGE
|
|
737
|
+ if (axis == X_AXIS)
|
|
738
|
+ axis_home_dir = x_home_dir(active_extruder);
|
|
739
|
+#endif
|
693
|
740
|
|
694
|
741
|
// Engage Servo endstop if enabled
|
695
|
742
|
#ifdef SERVO_ENDSTOPS
|
|
@@ -700,18 +747,18 @@ static void homeaxis(int axis) {
|
700
|
747
|
|
701
|
748
|
current_position[axis] = 0;
|
702
|
749
|
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);
|
|
750
|
+ destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
704
|
751
|
feedrate = homing_feedrate[axis];
|
705
|
752
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
706
|
753
|
st_synchronize();
|
707
|
754
|
|
708
|
755
|
current_position[axis] = 0;
|
709
|
756
|
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);
|
|
757
|
+ destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
711
|
758
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
712
|
759
|
st_synchronize();
|
713
|
760
|
|
714
|
|
- destination[axis] = 2*home_retract_mm(axis) * home_dir(axis);
|
|
761
|
+ destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
715
|
762
|
#ifdef DELTA
|
716
|
763
|
feedrate = homing_feedrate[axis]/10;
|
717
|
764
|
#else
|
|
@@ -855,7 +902,7 @@ void process_commands()
|
855
|
902
|
|
856
|
903
|
#else // NOT DELTA
|
857
|
904
|
|
858
|
|
- home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
|
905
|
+ home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
859
|
906
|
|
860
|
907
|
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
861
|
908
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -868,8 +915,14 @@ void process_commands()
|
868
|
915
|
{
|
869
|
916
|
current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;
|
870
|
917
|
|
|
918
|
+ #ifndef DUAL_X_CARRIAGE
|
|
919
|
+ int x_axis_home_dir = home_dir(X_AXIS);
|
|
920
|
+ #else
|
|
921
|
+ int x_axis_home_dir = x_home_dir(active_extruder);
|
|
922
|
+ #endif
|
|
923
|
+
|
871
|
924
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
872
|
|
- destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
|
|
925
|
+ 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);
|
873
|
926
|
feedrate = homing_feedrate[X_AXIS];
|
874
|
927
|
if(homing_feedrate[Y_AXIS]<feedrate)
|
875
|
928
|
feedrate =homing_feedrate[Y_AXIS];
|
|
@@ -894,6 +947,13 @@ void process_commands()
|
894
|
947
|
|
895
|
948
|
if((home_all_axis) || (code_seen(axis_codes[X_AXIS])))
|
896
|
949
|
{
|
|
950
|
+ #ifdef DUAL_X_CARRIAGE
|
|
951
|
+ int tmp_extruder = active_extruder;
|
|
952
|
+ active_extruder = !active_extruder;
|
|
953
|
+ HOMEAXIS(X);
|
|
954
|
+ inactive_x_carriage_pos = current_position[X_AXIS];
|
|
955
|
+ active_extruder = tmp_extruder;
|
|
956
|
+ #endif
|
897
|
957
|
HOMEAXIS(X);
|
898
|
958
|
}
|
899
|
959
|
|
|
@@ -926,7 +986,7 @@ void process_commands()
|
926
|
986
|
}
|
927
|
987
|
}
|
928
|
988
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
929
|
|
-#endif // DELTA
|
|
989
|
+#endif // else DELTA
|
930
|
990
|
|
931
|
991
|
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
932
|
992
|
enable_endstops(false);
|
|
@@ -1338,14 +1398,26 @@ void process_commands()
|
1338
|
1398
|
#endif
|
1339
|
1399
|
|
1340
|
1400
|
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
|
1341
|
|
- case 80: // M80 - ATX Power On
|
|
1401
|
+ case 80: // M80 - Turn on Power Supply
|
1342
|
1402
|
SET_OUTPUT(PS_ON_PIN); //GND
|
1343
|
1403
|
WRITE(PS_ON_PIN, PS_ON_AWAKE);
|
|
1404
|
+ #ifdef ULTIPANEL
|
|
1405
|
+ powersupply = true;
|
|
1406
|
+ LCD_MESSAGEPGM(WELCOME_MSG);
|
|
1407
|
+ lcd_update();
|
|
1408
|
+ #endif
|
1344
|
1409
|
break;
|
1345
|
1410
|
#endif
|
1346
|
|
-
|
1347
|
|
- case 81: // M81 - ATX Power Off
|
1348
|
|
-
|
|
1411
|
+
|
|
1412
|
+ case 81: // M81 - Turn off Power Supply
|
|
1413
|
+ disable_heater();
|
|
1414
|
+ st_synchronize();
|
|
1415
|
+ disable_e0();
|
|
1416
|
+ disable_e1();
|
|
1417
|
+ disable_e2();
|
|
1418
|
+ finishAndDisableSteppers();
|
|
1419
|
+ fanSpeed = 0;
|
|
1420
|
+ delay(1000); // Wait a little before to switch off
|
1349
|
1421
|
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
|
1350
|
1422
|
st_synchronize();
|
1351
|
1423
|
suicide();
|
|
@@ -1353,7 +1425,12 @@ void process_commands()
|
1353
|
1425
|
SET_OUTPUT(PS_ON_PIN);
|
1354
|
1426
|
WRITE(PS_ON_PIN, PS_ON_ASLEEP);
|
1355
|
1427
|
#endif
|
1356
|
|
- break;
|
|
1428
|
+ #ifdef ULTIPANEL
|
|
1429
|
+ powersupply = false;
|
|
1430
|
+ LCD_MESSAGEPGM(MACHINE_NAME" "MSG_OFF".");
|
|
1431
|
+ lcd_update();
|
|
1432
|
+ #endif
|
|
1433
|
+ break;
|
1357
|
1434
|
|
1358
|
1435
|
case 82:
|
1359
|
1436
|
axis_relative_modes[3] = false;
|
|
@@ -2005,6 +2082,20 @@ void process_commands()
|
2005
|
2082
|
if(tmp_extruder != active_extruder) {
|
2006
|
2083
|
// Save current position to return to after applying extruder offset
|
2007
|
2084
|
memcpy(destination, current_position, sizeof(destination));
|
|
2085
|
+ #ifdef DUAL_X_CARRIAGE
|
|
2086
|
+ // only apply Y extruder offset in dual x carriage mode (x offset is already used in determining home pos)
|
|
2087
|
+ current_position[Y_AXIS] = current_position[Y_AXIS] -
|
|
2088
|
+ extruder_offset[Y_AXIS][active_extruder] +
|
|
2089
|
+ extruder_offset[Y_AXIS][tmp_extruder];
|
|
2090
|
+
|
|
2091
|
+ float tmp_x_pos = current_position[X_AXIS];
|
|
2092
|
+
|
|
2093
|
+ // Set the new active extruder and position
|
|
2094
|
+ active_extruder = tmp_extruder;
|
|
2095
|
+ axis_is_at_home(X_AXIS); //this function updates X min/max values.
|
|
2096
|
+ current_position[X_AXIS] = inactive_x_carriage_pos;
|
|
2097
|
+ inactive_x_carriage_pos = tmp_x_pos;
|
|
2098
|
+ #else
|
2008
|
2099
|
// Offset extruder (only by XY)
|
2009
|
2100
|
int i;
|
2010
|
2101
|
for(i = 0; i < 2; i++) {
|
|
@@ -2014,6 +2105,7 @@ void process_commands()
|
2014
|
2105
|
}
|
2015
|
2106
|
// Set the new active extruder and position
|
2016
|
2107
|
active_extruder = tmp_extruder;
|
|
2108
|
+ #endif //else DUAL_X_CARRIAGE
|
2017
|
2109
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2018
|
2110
|
// Move to the old position if 'F' was in the parameters
|
2019
|
2111
|
if(make_move && Stopped == false) {
|
|
@@ -2258,6 +2350,9 @@ void controllerFan()
|
2258
|
2350
|
|| !READ(E2_ENABLE_PIN)
|
2259
|
2351
|
#endif
|
2260
|
2352
|
#if EXTRUDER > 1
|
|
2353
|
+ #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
|
2354
|
+ || !READ(X2_ENABLE_PIN)
|
|
2355
|
+ #endif
|
2261
|
2356
|
|| !READ(E1_ENABLE_PIN)
|
2262
|
2357
|
#endif
|
2263
|
2358
|
|| !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
|