|
@@ -47,7 +47,7 @@
|
47
|
47
|
|
48
|
48
|
#ifdef BLINKM
|
49
|
49
|
#include "BlinkM.h"
|
50
|
|
-#include "Wire.h"
|
|
50
|
+#include "Wire.h"
|
51
|
51
|
#endif
|
52
|
52
|
|
53
|
53
|
#if NUM_SERVOS > 0
|
|
@@ -96,7 +96,7 @@
|
96
|
96
|
// M29 - Stop SD write
|
97
|
97
|
// M30 - Delete file from SD (M30 filename.g)
|
98
|
98
|
// M31 - Output time since last M109 or SD card start to serial
|
99
|
|
-// M32 - Select file and start SD print (Can be used _while_ printing from SD card files):
|
|
99
|
+// M32 - Select file and start SD print (Can be used _while_ printing from SD card files):
|
100
|
100
|
// syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
|
101
|
101
|
// Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl to #include).
|
102
|
102
|
// The '#' is necessary when calling from within sd files, as it stops buffer prereading
|
|
@@ -226,7 +226,11 @@ int EtoPPressure=0;
|
226
|
226
|
#endif
|
227
|
227
|
|
228
|
228
|
#ifdef ULTIPANEL
|
229
|
|
- bool powersupply = true;
|
|
229
|
+ #ifdef PS_DEFAULT_OFF
|
|
230
|
+ bool powersupply = false;
|
|
231
|
+ #else
|
|
232
|
+ bool powersupply = true;
|
|
233
|
+ #endif
|
230
|
234
|
#endif
|
231
|
235
|
|
232
|
236
|
#ifdef DELTA
|
|
@@ -415,7 +419,7 @@ void servo_init()
|
415
|
419
|
|
416
|
420
|
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
417
|
421
|
delay(PROBE_SERVO_DEACTIVATION_DELAY);
|
418
|
|
- servos[servo_endstops[Z_AXIS]].detach();
|
|
422
|
+ servos[servo_endstops[Z_AXIS]].detach();
|
419
|
423
|
#endif
|
420
|
424
|
}
|
421
|
425
|
|
|
@@ -636,17 +640,17 @@ void get_command()
|
636
|
640
|
if(!card.sdprinting || serial_count!=0){
|
637
|
641
|
return;
|
638
|
642
|
}
|
639
|
|
-
|
|
643
|
+
|
640
|
644
|
//'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
|
641
|
|
- // if it occures, stop_buffering is triggered and the buffer is ran dry.
|
|
645
|
+ // if it occures, stop_buffering is triggered and the buffer is ran dry.
|
642
|
646
|
// this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
|
643
|
|
-
|
|
647
|
+
|
644
|
648
|
static bool stop_buffering=false;
|
645
|
649
|
if(buflen==0) stop_buffering=false;
|
646
|
|
-
|
647
|
|
- while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
|
|
650
|
+
|
|
651
|
+ while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
|
648
|
652
|
int16_t n=card.get();
|
649
|
|
- serial_char = (char)n;
|
|
653
|
+ serial_char = (char)n;
|
650
|
654
|
if(serial_char == '\n' ||
|
651
|
655
|
serial_char == '\r' ||
|
652
|
656
|
(serial_char == '#' && comment_mode == false) ||
|
|
@@ -671,7 +675,7 @@ void get_command()
|
671
|
675
|
}
|
672
|
676
|
if(serial_char=='#')
|
673
|
677
|
stop_buffering=true;
|
674
|
|
-
|
|
678
|
+
|
675
|
679
|
if(!serial_count)
|
676
|
680
|
{
|
677
|
681
|
comment_mode = false; //for new command
|
|
@@ -743,13 +747,13 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
743
|
747
|
#endif
|
744
|
748
|
#if X_HOME_DIR != -1 || X2_HOME_DIR != 1
|
745
|
749
|
#error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
|
746
|
|
- #endif
|
|
750
|
+ #endif
|
747
|
751
|
|
748
|
752
|
#define DXC_FULL_CONTROL_MODE 0
|
749
|
753
|
#define DXC_AUTO_PARK_MODE 1
|
750
|
754
|
#define DXC_DUPLICATION_MODE 2
|
751
|
755
|
static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
752
|
|
-
|
|
756
|
+
|
753
|
757
|
static float x_home_pos(int extruder) {
|
754
|
758
|
if (extruder == 0)
|
755
|
759
|
return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
@@ -767,12 +771,12 @@ static int x_home_dir(int extruder) {
|
767
|
771
|
|
768
|
772
|
static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
|
769
|
773
|
static bool active_extruder_parked = false; // used in mode 1 & 2
|
770
|
|
-static float raised_parked_position[NUM_AXIS]; // used in mode 1
|
771
|
|
-static unsigned long delayed_move_time = 0; // used in mode 1
|
|
774
|
+static float raised_parked_position[NUM_AXIS]; // used in mode 1
|
|
775
|
+static unsigned long delayed_move_time = 0; // used in mode 1
|
772
|
776
|
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
|
773
|
777
|
static float duplicate_extruder_temp_offset = 0; // used in mode 2
|
774
|
778
|
bool extruder_duplication_enabled = false; // used in mode 2
|
775
|
|
-#endif //DUAL_X_CARRIAGE
|
|
779
|
+#endif //DUAL_X_CARRIAGE
|
776
|
780
|
|
777
|
781
|
static void axis_is_at_home(int axis) {
|
778
|
782
|
#ifdef DUAL_X_CARRIAGE
|
|
@@ -785,8 +789,8 @@ static void axis_is_at_home(int axis) {
|
785
|
789
|
}
|
786
|
790
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
|
787
|
791
|
current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
788
|
|
- min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homeing[X_AXIS];
|
789
|
|
- max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
|
|
792
|
+ min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
793
|
+ max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
|
790
|
794
|
max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
|
791
|
795
|
return;
|
792
|
796
|
}
|
|
@@ -853,7 +857,7 @@ static void run_z_probe() {
|
853
|
857
|
st_synchronize();
|
854
|
858
|
|
855
|
859
|
// move back down slowly to find bed
|
856
|
|
- feedrate = homing_feedrate[Z_AXIS]/4;
|
|
860
|
+ feedrate = homing_feedrate[Z_AXIS]/4;
|
857
|
861
|
zPosition -= home_retract_mm(Z_AXIS) * 2;
|
858
|
862
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
|
859
|
863
|
st_synchronize();
|
|
@@ -950,7 +954,7 @@ static void homeaxis(int axis) {
|
950
|
954
|
|
951
|
955
|
current_position[axis] = 0;
|
952
|
956
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
953
|
|
-
|
|
957
|
+
|
954
|
958
|
|
955
|
959
|
// Engage Servo endstop if enabled
|
956
|
960
|
#ifdef SERVO_ENDSTOPS
|
|
@@ -1008,7 +1012,7 @@ static void homeaxis(int axis) {
|
1008
|
1012
|
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
1009
|
1013
|
if (axis==Z_AXIS) retract_z_probe();
|
1010
|
1014
|
#endif
|
1011
|
|
-
|
|
1015
|
+
|
1012
|
1016
|
}
|
1013
|
1017
|
}
|
1014
|
1018
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
|
@@ -1082,7 +1086,7 @@ void process_commands()
|
1082
|
1086
|
destination[Y_AXIS]=current_position[Y_AXIS];
|
1083
|
1087
|
destination[Z_AXIS]=current_position[Z_AXIS];
|
1084
|
1088
|
current_position[Z_AXIS]+=retract_zlift;
|
1085
|
|
- destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
|
1089
|
+ destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
1086
|
1090
|
feedrate=retract_recover_feedrate;
|
1087
|
1091
|
retracted=false;
|
1088
|
1092
|
prepare_move();
|
|
@@ -1196,10 +1200,10 @@ void process_commands()
|
1196
|
1200
|
// reset state used by the different modes
|
1197
|
1201
|
memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
|
1198
|
1202
|
delayed_move_time = 0;
|
1199
|
|
- active_extruder_parked = true;
|
1200
|
|
- #else
|
|
1203
|
+ active_extruder_parked = true;
|
|
1204
|
+ #else
|
1201
|
1205
|
HOMEAXIS(X);
|
1202
|
|
- #endif
|
|
1206
|
+ #endif
|
1203
|
1207
|
}
|
1204
|
1208
|
|
1205
|
1209
|
if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
|
|
@@ -1218,7 +1222,7 @@ void process_commands()
|
1218
|
1222
|
current_position[Y_AXIS]=code_value()+add_homeing[1];
|
1219
|
1223
|
}
|
1220
|
1224
|
}
|
1221
|
|
-
|
|
1225
|
+
|
1222
|
1226
|
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
|
1223
|
1227
|
#ifndef Z_SAFE_HOMING
|
1224
|
1228
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -1230,14 +1234,14 @@ void process_commands()
|
1230
|
1234
|
#endif
|
1231
|
1235
|
HOMEAXIS(Z);
|
1232
|
1236
|
}
|
1233
|
|
- #else // Z Safe mode activated.
|
|
1237
|
+ #else // Z Safe mode activated.
|
1234
|
1238
|
if(home_all_axis) {
|
1235
|
1239
|
destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
|
1236
|
1240
|
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
|
1237
|
1241
|
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
|
1238
|
1242
|
feedrate = XY_TRAVEL_SPEED;
|
1239
|
1243
|
current_position[Z_AXIS] = 0;
|
1240
|
|
-
|
|
1244
|
+
|
1241
|
1245
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1242
|
1246
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
1243
|
1247
|
st_synchronize();
|
|
@@ -1255,7 +1259,7 @@ void process_commands()
|
1255
|
1259
|
&& (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
|
1256
|
1260
|
|
1257
|
1261
|
current_position[Z_AXIS] = 0;
|
1258
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1262
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1259
|
1263
|
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
|
1260
|
1264
|
feedrate = max_feedrate[Z_AXIS];
|
1261
|
1265
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
|
@@ -1275,8 +1279,8 @@ void process_commands()
|
1275
|
1279
|
#endif
|
1276
|
1280
|
#endif
|
1277
|
1281
|
|
1278
|
|
-
|
1279
|
|
-
|
|
1282
|
+
|
|
1283
|
+
|
1280
|
1284
|
if(code_seen(axis_codes[Z_AXIS])) {
|
1281
|
1285
|
if(code_value_long() != 0) {
|
1282
|
1286
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
|
@@ -1347,7 +1351,7 @@ void process_commands()
|
1347
|
1351
|
run_z_probe();
|
1348
|
1352
|
float z_at_xLeft_yFront = current_position[Z_AXIS];
|
1349
|
1353
|
retract_z_probe();
|
1350
|
|
-
|
|
1354
|
+
|
1351
|
1355
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1352
|
1356
|
SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
|
1353
|
1357
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1365,7 +1369,7 @@ void process_commands()
|
1365
|
1369
|
run_z_probe();
|
1366
|
1370
|
float z_at_xRight_yFront = current_position[Z_AXIS];
|
1367
|
1371
|
retract_z_probe(); // Retract Z Servo endstop if available
|
1368
|
|
-
|
|
1372
|
+
|
1369
|
1373
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1370
|
1374
|
SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
|
1371
|
1375
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1378,10 +1382,10 @@ void process_commands()
|
1378
|
1382
|
|
1379
|
1383
|
set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
1380
|
1384
|
|
1381
|
|
- st_synchronize();
|
|
1385
|
+ st_synchronize();
|
1382
|
1386
|
|
1383
|
1387
|
// The following code correct the Z height difference from z-probe position and hotend tip position.
|
1384
|
|
- // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
|
1388
|
+ // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
1385
|
1389
|
// When the bed is uneven, this height must be corrected.
|
1386
|
1390
|
real_z = float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
|
1387
|
1391
|
x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
|
@@ -1393,11 +1397,11 @@ void process_commands()
|
1393
|
1397
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1394
|
1398
|
}
|
1395
|
1399
|
break;
|
1396
|
|
-
|
|
1400
|
+
|
1397
|
1401
|
case 30: // G30 Single Z Probe
|
1398
|
1402
|
{
|
1399
|
1403
|
engage_z_probe(); // Engage Z Servo endstop if available
|
1400
|
|
-
|
|
1404
|
+
|
1401
|
1405
|
st_synchronize();
|
1402
|
1406
|
// TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
|
1403
|
1407
|
setup_for_endstop_move();
|
|
@@ -1548,14 +1552,14 @@ void process_commands()
|
1548
|
1552
|
card.removeFile(strchr_pointer + 4);
|
1549
|
1553
|
}
|
1550
|
1554
|
break;
|
1551
|
|
- case 32: //M32 - Select file and start SD print
|
|
1555
|
+ case 32: //M32 - Select file and start SD print
|
1552
|
1556
|
{
|
1553
|
1557
|
if(card.sdprinting) {
|
1554
|
1558
|
st_synchronize();
|
1555
|
1559
|
|
1556
|
1560
|
}
|
1557
|
|
- starpos = (strchr(strchr_pointer + 4,'*'));
|
1558
|
|
-
|
|
1561
|
+ starpos = (strchr(strchr_pointer + 4,'*'));
|
|
1562
|
+
|
1559
|
1563
|
char* namestartpos = (strchr(strchr_pointer + 4,'!')); //find ! to indicate filename string start.
|
1560
|
1564
|
if(namestartpos==NULL)
|
1561
|
1565
|
{
|
|
@@ -1563,16 +1567,16 @@ void process_commands()
|
1563
|
1567
|
}
|
1564
|
1568
|
else
|
1565
|
1569
|
namestartpos++; //to skip the '!'
|
1566
|
|
-
|
|
1570
|
+
|
1567
|
1571
|
if(starpos!=NULL)
|
1568
|
1572
|
*(starpos-1)='\0';
|
1569
|
|
-
|
|
1573
|
+
|
1570
|
1574
|
bool call_procedure=(code_seen('P'));
|
1571
|
|
-
|
1572
|
|
- if(strchr_pointer>namestartpos)
|
|
1575
|
+
|
|
1576
|
+ if(strchr_pointer>namestartpos)
|
1573
|
1577
|
call_procedure=false; //false alert, 'P' found within filename
|
1574
|
|
-
|
1575
|
|
- if( card.cardOK )
|
|
1578
|
+
|
|
1579
|
+ if( card.cardOK )
|
1576
|
1580
|
{
|
1577
|
1581
|
card.openFile(namestartpos,true,!call_procedure);
|
1578
|
1582
|
if(code_seen('S'))
|
|
@@ -1645,7 +1649,7 @@ void process_commands()
|
1645
|
1649
|
#ifdef DUAL_X_CARRIAGE
|
1646
|
1650
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1647
|
1651
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1648
|
|
-#endif
|
|
1652
|
+#endif
|
1649
|
1653
|
setWatch();
|
1650
|
1654
|
break;
|
1651
|
1655
|
case 140: // M140 set bed temp
|
|
@@ -1701,7 +1705,7 @@ void process_commands()
|
1701
|
1705
|
SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
|
1702
|
1706
|
}
|
1703
|
1707
|
#endif
|
1704
|
|
-
|
|
1708
|
+
|
1705
|
1709
|
SERIAL_PROTOCOLLN("");
|
1706
|
1710
|
return;
|
1707
|
1711
|
break;
|
|
@@ -1719,14 +1723,14 @@ void process_commands()
|
1719
|
1723
|
#ifdef DUAL_X_CARRIAGE
|
1720
|
1724
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1721
|
1725
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1722
|
|
-#endif
|
|
1726
|
+#endif
|
1723
|
1727
|
CooldownNoWait = true;
|
1724
|
1728
|
} else if (code_seen('R')) {
|
1725
|
1729
|
setTargetHotend(code_value(), tmp_extruder);
|
1726
|
1730
|
#ifdef DUAL_X_CARRIAGE
|
1727
|
1731
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1728
|
1732
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1729
|
|
-#endif
|
|
1733
|
+#endif
|
1730
|
1734
|
CooldownNoWait = false;
|
1731
|
1735
|
}
|
1732
|
1736
|
#ifdef AUTOTEMP
|
|
@@ -1890,7 +1894,7 @@ void process_commands()
|
1890
|
1894
|
SET_OUTPUT(SUICIDE_PIN);
|
1891
|
1895
|
WRITE(SUICIDE_PIN, HIGH);
|
1892
|
1896
|
#endif
|
1893
|
|
-
|
|
1897
|
+
|
1894
|
1898
|
#ifdef ULTIPANEL
|
1895
|
1899
|
powersupply = true;
|
1896
|
1900
|
LCD_MESSAGEPGM(WELCOME_MSG);
|
|
@@ -2047,18 +2051,18 @@ void process_commands()
|
2047
|
2051
|
#endif
|
2048
|
2052
|
break;
|
2049
|
2053
|
//TODO: update for all axis, use for loop
|
2050
|
|
- #ifdef BLINKM
|
|
2054
|
+ #ifdef BLINKM
|
2051
|
2055
|
case 150: // M150
|
2052
|
2056
|
{
|
2053
|
2057
|
byte red;
|
2054
|
2058
|
byte grn;
|
2055
|
2059
|
byte blu;
|
2056
|
|
-
|
|
2060
|
+
|
2057
|
2061
|
if(code_seen('R')) red = code_value();
|
2058
|
2062
|
if(code_seen('U')) grn = code_value();
|
2059
|
2063
|
if(code_seen('B')) blu = code_value();
|
2060
|
|
-
|
2061
|
|
- SendColors(red,grn,blu);
|
|
2064
|
+
|
|
2065
|
+ SendColors(red,grn,blu);
|
2062
|
2066
|
}
|
2063
|
2067
|
break;
|
2064
|
2068
|
#endif //BLINKM
|
|
@@ -2180,7 +2184,7 @@ void process_commands()
|
2180
|
2184
|
{
|
2181
|
2185
|
extruder_offset[Z_AXIS][tmp_extruder] = code_value();
|
2182
|
2186
|
}
|
2183
|
|
- #endif
|
|
2187
|
+ #endif
|
2184
|
2188
|
SERIAL_ECHO_START;
|
2185
|
2189
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
2186
|
2190
|
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
|
|
@@ -2213,17 +2217,17 @@ void process_commands()
|
2213
|
2217
|
}
|
2214
|
2218
|
}
|
2215
|
2219
|
break;
|
2216
|
|
-
|
|
2220
|
+
|
2217
|
2221
|
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
|
2218
|
2222
|
{
|
2219
|
2223
|
if(code_seen('P')){
|
2220
|
2224
|
int pin_number = code_value(); // pin number
|
2221
|
2225
|
int pin_state = -1; // required pin state - default is inverted
|
2222
|
|
-
|
|
2226
|
+
|
2223
|
2227
|
if(code_seen('S')) pin_state = code_value(); // required pin state
|
2224
|
|
-
|
|
2228
|
+
|
2225
|
2229
|
if(pin_state >= -1 && pin_state <= 1){
|
2226
|
|
-
|
|
2230
|
+
|
2227
|
2231
|
for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
|
2228
|
2232
|
{
|
2229
|
2233
|
if (sensitive_pins[i] == pin_number)
|
|
@@ -2232,28 +2236,28 @@ void process_commands()
|
2232
|
2236
|
break;
|
2233
|
2237
|
}
|
2234
|
2238
|
}
|
2235
|
|
-
|
|
2239
|
+
|
2236
|
2240
|
if (pin_number > -1)
|
2237
|
2241
|
{
|
2238
|
2242
|
st_synchronize();
|
2239
|
|
-
|
|
2243
|
+
|
2240
|
2244
|
pinMode(pin_number, INPUT);
|
2241
|
|
-
|
|
2245
|
+
|
2242
|
2246
|
int target;
|
2243
|
2247
|
switch(pin_state){
|
2244
|
2248
|
case 1:
|
2245
|
2249
|
target = HIGH;
|
2246
|
2250
|
break;
|
2247
|
|
-
|
|
2251
|
+
|
2248
|
2252
|
case 0:
|
2249
|
2253
|
target = LOW;
|
2250
|
2254
|
break;
|
2251
|
|
-
|
|
2255
|
+
|
2252
|
2256
|
case -1:
|
2253
|
2257
|
target = !digitalRead(pin_number);
|
2254
|
2258
|
break;
|
2255
|
2259
|
}
|
2256
|
|
-
|
|
2260
|
+
|
2257
|
2261
|
while(digitalRead(pin_number) != target){
|
2258
|
2262
|
manage_heater();
|
2259
|
2263
|
manage_inactivity();
|
|
@@ -2263,7 +2267,7 @@ void process_commands()
|
2263
|
2267
|
}
|
2264
|
2268
|
}
|
2265
|
2269
|
}
|
2266
|
|
- break;
|
|
2270
|
+ break;
|
2267
|
2271
|
|
2268
|
2272
|
#if NUM_SERVOS > 0
|
2269
|
2273
|
case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
|
@@ -2439,13 +2443,13 @@ void process_commands()
|
2439
|
2443
|
engage_z_probe(); // Engage Z Servo endstop if available
|
2440
|
2444
|
}
|
2441
|
2445
|
break;
|
2442
|
|
-
|
|
2446
|
+
|
2443
|
2447
|
case 402:
|
2444
|
2448
|
{
|
2445
|
2449
|
retract_z_probe(); // Retract Z Servo endstop if enabled
|
2446
|
2450
|
}
|
2447
|
2451
|
break;
|
2448
|
|
-#endif
|
|
2452
|
+#endif
|
2449
|
2453
|
case 500: // M500 Store settings in EEPROM
|
2450
|
2454
|
{
|
2451
|
2455
|
Config_StoreSettings();
|
|
@@ -2603,14 +2607,14 @@ void process_commands()
|
2603
|
2607
|
// M605 S0: Full control mode. The slicer has full control over x-carriage movement
|
2604
|
2608
|
// M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
|
2605
|
2609
|
// M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
|
2606
|
|
- // millimeters x-offset and an optional differential hotend temperature of
|
|
2610
|
+ // millimeters x-offset and an optional differential hotend temperature of
|
2607
|
2611
|
// mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
|
2608
|
2612
|
// the first with a spacing of 100mm in the x direction and 2 degrees hotter.
|
2609
|
2613
|
//
|
2610
|
2614
|
// Note: the X axis should be homed after changing dual x-carriage mode.
|
2611
|
2615
|
{
|
2612
|
2616
|
st_synchronize();
|
2613
|
|
-
|
|
2617
|
+
|
2614
|
2618
|
if (code_seen('S'))
|
2615
|
2619
|
dual_x_carriage_mode = code_value();
|
2616
|
2620
|
|
|
@@ -2621,7 +2625,7 @@ void process_commands()
|
2621
|
2625
|
|
2622
|
2626
|
if (code_seen('R'))
|
2623
|
2627
|
duplicate_extruder_temp_offset = code_value();
|
2624
|
|
-
|
|
2628
|
+
|
2625
|
2629
|
SERIAL_ECHO_START;
|
2626
|
2630
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
2627
|
2631
|
SERIAL_ECHO(" ");
|
|
@@ -2637,13 +2641,13 @@ void process_commands()
|
2637
|
2641
|
{
|
2638
|
2642
|
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
2639
|
2643
|
}
|
2640
|
|
-
|
|
2644
|
+
|
2641
|
2645
|
active_extruder_parked = false;
|
2642
|
2646
|
extruder_duplication_enabled = false;
|
2643
|
2647
|
delayed_move_time = 0;
|
2644
|
2648
|
}
|
2645
|
2649
|
break;
|
2646
|
|
- #endif //DUAL_X_CARRIAGE
|
|
2650
|
+ #endif //DUAL_X_CARRIAGE
|
2647
|
2651
|
|
2648
|
2652
|
case 907: // M907 Set digital trimpot motor current using axis codes.
|
2649
|
2653
|
{
|
|
@@ -2724,19 +2728,19 @@ void process_commands()
|
2724
|
2728
|
// Save current position to return to after applying extruder offset
|
2725
|
2729
|
memcpy(destination, current_position, sizeof(destination));
|
2726
|
2730
|
#ifdef DUAL_X_CARRIAGE
|
2727
|
|
- if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
|
2731
|
+ if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
2728
|
2732
|
(delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
|
2729
|
2733
|
{
|
2730
|
2734
|
// Park old head: 1) raise 2) move to park position 3) lower
|
2731
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
|
2735
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
2732
|
2736
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
2733
|
|
- plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
|
2737
|
+ plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
2734
|
2738
|
current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder);
|
2735
|
|
- plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
|
|
2739
|
+ plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
|
2736
|
2740
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
2737
|
2741
|
st_synchronize();
|
2738
|
2742
|
}
|
2739
|
|
-
|
|
2743
|
+
|
2740
|
2744
|
// apply Y & Z extruder offset (x offset is already used in determining home pos)
|
2741
|
2745
|
current_position[Y_AXIS] = current_position[Y_AXIS] -
|
2742
|
2746
|
extruder_offset[Y_AXIS][active_extruder] +
|
|
@@ -2744,7 +2748,7 @@ void process_commands()
|
2744
|
2748
|
current_position[Z_AXIS] = current_position[Z_AXIS] -
|
2745
|
2749
|
extruder_offset[Z_AXIS][active_extruder] +
|
2746
|
2750
|
extruder_offset[Z_AXIS][tmp_extruder];
|
2747
|
|
-
|
|
2751
|
+
|
2748
|
2752
|
active_extruder = tmp_extruder;
|
2749
|
2753
|
|
2750
|
2754
|
// This function resets the max/min values - the current position may be overwritten below.
|
|
@@ -2752,18 +2756,18 @@ void process_commands()
|
2752
|
2756
|
|
2753
|
2757
|
if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE)
|
2754
|
2758
|
{
|
2755
|
|
- current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
2759
|
+ current_position[X_AXIS] = inactive_extruder_x_pos;
|
2756
|
2760
|
inactive_extruder_x_pos = destination[X_AXIS];
|
2757
|
2761
|
}
|
2758
|
2762
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE)
|
2759
|
2763
|
{
|
2760
|
2764
|
active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
|
2761
|
2765
|
if (active_extruder == 0 || active_extruder_parked)
|
2762
|
|
- current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
2766
|
+ current_position[X_AXIS] = inactive_extruder_x_pos;
|
2763
|
2767
|
else
|
2764
|
|
- current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
|
|
2768
|
+ current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
|
2765
|
2769
|
inactive_extruder_x_pos = destination[X_AXIS];
|
2766
|
|
- extruder_duplication_enabled = false;
|
|
2770
|
+ extruder_duplication_enabled = false;
|
2767
|
2771
|
}
|
2768
|
2772
|
else
|
2769
|
2773
|
{
|
|
@@ -2773,7 +2777,7 @@ void process_commands()
|
2773
|
2777
|
active_extruder_parked = true;
|
2774
|
2778
|
delayed_move_time = 0;
|
2775
|
2779
|
}
|
2776
|
|
- #else
|
|
2780
|
+ #else
|
2777
|
2781
|
// Offset extruder (only by XY)
|
2778
|
2782
|
int i;
|
2779
|
2783
|
for(i = 0; i < 2; i++) {
|
|
@@ -2986,13 +2990,13 @@ void prepare_move()
|
2986
|
2990
|
{
|
2987
|
2991
|
// move duplicate extruder into correct duplication position.
|
2988
|
2992
|
plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2989
|
|
- plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
|
2993
|
+ plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
2990
|
2994
|
current_position[E_AXIS], max_feedrate[X_AXIS], 1);
|
2991
|
2995
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2992
|
2996
|
st_synchronize();
|
2993
|
2997
|
extruder_duplication_enabled = true;
|
2994
|
2998
|
active_extruder_parked = false;
|
2995
|
|
- }
|
|
2999
|
+ }
|
2996
|
3000
|
else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
|
2997
|
3001
|
{
|
2998
|
3002
|
if (current_position[E_AXIS] == destination[E_AXIS])
|
|
@@ -3001,7 +3005,7 @@ void prepare_move()
|
3001
|
3005
|
// be used as start of first non-travel move)
|
3002
|
3006
|
if (delayed_move_time != 0xFFFFFFFFUL)
|
3003
|
3007
|
{
|
3004
|
|
- memcpy(current_position, destination, sizeof(current_position));
|
|
3008
|
+ memcpy(current_position, destination, sizeof(current_position));
|
3005
|
3009
|
if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
|
3006
|
3010
|
raised_parked_position[Z_AXIS] = destination[Z_AXIS];
|
3007
|
3011
|
delayed_move_time = millis();
|
|
@@ -3011,9 +3015,9 @@ void prepare_move()
|
3011
|
3015
|
delayed_move_time = 0;
|
3012
|
3016
|
// unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
|
3013
|
3017
|
plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
3014
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
|
3018
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
3015
|
3019
|
current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
|
3016
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
|
3020
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
3017
|
3021
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
3018
|
3022
|
active_extruder_parked = false;
|
3019
|
3023
|
}
|
|
@@ -3179,7 +3183,7 @@ void manage_inactivity()
|
3179
|
3183
|
// travel moves have been received so enact them
|
3180
|
3184
|
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
|
3181
|
3185
|
memcpy(destination,current_position,sizeof(destination));
|
3182
|
|
- prepare_move();
|
|
3186
|
+ prepare_move();
|
3183
|
3187
|
}
|
3184
|
3188
|
#endif
|
3185
|
3189
|
#ifdef TEMP_STAT_LEDS
|