|
@@ -50,7 +50,7 @@
|
50
|
50
|
|
51
|
51
|
#ifdef BLINKM
|
52
|
52
|
#include "BlinkM.h"
|
53
|
|
-#include "Wire.h"
|
|
53
|
+#include "Wire.h"
|
54
|
54
|
#endif
|
55
|
55
|
|
56
|
56
|
#if NUM_SERVOS > 0
|
|
@@ -99,7 +99,7 @@
|
99
|
99
|
// M29 - Stop SD write
|
100
|
100
|
// M30 - Delete file from SD (M30 filename.g)
|
101
|
101
|
// M31 - Output time since last M109 or SD card start to serial
|
102
|
|
-// M32 - Select file and start SD print (Can be used _while_ printing from SD card files):
|
|
102
|
+// M32 - Select file and start SD print (Can be used _while_ printing from SD card files):
|
103
|
103
|
// syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
|
104
|
104
|
// Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl to #include).
|
105
|
105
|
// The '#' is necessary when calling from within sd files, as it stops buffer prereading
|
|
@@ -229,7 +229,11 @@ int EtoPPressure=0;
|
229
|
229
|
#endif
|
230
|
230
|
|
231
|
231
|
#ifdef ULTIPANEL
|
232
|
|
- bool powersupply = true;
|
|
232
|
+ #ifdef PS_DEFAULT_OFF
|
|
233
|
+ bool powersupply = false;
|
|
234
|
+ #else
|
|
235
|
+ bool powersupply = true;
|
|
236
|
+ #endif
|
233
|
237
|
#endif
|
234
|
238
|
|
235
|
239
|
#ifdef DELTA
|
|
@@ -418,7 +422,7 @@ void servo_init()
|
418
|
422
|
|
419
|
423
|
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
420
|
424
|
delay(PROBE_SERVO_DEACTIVATION_DELAY);
|
421
|
|
- servos[servo_endstops[Z_AXIS]].detach();
|
|
425
|
+ servos[servo_endstops[Z_AXIS]].detach();
|
422
|
426
|
#endif
|
423
|
427
|
}
|
424
|
428
|
|
|
@@ -639,17 +643,17 @@ void get_command()
|
639
|
643
|
if(!card.sdprinting || serial_count!=0){
|
640
|
644
|
return;
|
641
|
645
|
}
|
642
|
|
-
|
|
646
|
+
|
643
|
647
|
//'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
|
644
|
|
- // if it occures, stop_buffering is triggered and the buffer is ran dry.
|
|
648
|
+ // if it occures, stop_buffering is triggered and the buffer is ran dry.
|
645
|
649
|
// this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
|
646
|
|
-
|
|
650
|
+
|
647
|
651
|
static bool stop_buffering=false;
|
648
|
652
|
if(buflen==0) stop_buffering=false;
|
649
|
|
-
|
650
|
|
- while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
|
|
653
|
+
|
|
654
|
+ while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
|
651
|
655
|
int16_t n=card.get();
|
652
|
|
- serial_char = (char)n;
|
|
656
|
+ serial_char = (char)n;
|
653
|
657
|
if(serial_char == '\n' ||
|
654
|
658
|
serial_char == '\r' ||
|
655
|
659
|
(serial_char == '#' && comment_mode == false) ||
|
|
@@ -674,7 +678,7 @@ void get_command()
|
674
|
678
|
}
|
675
|
679
|
if(serial_char=='#')
|
676
|
680
|
stop_buffering=true;
|
677
|
|
-
|
|
681
|
+
|
678
|
682
|
if(!serial_count)
|
679
|
683
|
{
|
680
|
684
|
comment_mode = false; //for new command
|
|
@@ -746,13 +750,13 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
746
|
750
|
#endif
|
747
|
751
|
#if X_HOME_DIR != -1 || X2_HOME_DIR != 1
|
748
|
752
|
#error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
|
749
|
|
- #endif
|
|
753
|
+ #endif
|
750
|
754
|
|
751
|
755
|
#define DXC_FULL_CONTROL_MODE 0
|
752
|
756
|
#define DXC_AUTO_PARK_MODE 1
|
753
|
757
|
#define DXC_DUPLICATION_MODE 2
|
754
|
758
|
static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
755
|
|
-
|
|
759
|
+
|
756
|
760
|
static float x_home_pos(int extruder) {
|
757
|
761
|
if (extruder == 0)
|
758
|
762
|
return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
@@ -770,12 +774,12 @@ static int x_home_dir(int extruder) {
|
770
|
774
|
|
771
|
775
|
static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
|
772
|
776
|
static bool active_extruder_parked = false; // used in mode 1 & 2
|
773
|
|
-static float raised_parked_position[NUM_AXIS]; // used in mode 1
|
774
|
|
-static unsigned long delayed_move_time = 0; // used in mode 1
|
|
777
|
+static float raised_parked_position[NUM_AXIS]; // used in mode 1
|
|
778
|
+static unsigned long delayed_move_time = 0; // used in mode 1
|
775
|
779
|
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
|
776
|
780
|
static float duplicate_extruder_temp_offset = 0; // used in mode 2
|
777
|
781
|
bool extruder_duplication_enabled = false; // used in mode 2
|
778
|
|
-#endif //DUAL_X_CARRIAGE
|
|
782
|
+#endif //DUAL_X_CARRIAGE
|
779
|
783
|
|
780
|
784
|
static void axis_is_at_home(int axis) {
|
781
|
785
|
#ifdef DUAL_X_CARRIAGE
|
|
@@ -788,8 +792,8 @@ static void axis_is_at_home(int axis) {
|
788
|
792
|
}
|
789
|
793
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
|
790
|
794
|
current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
791
|
|
- min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homeing[X_AXIS];
|
792
|
|
- max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
|
|
795
|
+ min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
796
|
+ max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
|
793
|
797
|
max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
|
794
|
798
|
return;
|
795
|
799
|
}
|
|
@@ -881,7 +885,7 @@ static void run_z_probe() {
|
881
|
885
|
st_synchronize();
|
882
|
886
|
|
883
|
887
|
// move back down slowly to find bed
|
884
|
|
- feedrate = homing_feedrate[Z_AXIS]/4;
|
|
888
|
+ feedrate = homing_feedrate[Z_AXIS]/4;
|
885
|
889
|
zPosition -= home_retract_mm(Z_AXIS) * 2;
|
886
|
890
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
|
887
|
891
|
st_synchronize();
|
|
@@ -978,7 +982,7 @@ static void homeaxis(int axis) {
|
978
|
982
|
|
979
|
983
|
current_position[axis] = 0;
|
980
|
984
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
981
|
|
-
|
|
985
|
+
|
982
|
986
|
|
983
|
987
|
// Engage Servo endstop if enabled
|
984
|
988
|
#ifdef SERVO_ENDSTOPS
|
|
@@ -1036,7 +1040,7 @@ static void homeaxis(int axis) {
|
1036
|
1040
|
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
1037
|
1041
|
if (axis==Z_AXIS) retract_z_probe();
|
1038
|
1042
|
#endif
|
1039
|
|
-
|
|
1043
|
+
|
1040
|
1044
|
}
|
1041
|
1045
|
}
|
1042
|
1046
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
|
@@ -1110,7 +1114,7 @@ void process_commands()
|
1110
|
1114
|
destination[Y_AXIS]=current_position[Y_AXIS];
|
1111
|
1115
|
destination[Z_AXIS]=current_position[Z_AXIS];
|
1112
|
1116
|
current_position[Z_AXIS]+=retract_zlift;
|
1113
|
|
- destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
|
1117
|
+ destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
1114
|
1118
|
feedrate=retract_recover_feedrate;
|
1115
|
1119
|
retracted=false;
|
1116
|
1120
|
prepare_move();
|
|
@@ -1224,10 +1228,10 @@ void process_commands()
|
1224
|
1228
|
// reset state used by the different modes
|
1225
|
1229
|
memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
|
1226
|
1230
|
delayed_move_time = 0;
|
1227
|
|
- active_extruder_parked = true;
|
1228
|
|
- #else
|
|
1231
|
+ active_extruder_parked = true;
|
|
1232
|
+ #else
|
1229
|
1233
|
HOMEAXIS(X);
|
1230
|
|
- #endif
|
|
1234
|
+ #endif
|
1231
|
1235
|
}
|
1232
|
1236
|
|
1233
|
1237
|
if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
|
|
@@ -1246,7 +1250,7 @@ void process_commands()
|
1246
|
1250
|
current_position[Y_AXIS]=code_value()+add_homeing[1];
|
1247
|
1251
|
}
|
1248
|
1252
|
}
|
1249
|
|
-
|
|
1253
|
+
|
1250
|
1254
|
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
|
1251
|
1255
|
#ifndef Z_SAFE_HOMING
|
1252
|
1256
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -1258,14 +1262,14 @@ void process_commands()
|
1258
|
1262
|
#endif
|
1259
|
1263
|
HOMEAXIS(Z);
|
1260
|
1264
|
}
|
1261
|
|
- #else // Z Safe mode activated.
|
|
1265
|
+ #else // Z Safe mode activated.
|
1262
|
1266
|
if(home_all_axis) {
|
1263
|
1267
|
destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
|
1264
|
1268
|
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
|
1265
|
1269
|
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
|
1266
|
1270
|
feedrate = XY_TRAVEL_SPEED;
|
1267
|
1271
|
current_position[Z_AXIS] = 0;
|
1268
|
|
-
|
|
1272
|
+
|
1269
|
1273
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1270
|
1274
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
1271
|
1275
|
st_synchronize();
|
|
@@ -1283,7 +1287,7 @@ void process_commands()
|
1283
|
1287
|
&& (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
|
1284
|
1288
|
|
1285
|
1289
|
current_position[Z_AXIS] = 0;
|
1286
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1290
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1287
|
1291
|
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
|
1288
|
1292
|
feedrate = max_feedrate[Z_AXIS];
|
1289
|
1293
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
|
@@ -1303,8 +1307,8 @@ void process_commands()
|
1303
|
1307
|
#endif
|
1304
|
1308
|
#endif
|
1305
|
1309
|
|
1306
|
|
-
|
1307
|
|
-
|
|
1310
|
+
|
|
1311
|
+
|
1308
|
1312
|
if(code_seen(axis_codes[Z_AXIS])) {
|
1309
|
1313
|
if(code_value_long() != 0) {
|
1310
|
1314
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
|
@@ -1467,7 +1471,7 @@ void process_commands()
|
1467
|
1471
|
run_z_probe();
|
1468
|
1472
|
float z_at_xLeft_yFront = current_position[Z_AXIS];
|
1469
|
1473
|
retract_z_probe();
|
1470
|
|
-
|
|
1474
|
+
|
1471
|
1475
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1472
|
1476
|
SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
|
1473
|
1477
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1485,7 +1489,7 @@ void process_commands()
|
1485
|
1489
|
run_z_probe();
|
1486
|
1490
|
float z_at_xRight_yFront = current_position[Z_AXIS];
|
1487
|
1491
|
retract_z_probe(); // Retract Z Servo endstop if available
|
1488
|
|
-
|
|
1492
|
+
|
1489
|
1493
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1490
|
1494
|
SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
|
1491
|
1495
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1500,10 +1504,10 @@ void process_commands()
|
1500
|
1504
|
|
1501
|
1505
|
|
1502
|
1506
|
#endif // ACCURATE_BED_LEVELING
|
1503
|
|
- st_synchronize();
|
|
1507
|
+ st_synchronize();
|
1504
|
1508
|
|
1505
|
1509
|
// The following code correct the Z height difference from z-probe position and hotend tip position.
|
1506
|
|
- // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
|
1510
|
+ // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
1507
|
1511
|
// When the bed is uneven, this height must be corrected.
|
1508
|
1512
|
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)
|
1509
|
1513
|
x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
|
@@ -1515,11 +1519,11 @@ void process_commands()
|
1515
|
1519
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1516
|
1520
|
}
|
1517
|
1521
|
break;
|
1518
|
|
-
|
|
1522
|
+
|
1519
|
1523
|
case 30: // G30 Single Z Probe
|
1520
|
1524
|
{
|
1521
|
1525
|
engage_z_probe(); // Engage Z Servo endstop if available
|
1522
|
|
-
|
|
1526
|
+
|
1523
|
1527
|
st_synchronize();
|
1524
|
1528
|
// TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
|
1525
|
1529
|
setup_for_endstop_move();
|
|
@@ -1670,14 +1674,14 @@ void process_commands()
|
1670
|
1674
|
card.removeFile(strchr_pointer + 4);
|
1671
|
1675
|
}
|
1672
|
1676
|
break;
|
1673
|
|
- case 32: //M32 - Select file and start SD print
|
|
1677
|
+ case 32: //M32 - Select file and start SD print
|
1674
|
1678
|
{
|
1675
|
1679
|
if(card.sdprinting) {
|
1676
|
1680
|
st_synchronize();
|
1677
|
1681
|
|
1678
|
1682
|
}
|
1679
|
|
- starpos = (strchr(strchr_pointer + 4,'*'));
|
1680
|
|
-
|
|
1683
|
+ starpos = (strchr(strchr_pointer + 4,'*'));
|
|
1684
|
+
|
1681
|
1685
|
char* namestartpos = (strchr(strchr_pointer + 4,'!')); //find ! to indicate filename string start.
|
1682
|
1686
|
if(namestartpos==NULL)
|
1683
|
1687
|
{
|
|
@@ -1685,16 +1689,16 @@ void process_commands()
|
1685
|
1689
|
}
|
1686
|
1690
|
else
|
1687
|
1691
|
namestartpos++; //to skip the '!'
|
1688
|
|
-
|
|
1692
|
+
|
1689
|
1693
|
if(starpos!=NULL)
|
1690
|
1694
|
*(starpos-1)='\0';
|
1691
|
|
-
|
|
1695
|
+
|
1692
|
1696
|
bool call_procedure=(code_seen('P'));
|
1693
|
|
-
|
1694
|
|
- if(strchr_pointer>namestartpos)
|
|
1697
|
+
|
|
1698
|
+ if(strchr_pointer>namestartpos)
|
1695
|
1699
|
call_procedure=false; //false alert, 'P' found within filename
|
1696
|
|
-
|
1697
|
|
- if( card.cardOK )
|
|
1700
|
+
|
|
1701
|
+ if( card.cardOK )
|
1698
|
1702
|
{
|
1699
|
1703
|
card.openFile(namestartpos,true,!call_procedure);
|
1700
|
1704
|
if(code_seen('S'))
|
|
@@ -1767,7 +1771,7 @@ void process_commands()
|
1767
|
1771
|
#ifdef DUAL_X_CARRIAGE
|
1768
|
1772
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1769
|
1773
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1770
|
|
-#endif
|
|
1774
|
+#endif
|
1771
|
1775
|
setWatch();
|
1772
|
1776
|
break;
|
1773
|
1777
|
case 140: // M140 set bed temp
|
|
@@ -1823,7 +1827,7 @@ void process_commands()
|
1823
|
1827
|
SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
|
1824
|
1828
|
}
|
1825
|
1829
|
#endif
|
1826
|
|
-
|
|
1830
|
+
|
1827
|
1831
|
SERIAL_PROTOCOLLN("");
|
1828
|
1832
|
return;
|
1829
|
1833
|
break;
|
|
@@ -1841,14 +1845,14 @@ void process_commands()
|
1841
|
1845
|
#ifdef DUAL_X_CARRIAGE
|
1842
|
1846
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1843
|
1847
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1844
|
|
-#endif
|
|
1848
|
+#endif
|
1845
|
1849
|
CooldownNoWait = true;
|
1846
|
1850
|
} else if (code_seen('R')) {
|
1847
|
1851
|
setTargetHotend(code_value(), tmp_extruder);
|
1848
|
1852
|
#ifdef DUAL_X_CARRIAGE
|
1849
|
1853
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1850
|
1854
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1851
|
|
-#endif
|
|
1855
|
+#endif
|
1852
|
1856
|
CooldownNoWait = false;
|
1853
|
1857
|
}
|
1854
|
1858
|
#ifdef AUTOTEMP
|
|
@@ -2012,7 +2016,7 @@ void process_commands()
|
2012
|
2016
|
SET_OUTPUT(SUICIDE_PIN);
|
2013
|
2017
|
WRITE(SUICIDE_PIN, HIGH);
|
2014
|
2018
|
#endif
|
2015
|
|
-
|
|
2019
|
+
|
2016
|
2020
|
#ifdef ULTIPANEL
|
2017
|
2021
|
powersupply = true;
|
2018
|
2022
|
LCD_MESSAGEPGM(WELCOME_MSG);
|
|
@@ -2169,18 +2173,18 @@ void process_commands()
|
2169
|
2173
|
#endif
|
2170
|
2174
|
break;
|
2171
|
2175
|
//TODO: update for all axis, use for loop
|
2172
|
|
- #ifdef BLINKM
|
|
2176
|
+ #ifdef BLINKM
|
2173
|
2177
|
case 150: // M150
|
2174
|
2178
|
{
|
2175
|
2179
|
byte red;
|
2176
|
2180
|
byte grn;
|
2177
|
2181
|
byte blu;
|
2178
|
|
-
|
|
2182
|
+
|
2179
|
2183
|
if(code_seen('R')) red = code_value();
|
2180
|
2184
|
if(code_seen('U')) grn = code_value();
|
2181
|
2185
|
if(code_seen('B')) blu = code_value();
|
2182
|
|
-
|
2183
|
|
- SendColors(red,grn,blu);
|
|
2186
|
+
|
|
2187
|
+ SendColors(red,grn,blu);
|
2184
|
2188
|
}
|
2185
|
2189
|
break;
|
2186
|
2190
|
#endif //BLINKM
|
|
@@ -2302,7 +2306,7 @@ void process_commands()
|
2302
|
2306
|
{
|
2303
|
2307
|
extruder_offset[Z_AXIS][tmp_extruder] = code_value();
|
2304
|
2308
|
}
|
2305
|
|
- #endif
|
|
2309
|
+ #endif
|
2306
|
2310
|
SERIAL_ECHO_START;
|
2307
|
2311
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
2308
|
2312
|
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
|
|
@@ -2335,17 +2339,17 @@ void process_commands()
|
2335
|
2339
|
}
|
2336
|
2340
|
}
|
2337
|
2341
|
break;
|
2338
|
|
-
|
|
2342
|
+
|
2339
|
2343
|
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
|
2340
|
2344
|
{
|
2341
|
2345
|
if(code_seen('P')){
|
2342
|
2346
|
int pin_number = code_value(); // pin number
|
2343
|
2347
|
int pin_state = -1; // required pin state - default is inverted
|
2344
|
|
-
|
|
2348
|
+
|
2345
|
2349
|
if(code_seen('S')) pin_state = code_value(); // required pin state
|
2346
|
|
-
|
|
2350
|
+
|
2347
|
2351
|
if(pin_state >= -1 && pin_state <= 1){
|
2348
|
|
-
|
|
2352
|
+
|
2349
|
2353
|
for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
|
2350
|
2354
|
{
|
2351
|
2355
|
if (sensitive_pins[i] == pin_number)
|
|
@@ -2354,28 +2358,28 @@ void process_commands()
|
2354
|
2358
|
break;
|
2355
|
2359
|
}
|
2356
|
2360
|
}
|
2357
|
|
-
|
|
2361
|
+
|
2358
|
2362
|
if (pin_number > -1)
|
2359
|
2363
|
{
|
2360
|
2364
|
st_synchronize();
|
2361
|
|
-
|
|
2365
|
+
|
2362
|
2366
|
pinMode(pin_number, INPUT);
|
2363
|
|
-
|
|
2367
|
+
|
2364
|
2368
|
int target;
|
2365
|
2369
|
switch(pin_state){
|
2366
|
2370
|
case 1:
|
2367
|
2371
|
target = HIGH;
|
2368
|
2372
|
break;
|
2369
|
|
-
|
|
2373
|
+
|
2370
|
2374
|
case 0:
|
2371
|
2375
|
target = LOW;
|
2372
|
2376
|
break;
|
2373
|
|
-
|
|
2377
|
+
|
2374
|
2378
|
case -1:
|
2375
|
2379
|
target = !digitalRead(pin_number);
|
2376
|
2380
|
break;
|
2377
|
2381
|
}
|
2378
|
|
-
|
|
2382
|
+
|
2379
|
2383
|
while(digitalRead(pin_number) != target){
|
2380
|
2384
|
manage_heater();
|
2381
|
2385
|
manage_inactivity();
|
|
@@ -2385,7 +2389,7 @@ void process_commands()
|
2385
|
2389
|
}
|
2386
|
2390
|
}
|
2387
|
2391
|
}
|
2388
|
|
- break;
|
|
2392
|
+ break;
|
2389
|
2393
|
|
2390
|
2394
|
#if NUM_SERVOS > 0
|
2391
|
2395
|
case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
|
@@ -2561,13 +2565,13 @@ void process_commands()
|
2561
|
2565
|
engage_z_probe(); // Engage Z Servo endstop if available
|
2562
|
2566
|
}
|
2563
|
2567
|
break;
|
2564
|
|
-
|
|
2568
|
+
|
2565
|
2569
|
case 402:
|
2566
|
2570
|
{
|
2567
|
2571
|
retract_z_probe(); // Retract Z Servo endstop if enabled
|
2568
|
2572
|
}
|
2569
|
2573
|
break;
|
2570
|
|
-#endif
|
|
2574
|
+#endif
|
2571
|
2575
|
case 500: // M500 Store settings in EEPROM
|
2572
|
2576
|
{
|
2573
|
2577
|
Config_StoreSettings();
|
|
@@ -2725,14 +2729,14 @@ void process_commands()
|
2725
|
2729
|
// M605 S0: Full control mode. The slicer has full control over x-carriage movement
|
2726
|
2730
|
// M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
|
2727
|
2731
|
// M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
|
2728
|
|
- // millimeters x-offset and an optional differential hotend temperature of
|
|
2732
|
+ // millimeters x-offset and an optional differential hotend temperature of
|
2729
|
2733
|
// mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
|
2730
|
2734
|
// the first with a spacing of 100mm in the x direction and 2 degrees hotter.
|
2731
|
2735
|
//
|
2732
|
2736
|
// Note: the X axis should be homed after changing dual x-carriage mode.
|
2733
|
2737
|
{
|
2734
|
2738
|
st_synchronize();
|
2735
|
|
-
|
|
2739
|
+
|
2736
|
2740
|
if (code_seen('S'))
|
2737
|
2741
|
dual_x_carriage_mode = code_value();
|
2738
|
2742
|
|
|
@@ -2743,7 +2747,7 @@ void process_commands()
|
2743
|
2747
|
|
2744
|
2748
|
if (code_seen('R'))
|
2745
|
2749
|
duplicate_extruder_temp_offset = code_value();
|
2746
|
|
-
|
|
2750
|
+
|
2747
|
2751
|
SERIAL_ECHO_START;
|
2748
|
2752
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
2749
|
2753
|
SERIAL_ECHO(" ");
|
|
@@ -2759,13 +2763,13 @@ void process_commands()
|
2759
|
2763
|
{
|
2760
|
2764
|
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
2761
|
2765
|
}
|
2762
|
|
-
|
|
2766
|
+
|
2763
|
2767
|
active_extruder_parked = false;
|
2764
|
2768
|
extruder_duplication_enabled = false;
|
2765
|
2769
|
delayed_move_time = 0;
|
2766
|
2770
|
}
|
2767
|
2771
|
break;
|
2768
|
|
- #endif //DUAL_X_CARRIAGE
|
|
2772
|
+ #endif //DUAL_X_CARRIAGE
|
2769
|
2773
|
|
2770
|
2774
|
case 907: // M907 Set digital trimpot motor current using axis codes.
|
2771
|
2775
|
{
|
|
@@ -2846,19 +2850,19 @@ void process_commands()
|
2846
|
2850
|
// Save current position to return to after applying extruder offset
|
2847
|
2851
|
memcpy(destination, current_position, sizeof(destination));
|
2848
|
2852
|
#ifdef DUAL_X_CARRIAGE
|
2849
|
|
- if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
|
2853
|
+ if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
2850
|
2854
|
(delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
|
2851
|
2855
|
{
|
2852
|
2856
|
// Park old head: 1) raise 2) move to park position 3) lower
|
2853
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
|
2857
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
2854
|
2858
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
2855
|
|
- plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
|
2859
|
+ plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
2856
|
2860
|
current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder);
|
2857
|
|
- plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
|
|
2861
|
+ plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
|
2858
|
2862
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
2859
|
2863
|
st_synchronize();
|
2860
|
2864
|
}
|
2861
|
|
-
|
|
2865
|
+
|
2862
|
2866
|
// apply Y & Z extruder offset (x offset is already used in determining home pos)
|
2863
|
2867
|
current_position[Y_AXIS] = current_position[Y_AXIS] -
|
2864
|
2868
|
extruder_offset[Y_AXIS][active_extruder] +
|
|
@@ -2866,7 +2870,7 @@ void process_commands()
|
2866
|
2870
|
current_position[Z_AXIS] = current_position[Z_AXIS] -
|
2867
|
2871
|
extruder_offset[Z_AXIS][active_extruder] +
|
2868
|
2872
|
extruder_offset[Z_AXIS][tmp_extruder];
|
2869
|
|
-
|
|
2873
|
+
|
2870
|
2874
|
active_extruder = tmp_extruder;
|
2871
|
2875
|
|
2872
|
2876
|
// This function resets the max/min values - the current position may be overwritten below.
|
|
@@ -2874,18 +2878,18 @@ void process_commands()
|
2874
|
2878
|
|
2875
|
2879
|
if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE)
|
2876
|
2880
|
{
|
2877
|
|
- current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
2881
|
+ current_position[X_AXIS] = inactive_extruder_x_pos;
|
2878
|
2882
|
inactive_extruder_x_pos = destination[X_AXIS];
|
2879
|
2883
|
}
|
2880
|
2884
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE)
|
2881
|
2885
|
{
|
2882
|
2886
|
active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
|
2883
|
2887
|
if (active_extruder == 0 || active_extruder_parked)
|
2884
|
|
- current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
2888
|
+ current_position[X_AXIS] = inactive_extruder_x_pos;
|
2885
|
2889
|
else
|
2886
|
|
- current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
|
|
2890
|
+ current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
|
2887
|
2891
|
inactive_extruder_x_pos = destination[X_AXIS];
|
2888
|
|
- extruder_duplication_enabled = false;
|
|
2892
|
+ extruder_duplication_enabled = false;
|
2889
|
2893
|
}
|
2890
|
2894
|
else
|
2891
|
2895
|
{
|
|
@@ -2895,7 +2899,7 @@ void process_commands()
|
2895
|
2899
|
active_extruder_parked = true;
|
2896
|
2900
|
delayed_move_time = 0;
|
2897
|
2901
|
}
|
2898
|
|
- #else
|
|
2902
|
+ #else
|
2899
|
2903
|
// Offset extruder (only by XY)
|
2900
|
2904
|
int i;
|
2901
|
2905
|
for(i = 0; i < 2; i++) {
|
|
@@ -3108,13 +3112,13 @@ void prepare_move()
|
3108
|
3112
|
{
|
3109
|
3113
|
// move duplicate extruder into correct duplication position.
|
3110
|
3114
|
plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
3111
|
|
- plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
|
3115
|
+ plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
3112
|
3116
|
current_position[E_AXIS], max_feedrate[X_AXIS], 1);
|
3113
|
3117
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
3114
|
3118
|
st_synchronize();
|
3115
|
3119
|
extruder_duplication_enabled = true;
|
3116
|
3120
|
active_extruder_parked = false;
|
3117
|
|
- }
|
|
3121
|
+ }
|
3118
|
3122
|
else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
|
3119
|
3123
|
{
|
3120
|
3124
|
if (current_position[E_AXIS] == destination[E_AXIS])
|
|
@@ -3123,7 +3127,7 @@ void prepare_move()
|
3123
|
3127
|
// be used as start of first non-travel move)
|
3124
|
3128
|
if (delayed_move_time != 0xFFFFFFFFUL)
|
3125
|
3129
|
{
|
3126
|
|
- memcpy(current_position, destination, sizeof(current_position));
|
|
3130
|
+ memcpy(current_position, destination, sizeof(current_position));
|
3127
|
3131
|
if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
|
3128
|
3132
|
raised_parked_position[Z_AXIS] = destination[Z_AXIS];
|
3129
|
3133
|
delayed_move_time = millis();
|
|
@@ -3133,9 +3137,9 @@ void prepare_move()
|
3133
|
3137
|
delayed_move_time = 0;
|
3134
|
3138
|
// unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
|
3135
|
3139
|
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);
|
3136
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
|
3140
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
3137
|
3141
|
current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
|
3138
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
|
3142
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
3139
|
3143
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
3140
|
3144
|
active_extruder_parked = false;
|
3141
|
3145
|
}
|
|
@@ -3301,7 +3305,7 @@ void manage_inactivity()
|
3301
|
3305
|
// travel moves have been received so enact them
|
3302
|
3306
|
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
|
3303
|
3307
|
memcpy(destination,current_position,sizeof(destination));
|
3304
|
|
- prepare_move();
|
|
3308
|
+ prepare_move();
|
3305
|
3309
|
}
|
3306
|
3310
|
#endif
|
3307
|
3311
|
#ifdef TEMP_STAT_LEDS
|