|
@@ -249,7 +249,7 @@ int EtoPPressure=0;
|
249
|
249
|
float delta[3] = {0.0, 0.0, 0.0};
|
250
|
250
|
#endif
|
251
|
251
|
|
252
|
|
-
|
|
252
|
+
|
253
|
253
|
//===========================================================================
|
254
|
254
|
//=============================private variables=============================
|
255
|
255
|
//===========================================================================
|
|
@@ -492,6 +492,10 @@ void setup()
|
492
|
492
|
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
|
493
|
493
|
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
|
494
|
494
|
#endif
|
|
495
|
+
|
|
496
|
+ #ifdef DIGIPOT_I2C
|
|
497
|
+ digipot_i2c_init();
|
|
498
|
+ #endif
|
495
|
499
|
}
|
496
|
500
|
|
497
|
501
|
|
|
@@ -789,7 +793,7 @@ static unsigned long delayed_move_time = 0; // used in mode 1
|
789
|
793
|
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
|
790
|
794
|
static float duplicate_extruder_temp_offset = 0; // used in mode 2
|
791
|
795
|
bool extruder_duplication_enabled = false; // used in mode 2
|
792
|
|
-#endif //DUAL_X_CARRIAGE
|
|
796
|
+#endif //DUAL_X_CARRIAGE
|
793
|
797
|
|
794
|
798
|
static void axis_is_at_home(int axis) {
|
795
|
799
|
#ifdef DUAL_X_CARRIAGE
|
|
@@ -802,8 +806,8 @@ static void axis_is_at_home(int axis) {
|
802
|
806
|
}
|
803
|
807
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
|
804
|
808
|
current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homeing[X_AXIS];
|
805
|
|
- min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homeing[X_AXIS];
|
806
|
|
- max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
|
|
809
|
+ min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homeing[X_AXIS];
|
|
810
|
+ max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
|
807
|
811
|
max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
|
808
|
812
|
return;
|
809
|
813
|
}
|
|
@@ -895,7 +899,7 @@ static void run_z_probe() {
|
895
|
899
|
st_synchronize();
|
896
|
900
|
|
897
|
901
|
// move back down slowly to find bed
|
898
|
|
- feedrate = homing_feedrate[Z_AXIS]/4;
|
|
902
|
+ feedrate = homing_feedrate[Z_AXIS]/4;
|
899
|
903
|
zPosition -= home_retract_mm(Z_AXIS) * 2;
|
900
|
904
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
|
901
|
905
|
st_synchronize();
|
|
@@ -992,7 +996,7 @@ static void homeaxis(int axis) {
|
992
|
996
|
|
993
|
997
|
current_position[axis] = 0;
|
994
|
998
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
995
|
|
-
|
|
999
|
+
|
996
|
1000
|
|
997
|
1001
|
// Engage Servo endstop if enabled
|
998
|
1002
|
#ifdef SERVO_ENDSTOPS
|
|
@@ -1050,7 +1054,7 @@ static void homeaxis(int axis) {
|
1050
|
1054
|
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
1051
|
1055
|
if (axis==Z_AXIS) retract_z_probe();
|
1052
|
1056
|
#endif
|
1053
|
|
-
|
|
1057
|
+
|
1054
|
1058
|
}
|
1055
|
1059
|
}
|
1056
|
1060
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
|
@@ -1124,7 +1128,7 @@ void process_commands()
|
1124
|
1128
|
destination[Y_AXIS]=current_position[Y_AXIS];
|
1125
|
1129
|
destination[Z_AXIS]=current_position[Z_AXIS];
|
1126
|
1130
|
current_position[Z_AXIS]+=retract_zlift;
|
1127
|
|
- destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
|
1131
|
+ destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
1128
|
1132
|
feedrate=retract_recover_feedrate;
|
1129
|
1133
|
retracted=false;
|
1130
|
1134
|
prepare_move();
|
|
@@ -1238,10 +1242,10 @@ void process_commands()
|
1238
|
1242
|
// reset state used by the different modes
|
1239
|
1243
|
memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
|
1240
|
1244
|
delayed_move_time = 0;
|
1241
|
|
- active_extruder_parked = true;
|
1242
|
|
- #else
|
|
1245
|
+ active_extruder_parked = true;
|
|
1246
|
+ #else
|
1243
|
1247
|
HOMEAXIS(X);
|
1244
|
|
- #endif
|
|
1248
|
+ #endif
|
1245
|
1249
|
}
|
1246
|
1250
|
|
1247
|
1251
|
if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
|
|
@@ -1260,7 +1264,7 @@ void process_commands()
|
1260
|
1264
|
current_position[Y_AXIS]=code_value()+add_homeing[1];
|
1261
|
1265
|
}
|
1262
|
1266
|
}
|
1263
|
|
-
|
|
1267
|
+
|
1264
|
1268
|
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
|
1265
|
1269
|
#ifndef Z_SAFE_HOMING
|
1266
|
1270
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -1272,14 +1276,14 @@ void process_commands()
|
1272
|
1276
|
#endif
|
1273
|
1277
|
HOMEAXIS(Z);
|
1274
|
1278
|
}
|
1275
|
|
- #else // Z Safe mode activated.
|
|
1279
|
+ #else // Z Safe mode activated.
|
1276
|
1280
|
if(home_all_axis) {
|
1277
|
1281
|
destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
|
1278
|
1282
|
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
|
1279
|
1283
|
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
|
1280
|
1284
|
feedrate = XY_TRAVEL_SPEED;
|
1281
|
1285
|
current_position[Z_AXIS] = 0;
|
1282
|
|
-
|
|
1286
|
+
|
1283
|
1287
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1284
|
1288
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
1285
|
1289
|
st_synchronize();
|
|
@@ -1297,7 +1301,7 @@ void process_commands()
|
1297
|
1301
|
&& (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
|
1298
|
1302
|
|
1299
|
1303
|
current_position[Z_AXIS] = 0;
|
1300
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1304
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1301
|
1305
|
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
|
1302
|
1306
|
feedrate = max_feedrate[Z_AXIS];
|
1303
|
1307
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
|
@@ -1317,8 +1321,8 @@ void process_commands()
|
1317
|
1321
|
#endif
|
1318
|
1322
|
#endif
|
1319
|
1323
|
|
1320
|
|
-
|
1321
|
|
-
|
|
1324
|
+
|
|
1325
|
+
|
1322
|
1326
|
if(code_seen(axis_codes[Z_AXIS])) {
|
1323
|
1327
|
if(code_value_long() != 0) {
|
1324
|
1328
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
|
@@ -1364,26 +1368,26 @@ void process_commands()
|
1364
|
1368
|
|
1365
|
1369
|
feedrate = homing_feedrate[Z_AXIS];
|
1366
|
1370
|
#ifdef ACCURATE_BED_LEVELING
|
1367
|
|
-
|
|
1371
|
+
|
1368
|
1372
|
int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
1369
|
1373
|
int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
1370
|
|
-
|
1371
|
|
-
|
|
1374
|
+
|
|
1375
|
+
|
1372
|
1376
|
// solve the plane equation ax + by + d = z
|
1373
|
1377
|
// A is the matrix with rows [x y 1] for all the probed points
|
1374
|
1378
|
// B is the vector of the Z positions
|
1375
|
1379
|
// the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
|
1376
|
1380
|
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
1377
|
|
-
|
|
1381
|
+
|
1378
|
1382
|
// "A" matrix of the linear system of equations
|
1379
|
1383
|
double eqnAMatrix[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS*3];
|
1380
|
1384
|
// "B" vector of Z points
|
1381
|
1385
|
double eqnBVector[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS];
|
1382
|
|
-
|
1383
|
|
-
|
|
1386
|
+
|
|
1387
|
+
|
1384
|
1388
|
int probePointCounter = 0;
|
1385
|
1389
|
bool zig = true;
|
1386
|
|
-
|
|
1390
|
+
|
1387
|
1391
|
for (int yProbe=FRONT_PROBE_BED_POSITION; yProbe <= BACK_PROBE_BED_POSITION; yProbe += yGridSpacing)
|
1388
|
1392
|
{
|
1389
|
1393
|
int xProbe, xInc;
|
|
@@ -1400,7 +1404,7 @@ void process_commands()
|
1400
|
1404
|
xInc = -xGridSpacing;
|
1401
|
1405
|
zig = true;
|
1402
|
1406
|
}
|
1403
|
|
-
|
|
1407
|
+
|
1404
|
1408
|
for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++)
|
1405
|
1409
|
{
|
1406
|
1410
|
if (probePointCounter == 0)
|
|
@@ -1408,19 +1412,19 @@ void process_commands()
|
1408
|
1412
|
// raise before probing
|
1409
|
1413
|
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING);
|
1410
|
1414
|
} else
|
1411
|
|
- {
|
|
1415
|
+ {
|
1412
|
1416
|
// raise extruder
|
1413
|
1417
|
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
1414
|
1418
|
}
|
1415
|
|
-
|
1416
|
|
-
|
|
1419
|
+
|
|
1420
|
+
|
1417
|
1421
|
do_blocking_move_to(xProbe - X_PROBE_OFFSET_FROM_EXTRUDER, yProbe - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
1418
|
|
-
|
|
1422
|
+
|
1419
|
1423
|
engage_z_probe(); // Engage Z Servo endstop if available
|
1420
|
1424
|
run_z_probe();
|
1421
|
1425
|
eqnBVector[probePointCounter] = current_position[Z_AXIS];
|
1422
|
1426
|
retract_z_probe();
|
1423
|
|
-
|
|
1427
|
+
|
1424
|
1428
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1425
|
1429
|
SERIAL_PROTOCOL(xProbe);
|
1426
|
1430
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1428,7 +1432,7 @@ void process_commands()
|
1428
|
1432
|
SERIAL_PROTOCOLPGM(" z: ");
|
1429
|
1433
|
SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
1430
|
1434
|
SERIAL_PROTOCOLPGM("\n");
|
1431
|
|
-
|
|
1435
|
+
|
1432
|
1436
|
eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe;
|
1433
|
1437
|
eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;
|
1434
|
1438
|
eqnAMatrix[probePointCounter + 2*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = 1;
|
|
@@ -1437,25 +1441,25 @@ void process_commands()
|
1437
|
1441
|
}
|
1438
|
1442
|
}
|
1439
|
1443
|
clean_up_after_endstop_move();
|
1440
|
|
-
|
|
1444
|
+
|
1441
|
1445
|
// solve lsq problem
|
1442
|
1446
|
double *plane_equation_coefficients = qr_solve(ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS, 3, eqnAMatrix, eqnBVector);
|
1443
|
|
-
|
|
1447
|
+
|
1444
|
1448
|
SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
1445
|
1449
|
SERIAL_PROTOCOL(plane_equation_coefficients[0]);
|
1446
|
1450
|
SERIAL_PROTOCOLPGM(" b: ");
|
1447
|
1451
|
SERIAL_PROTOCOL(plane_equation_coefficients[1]);
|
1448
|
1452
|
SERIAL_PROTOCOLPGM(" d: ");
|
1449
|
1453
|
SERIAL_PROTOCOLLN(plane_equation_coefficients[2]);
|
1450
|
|
-
|
1451
|
|
-
|
|
1454
|
+
|
|
1455
|
+
|
1452
|
1456
|
set_bed_level_equation_lsq(plane_equation_coefficients);
|
1453
|
|
-
|
|
1457
|
+
|
1454
|
1458
|
free(plane_equation_coefficients);
|
1455
|
|
-
|
|
1459
|
+
|
1456
|
1460
|
#else // ACCURATE_BED_LEVELING not defined
|
1457
|
|
-
|
1458
|
|
-
|
|
1461
|
+
|
|
1462
|
+
|
1459
|
1463
|
// prob 1
|
1460
|
1464
|
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING);
|
1461
|
1465
|
do_blocking_move_to(LEFT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, BACK_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
|
@@ -1481,7 +1485,7 @@ void process_commands()
|
1481
|
1485
|
run_z_probe();
|
1482
|
1486
|
float z_at_xLeft_yFront = current_position[Z_AXIS];
|
1483
|
1487
|
retract_z_probe();
|
1484
|
|
-
|
|
1488
|
+
|
1485
|
1489
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1486
|
1490
|
SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
|
1487
|
1491
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1499,7 +1503,7 @@ void process_commands()
|
1499
|
1503
|
run_z_probe();
|
1500
|
1504
|
float z_at_xRight_yFront = current_position[Z_AXIS];
|
1501
|
1505
|
retract_z_probe(); // Retract Z Servo endstop if available
|
1502
|
|
-
|
|
1506
|
+
|
1503
|
1507
|
SERIAL_PROTOCOLPGM("Bed x: ");
|
1504
|
1508
|
SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
|
1505
|
1509
|
SERIAL_PROTOCOLPGM(" y: ");
|
|
@@ -1511,13 +1515,13 @@ void process_commands()
|
1511
|
1515
|
clean_up_after_endstop_move();
|
1512
|
1516
|
|
1513
|
1517
|
set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
1514
|
|
-
|
1515
|
|
-
|
|
1518
|
+
|
|
1519
|
+
|
1516
|
1520
|
#endif // ACCURATE_BED_LEVELING
|
1517
|
|
- st_synchronize();
|
|
1521
|
+ st_synchronize();
|
1518
|
1522
|
|
1519
|
1523
|
// The following code correct the Z height difference from z-probe position and hotend tip position.
|
1520
|
|
- // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
|
1524
|
+ // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
1521
|
1525
|
// When the bed is uneven, this height must be corrected.
|
1522
|
1526
|
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)
|
1523
|
1527
|
x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
|
@@ -1529,11 +1533,11 @@ void process_commands()
|
1529
|
1533
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1530
|
1534
|
}
|
1531
|
1535
|
break;
|
1532
|
|
-
|
|
1536
|
+
|
1533
|
1537
|
case 30: // G30 Single Z Probe
|
1534
|
1538
|
{
|
1535
|
1539
|
engage_z_probe(); // Engage Z Servo endstop if available
|
1536
|
|
-
|
|
1540
|
+
|
1537
|
1541
|
st_synchronize();
|
1538
|
1542
|
// TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
|
1539
|
1543
|
setup_for_endstop_move();
|
|
@@ -1684,14 +1688,14 @@ void process_commands()
|
1684
|
1688
|
card.removeFile(strchr_pointer + 4);
|
1685
|
1689
|
}
|
1686
|
1690
|
break;
|
1687
|
|
- case 32: //M32 - Select file and start SD print
|
|
1691
|
+ case 32: //M32 - Select file and start SD print
|
1688
|
1692
|
{
|
1689
|
1693
|
if(card.sdprinting) {
|
1690
|
1694
|
st_synchronize();
|
1691
|
1695
|
|
1692
|
1696
|
}
|
1693
|
|
- starpos = (strchr(strchr_pointer + 4,'*'));
|
1694
|
|
-
|
|
1697
|
+ starpos = (strchr(strchr_pointer + 4,'*'));
|
|
1698
|
+
|
1695
|
1699
|
char* namestartpos = (strchr(strchr_pointer + 4,'!')); //find ! to indicate filename string start.
|
1696
|
1700
|
if(namestartpos==NULL)
|
1697
|
1701
|
{
|
|
@@ -1699,16 +1703,16 @@ void process_commands()
|
1699
|
1703
|
}
|
1700
|
1704
|
else
|
1701
|
1705
|
namestartpos++; //to skip the '!'
|
1702
|
|
-
|
|
1706
|
+
|
1703
|
1707
|
if(starpos!=NULL)
|
1704
|
1708
|
*(starpos-1)='\0';
|
1705
|
|
-
|
|
1709
|
+
|
1706
|
1710
|
bool call_procedure=(code_seen('P'));
|
1707
|
|
-
|
1708
|
|
- if(strchr_pointer>namestartpos)
|
|
1711
|
+
|
|
1712
|
+ if(strchr_pointer>namestartpos)
|
1709
|
1713
|
call_procedure=false; //false alert, 'P' found within filename
|
1710
|
|
-
|
1711
|
|
- if( card.cardOK )
|
|
1714
|
+
|
|
1715
|
+ if( card.cardOK )
|
1712
|
1716
|
{
|
1713
|
1717
|
card.openFile(namestartpos,true,!call_procedure);
|
1714
|
1718
|
if(code_seen('S'))
|
|
@@ -1781,7 +1785,7 @@ void process_commands()
|
1781
|
1785
|
#ifdef DUAL_X_CARRIAGE
|
1782
|
1786
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1783
|
1787
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1784
|
|
-#endif
|
|
1788
|
+#endif
|
1785
|
1789
|
setWatch();
|
1786
|
1790
|
break;
|
1787
|
1791
|
case 140: // M140 set bed temp
|
|
@@ -1847,7 +1851,7 @@ void process_commands()
|
1847
|
1851
|
SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
|
1848
|
1852
|
}
|
1849
|
1853
|
#endif
|
1850
|
|
-
|
|
1854
|
+
|
1851
|
1855
|
SERIAL_PROTOCOLLN("");
|
1852
|
1856
|
return;
|
1853
|
1857
|
break;
|
|
@@ -1865,14 +1869,14 @@ void process_commands()
|
1865
|
1869
|
#ifdef DUAL_X_CARRIAGE
|
1866
|
1870
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1867
|
1871
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1868
|
|
-#endif
|
|
1872
|
+#endif
|
1869
|
1873
|
CooldownNoWait = true;
|
1870
|
1874
|
} else if (code_seen('R')) {
|
1871
|
1875
|
setTargetHotend(code_value(), tmp_extruder);
|
1872
|
1876
|
#ifdef DUAL_X_CARRIAGE
|
1873
|
1877
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
|
1874
|
1878
|
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
|
1875
|
|
-#endif
|
|
1879
|
+#endif
|
1876
|
1880
|
CooldownNoWait = false;
|
1877
|
1881
|
}
|
1878
|
1882
|
#ifdef AUTOTEMP
|
|
@@ -2036,7 +2040,7 @@ void process_commands()
|
2036
|
2040
|
SET_OUTPUT(SUICIDE_PIN);
|
2037
|
2041
|
WRITE(SUICIDE_PIN, HIGH);
|
2038
|
2042
|
#endif
|
2039
|
|
-
|
|
2043
|
+
|
2040
|
2044
|
#ifdef ULTIPANEL
|
2041
|
2045
|
powersupply = true;
|
2042
|
2046
|
LCD_MESSAGEPGM(WELCOME_MSG);
|
|
@@ -2193,18 +2197,18 @@ void process_commands()
|
2193
|
2197
|
#endif
|
2194
|
2198
|
break;
|
2195
|
2199
|
//TODO: update for all axis, use for loop
|
2196
|
|
- #ifdef BLINKM
|
|
2200
|
+ #ifdef BLINKM
|
2197
|
2201
|
case 150: // M150
|
2198
|
2202
|
{
|
2199
|
2203
|
byte red;
|
2200
|
2204
|
byte grn;
|
2201
|
2205
|
byte blu;
|
2202
|
|
-
|
|
2206
|
+
|
2203
|
2207
|
if(code_seen('R')) red = code_value();
|
2204
|
2208
|
if(code_seen('U')) grn = code_value();
|
2205
|
2209
|
if(code_seen('B')) blu = code_value();
|
2206
|
|
-
|
2207
|
|
- SendColors(red,grn,blu);
|
|
2210
|
+
|
|
2211
|
+ SendColors(red,grn,blu);
|
2208
|
2212
|
}
|
2209
|
2213
|
break;
|
2210
|
2214
|
#endif //BLINKM
|
|
@@ -2354,7 +2358,7 @@ void process_commands()
|
2354
|
2358
|
{
|
2355
|
2359
|
extruder_offset[Z_AXIS][tmp_extruder] = code_value();
|
2356
|
2360
|
}
|
2357
|
|
- #endif
|
|
2361
|
+ #endif
|
2358
|
2362
|
SERIAL_ECHO_START;
|
2359
|
2363
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
2360
|
2364
|
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
|
|
@@ -2387,17 +2391,17 @@ void process_commands()
|
2387
|
2391
|
}
|
2388
|
2392
|
}
|
2389
|
2393
|
break;
|
2390
|
|
-
|
|
2394
|
+
|
2391
|
2395
|
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
|
2392
|
2396
|
{
|
2393
|
2397
|
if(code_seen('P')){
|
2394
|
2398
|
int pin_number = code_value(); // pin number
|
2395
|
2399
|
int pin_state = -1; // required pin state - default is inverted
|
2396
|
|
-
|
|
2400
|
+
|
2397
|
2401
|
if(code_seen('S')) pin_state = code_value(); // required pin state
|
2398
|
|
-
|
|
2402
|
+
|
2399
|
2403
|
if(pin_state >= -1 && pin_state <= 1){
|
2400
|
|
-
|
|
2404
|
+
|
2401
|
2405
|
for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
|
2402
|
2406
|
{
|
2403
|
2407
|
if (sensitive_pins[i] == pin_number)
|
|
@@ -2406,28 +2410,28 @@ void process_commands()
|
2406
|
2410
|
break;
|
2407
|
2411
|
}
|
2408
|
2412
|
}
|
2409
|
|
-
|
|
2413
|
+
|
2410
|
2414
|
if (pin_number > -1)
|
2411
|
2415
|
{
|
2412
|
2416
|
st_synchronize();
|
2413
|
|
-
|
|
2417
|
+
|
2414
|
2418
|
pinMode(pin_number, INPUT);
|
2415
|
|
-
|
|
2419
|
+
|
2416
|
2420
|
int target;
|
2417
|
2421
|
switch(pin_state){
|
2418
|
2422
|
case 1:
|
2419
|
2423
|
target = HIGH;
|
2420
|
2424
|
break;
|
2421
|
|
-
|
|
2425
|
+
|
2422
|
2426
|
case 0:
|
2423
|
2427
|
target = LOW;
|
2424
|
2428
|
break;
|
2425
|
|
-
|
|
2429
|
+
|
2426
|
2430
|
case -1:
|
2427
|
2431
|
target = !digitalRead(pin_number);
|
2428
|
2432
|
break;
|
2429
|
2433
|
}
|
2430
|
|
-
|
|
2434
|
+
|
2431
|
2435
|
while(digitalRead(pin_number) != target){
|
2432
|
2436
|
manage_heater();
|
2433
|
2437
|
manage_inactivity();
|
|
@@ -2437,7 +2441,7 @@ void process_commands()
|
2437
|
2441
|
}
|
2438
|
2442
|
}
|
2439
|
2443
|
}
|
2440
|
|
- break;
|
|
2444
|
+ break;
|
2441
|
2445
|
|
2442
|
2446
|
#if NUM_SERVOS > 0
|
2443
|
2447
|
case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
|
@@ -2615,13 +2619,13 @@ void process_commands()
|
2615
|
2619
|
engage_z_probe(); // Engage Z Servo endstop if available
|
2616
|
2620
|
}
|
2617
|
2621
|
break;
|
2618
|
|
-
|
|
2622
|
+
|
2619
|
2623
|
case 402:
|
2620
|
2624
|
{
|
2621
|
2625
|
retract_z_probe(); // Retract Z Servo endstop if enabled
|
2622
|
2626
|
}
|
2623
|
2627
|
break;
|
2624
|
|
-#endif
|
|
2628
|
+#endif
|
2625
|
2629
|
case 500: // M500 Store settings in EEPROM
|
2626
|
2630
|
{
|
2627
|
2631
|
Config_StoreSettings();
|
|
@@ -2783,14 +2787,14 @@ void process_commands()
|
2783
|
2787
|
// M605 S0: Full control mode. The slicer has full control over x-carriage movement
|
2784
|
2788
|
// M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
|
2785
|
2789
|
// M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
|
2786
|
|
- // millimeters x-offset and an optional differential hotend temperature of
|
|
2790
|
+ // millimeters x-offset and an optional differential hotend temperature of
|
2787
|
2791
|
// mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
|
2788
|
2792
|
// the first with a spacing of 100mm in the x direction and 2 degrees hotter.
|
2789
|
2793
|
//
|
2790
|
2794
|
// Note: the X axis should be homed after changing dual x-carriage mode.
|
2791
|
2795
|
{
|
2792
|
2796
|
st_synchronize();
|
2793
|
|
-
|
|
2797
|
+
|
2794
|
2798
|
if (code_seen('S'))
|
2795
|
2799
|
dual_x_carriage_mode = code_value();
|
2796
|
2800
|
|
|
@@ -2801,7 +2805,7 @@ void process_commands()
|
2801
|
2805
|
|
2802
|
2806
|
if (code_seen('R'))
|
2803
|
2807
|
duplicate_extruder_temp_offset = code_value();
|
2804
|
|
-
|
|
2808
|
+
|
2805
|
2809
|
SERIAL_ECHO_START;
|
2806
|
2810
|
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
2807
|
2811
|
SERIAL_ECHO(" ");
|
|
@@ -2817,13 +2821,13 @@ void process_commands()
|
2817
|
2821
|
{
|
2818
|
2822
|
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
2819
|
2823
|
}
|
2820
|
|
-
|
|
2824
|
+
|
2821
|
2825
|
active_extruder_parked = false;
|
2822
|
2826
|
extruder_duplication_enabled = false;
|
2823
|
2827
|
delayed_move_time = 0;
|
2824
|
2828
|
}
|
2825
|
2829
|
break;
|
2826
|
|
- #endif //DUAL_X_CARRIAGE
|
|
2830
|
+ #endif //DUAL_X_CARRIAGE
|
2827
|
2831
|
|
2828
|
2832
|
case 907: // M907 Set digital trimpot motor current using axis codes.
|
2829
|
2833
|
{
|
|
@@ -2841,6 +2845,12 @@ void process_commands()
|
2841
|
2845
|
#ifdef MOTOR_CURRENT_PWM_E_PIN
|
2842
|
2846
|
if(code_seen('E')) digipot_current(2, code_value());
|
2843
|
2847
|
#endif
|
|
2848
|
+ #ifdef DIGIPOT_I2C
|
|
2849
|
+ // this one uses actual amps in floating point
|
|
2850
|
+ for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_i2c_set_current(i, code_value());
|
|
2851
|
+ // for each additional extruder (named B,C,D,E..., channels 4,5,6,7...)
|
|
2852
|
+ for(int i=NUM_AXIS;i<DIGIPOT_I2C_NUM_CHANNELS;i++) if(code_seen('B'+i-NUM_AXIS)) digipot_i2c_set_current(i, code_value());
|
|
2853
|
+ #endif
|
2844
|
2854
|
}
|
2845
|
2855
|
break;
|
2846
|
2856
|
case 908: // M908 Control digital trimpot directly.
|
|
@@ -2913,19 +2923,19 @@ void process_commands()
|
2913
|
2923
|
// Save current position to return to after applying extruder offset
|
2914
|
2924
|
memcpy(destination, current_position, sizeof(destination));
|
2915
|
2925
|
#ifdef DUAL_X_CARRIAGE
|
2916
|
|
- if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
|
2926
|
+ if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
2917
|
2927
|
(delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
|
2918
|
2928
|
{
|
2919
|
2929
|
// Park old head: 1) raise 2) move to park position 3) lower
|
2920
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
|
2930
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
2921
|
2931
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
2922
|
|
- plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
|
2932
|
+ plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
|
2923
|
2933
|
current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder);
|
2924
|
|
- plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
|
|
2934
|
+ plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
|
2925
|
2935
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
2926
|
2936
|
st_synchronize();
|
2927
|
2937
|
}
|
2928
|
|
-
|
|
2938
|
+
|
2929
|
2939
|
// apply Y & Z extruder offset (x offset is already used in determining home pos)
|
2930
|
2940
|
current_position[Y_AXIS] = current_position[Y_AXIS] -
|
2931
|
2941
|
extruder_offset[Y_AXIS][active_extruder] +
|
|
@@ -2933,7 +2943,7 @@ void process_commands()
|
2933
|
2943
|
current_position[Z_AXIS] = current_position[Z_AXIS] -
|
2934
|
2944
|
extruder_offset[Z_AXIS][active_extruder] +
|
2935
|
2945
|
extruder_offset[Z_AXIS][tmp_extruder];
|
2936
|
|
-
|
|
2946
|
+
|
2937
|
2947
|
active_extruder = tmp_extruder;
|
2938
|
2948
|
|
2939
|
2949
|
// This function resets the max/min values - the current position may be overwritten below.
|
|
@@ -2941,18 +2951,18 @@ void process_commands()
|
2941
|
2951
|
|
2942
|
2952
|
if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE)
|
2943
|
2953
|
{
|
2944
|
|
- current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
2954
|
+ current_position[X_AXIS] = inactive_extruder_x_pos;
|
2945
|
2955
|
inactive_extruder_x_pos = destination[X_AXIS];
|
2946
|
2956
|
}
|
2947
|
2957
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE)
|
2948
|
2958
|
{
|
2949
|
2959
|
active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
|
2950
|
2960
|
if (active_extruder == 0 || active_extruder_parked)
|
2951
|
|
- current_position[X_AXIS] = inactive_extruder_x_pos;
|
|
2961
|
+ current_position[X_AXIS] = inactive_extruder_x_pos;
|
2952
|
2962
|
else
|
2953
|
|
- current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
|
|
2963
|
+ current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
|
2954
|
2964
|
inactive_extruder_x_pos = destination[X_AXIS];
|
2955
|
|
- extruder_duplication_enabled = false;
|
|
2965
|
+ extruder_duplication_enabled = false;
|
2956
|
2966
|
}
|
2957
|
2967
|
else
|
2958
|
2968
|
{
|
|
@@ -2962,7 +2972,7 @@ void process_commands()
|
2962
|
2972
|
active_extruder_parked = true;
|
2963
|
2973
|
delayed_move_time = 0;
|
2964
|
2974
|
}
|
2965
|
|
- #else
|
|
2975
|
+ #else
|
2966
|
2976
|
// Offset extruder (only by XY)
|
2967
|
2977
|
int i;
|
2968
|
2978
|
for(i = 0; i < 2; i++) {
|
|
@@ -3175,13 +3185,13 @@ void prepare_move()
|
3175
|
3185
|
{
|
3176
|
3186
|
// move duplicate extruder into correct duplication position.
|
3177
|
3187
|
plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
3178
|
|
- plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
|
3188
|
+ plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
3179
|
3189
|
current_position[E_AXIS], max_feedrate[X_AXIS], 1);
|
3180
|
3190
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
3181
|
3191
|
st_synchronize();
|
3182
|
3192
|
extruder_duplication_enabled = true;
|
3183
|
3193
|
active_extruder_parked = false;
|
3184
|
|
- }
|
|
3194
|
+ }
|
3185
|
3195
|
else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
|
3186
|
3196
|
{
|
3187
|
3197
|
if (current_position[E_AXIS] == destination[E_AXIS])
|
|
@@ -3190,7 +3200,7 @@ void prepare_move()
|
3190
|
3200
|
// be used as start of first non-travel move)
|
3191
|
3201
|
if (delayed_move_time != 0xFFFFFFFFUL)
|
3192
|
3202
|
{
|
3193
|
|
- memcpy(current_position, destination, sizeof(current_position));
|
|
3203
|
+ memcpy(current_position, destination, sizeof(current_position));
|
3194
|
3204
|
if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
|
3195
|
3205
|
raised_parked_position[Z_AXIS] = destination[Z_AXIS];
|
3196
|
3206
|
delayed_move_time = millis();
|
|
@@ -3200,9 +3210,9 @@ void prepare_move()
|
3200
|
3210
|
delayed_move_time = 0;
|
3201
|
3211
|
// unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
|
3202
|
3212
|
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);
|
3203
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
|
3213
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
3204
|
3214
|
current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
|
3205
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
|
3215
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
3206
|
3216
|
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
3207
|
3217
|
active_extruder_parked = false;
|
3208
|
3218
|
}
|
|
@@ -3350,8 +3360,8 @@ void manage_inactivity()
|
3350
|
3360
|
enable_e0();
|
3351
|
3361
|
float oldepos=current_position[E_AXIS];
|
3352
|
3362
|
float oldedes=destination[E_AXIS];
|
3353
|
|
- plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS],
|
3354
|
|
- destination[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS],
|
|
3363
|
+ plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS],
|
|
3364
|
+ destination[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS],
|
3355
|
3365
|
EXTRUDER_RUNOUT_SPEED/60.*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], active_extruder);
|
3356
|
3366
|
current_position[E_AXIS]=oldepos;
|
3357
|
3367
|
destination[E_AXIS]=oldedes;
|
|
@@ -3368,7 +3378,7 @@ void manage_inactivity()
|
3368
|
3378
|
// travel moves have been received so enact them
|
3369
|
3379
|
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
|
3370
|
3380
|
memcpy(destination,current_position,sizeof(destination));
|
3371
|
|
- prepare_move();
|
|
3381
|
+ prepare_move();
|
3372
|
3382
|
}
|
3373
|
3383
|
#endif
|
3374
|
3384
|
#ifdef TEMP_STAT_LEDS
|