|
@@ -1009,6 +1009,8 @@ inline void sync_plan_position() {
|
1009
|
1009
|
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
|
1010
|
1010
|
}
|
1011
|
1011
|
#endif
|
|
1012
|
+inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
|
|
1013
|
+inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
|
1012
|
1014
|
|
1013
|
1015
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
1014
|
1016
|
|
|
@@ -1020,7 +1022,7 @@ inline void sync_plan_position() {
|
1020
|
1022
|
refresh_cmd_timeout();
|
1021
|
1023
|
calculate_delta(destination);
|
1022
|
1024
|
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
|
1023
|
|
- for (int i = 0; i < NUM_AXIS; i++) current_position[i] = destination[i];
|
|
1025
|
+ set_current_to_destination();
|
1024
|
1026
|
}
|
1025
|
1027
|
#endif
|
1026
|
1028
|
|
|
@@ -1564,7 +1566,7 @@ static void homeaxis(int axis) {
|
1564
|
1566
|
|
1565
|
1567
|
float oldFeedrate = feedrate;
|
1566
|
1568
|
|
1567
|
|
- for (int i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i];
|
|
1569
|
+ set_destination_to_current();
|
1568
|
1570
|
|
1569
|
1571
|
if (retracting) {
|
1570
|
1572
|
|
|
@@ -1769,7 +1771,7 @@ inline void gcode_G28() {
|
1769
|
1771
|
|
1770
|
1772
|
enable_endstops(true);
|
1771
|
1773
|
|
1772
|
|
- for (int i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i]; // includes E_AXIS
|
|
1774
|
+ set_destination_to_current();
|
1773
|
1775
|
|
1774
|
1776
|
feedrate = 0.0;
|
1775
|
1777
|
|
|
@@ -1997,7 +1999,7 @@ inline void gcode_G28() {
|
1997
|
1999
|
if (mbl_was_active) {
|
1998
|
2000
|
current_position[X_AXIS] = mbl.get_x(0);
|
1999
|
2001
|
current_position[Y_AXIS] = mbl.get_y(0);
|
2000
|
|
- for (int i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i];
|
|
2002
|
+ set_destination_to_current();
|
2001
|
2003
|
feedrate = homing_feedrate[X_AXIS];
|
2002
|
2004
|
line_to_destination();
|
2003
|
2005
|
st_synchronize();
|
|
@@ -4613,7 +4615,7 @@ inline void gcode_T() {
|
4613
|
4615
|
#if EXTRUDERS > 1
|
4614
|
4616
|
if (tmp_extruder != active_extruder) {
|
4615
|
4617
|
// Save current position to return to after applying extruder offset
|
4616
|
|
- memcpy(destination, current_position, sizeof(destination));
|
|
4618
|
+ set_destination_to_current();
|
4617
|
4619
|
#ifdef DUAL_X_CARRIAGE
|
4618
|
4620
|
if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
|
4619
|
4621
|
(delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder))) {
|
|
@@ -5338,9 +5340,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
5338
|
5340
|
{
|
5339
|
5341
|
if (!mbl.active) {
|
5340
|
5342
|
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
5341
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
5342
|
|
- current_position[i] = destination[i];
|
5343
|
|
- }
|
|
5343
|
+ set_current_to_destination();
|
5344
|
5344
|
return;
|
5345
|
5345
|
}
|
5346
|
5346
|
int pix = mbl.select_x_index(current_position[X_AXIS]);
|
|
@@ -5354,9 +5354,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
5354
|
5354
|
if (pix == ix && piy == iy) {
|
5355
|
5355
|
// Start and end on same mesh square
|
5356
|
5356
|
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
5357
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
5358
|
|
- current_position[i] = destination[i];
|
5359
|
|
- }
|
|
5357
|
+ set_current_to_destination();
|
5360
|
5358
|
return;
|
5361
|
5359
|
}
|
5362
|
5360
|
float nx, ny, ne, normalized_dist;
|
|
@@ -5387,9 +5385,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
5387
|
5385
|
} else {
|
5388
|
5386
|
// Already split on a border
|
5389
|
5387
|
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
5390
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
5391
|
|
- current_position[i] = destination[i];
|
5392
|
|
- }
|
|
5388
|
+ set_current_to_destination();
|
5393
|
5389
|
return;
|
5394
|
5390
|
}
|
5395
|
5391
|
// Do the split and look for more borders
|
|
@@ -5477,64 +5473,58 @@ void prepare_move() {
|
5477
|
5473
|
|
5478
|
5474
|
#endif // DELTA
|
5479
|
5475
|
|
5480
|
|
-#ifdef DUAL_X_CARRIAGE
|
5481
|
|
- if (active_extruder_parked)
|
5482
|
|
- {
|
5483
|
|
- if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0)
|
5484
|
|
- {
|
5485
|
|
- // move duplicate extruder into correct duplication position.
|
5486
|
|
- plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
5487
|
|
- plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
5488
|
|
- current_position[E_AXIS], max_feedrate[X_AXIS], 1);
|
5489
|
|
- sync_plan_position();
|
5490
|
|
- st_synchronize();
|
5491
|
|
- extruder_duplication_enabled = true;
|
5492
|
|
- active_extruder_parked = false;
|
5493
|
|
- }
|
5494
|
|
- else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
|
5495
|
|
- {
|
5496
|
|
- if (current_position[E_AXIS] == destination[E_AXIS])
|
5497
|
|
- {
|
5498
|
|
- // this is a travel move - skit it but keep track of current position (so that it can later
|
5499
|
|
- // be used as start of first non-travel move)
|
5500
|
|
- if (delayed_move_time != 0xFFFFFFFFUL)
|
5501
|
|
- {
|
5502
|
|
- memcpy(current_position, destination, sizeof(current_position));
|
5503
|
|
- if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
|
5504
|
|
- raised_parked_position[Z_AXIS] = destination[Z_AXIS];
|
5505
|
|
- delayed_move_time = millis();
|
5506
|
|
- return;
|
|
5476
|
+ #ifdef DUAL_X_CARRIAGE
|
|
5477
|
+ if (active_extruder_parked) {
|
|
5478
|
+ if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
|
|
5479
|
+ // move duplicate extruder into correct duplication position.
|
|
5480
|
+ plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
5481
|
+ plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
|
|
5482
|
+ current_position[E_AXIS], max_feedrate[X_AXIS], 1);
|
|
5483
|
+ sync_plan_position();
|
|
5484
|
+ st_synchronize();
|
|
5485
|
+ extruder_duplication_enabled = true;
|
|
5486
|
+ active_extruder_parked = false;
|
|
5487
|
+ }
|
|
5488
|
+ else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) { // handle unparking of head
|
|
5489
|
+ if (current_position[E_AXIS] == destination[E_AXIS]) {
|
|
5490
|
+ // this is a travel move - skit it but keep track of current position (so that it can later
|
|
5491
|
+ // be used as start of first non-travel move)
|
|
5492
|
+ if (delayed_move_time != 0xFFFFFFFFUL) {
|
|
5493
|
+ set_current_to_destination();
|
|
5494
|
+ if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
|
|
5495
|
+ raised_parked_position[Z_AXIS] = destination[Z_AXIS];
|
|
5496
|
+ delayed_move_time = millis();
|
|
5497
|
+ return;
|
|
5498
|
+ }
|
5507
|
5499
|
}
|
|
5500
|
+ delayed_move_time = 0;
|
|
5501
|
+ // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
|
|
5502
|
+ 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);
|
|
5503
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
|
5504
|
+ current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
|
|
5505
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
|
5506
|
+ current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
|
5507
|
+ active_extruder_parked = false;
|
5508
|
5508
|
}
|
5509
|
|
- delayed_move_time = 0;
|
5510
|
|
- // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
|
5511
|
|
- 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);
|
5512
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
|
5513
|
|
- current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
|
5514
|
|
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
|
5515
|
|
- current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
|
5516
|
|
- active_extruder_parked = false;
|
5517
|
5509
|
}
|
5518
|
|
- }
|
5519
|
|
-#endif //DUAL_X_CARRIAGE
|
|
5510
|
+ #endif // DUAL_X_CARRIAGE
|
5520
|
5511
|
|
5521
|
|
-#if !defined(DELTA) && !defined(SCARA)
|
5522
|
|
- // Do not use feedmultiply for E or Z only moves
|
5523
|
|
- if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
|
5524
|
|
- line_to_destination();
|
5525
|
|
- } else {
|
5526
|
|
-#ifdef MESH_BED_LEVELING
|
5527
|
|
- mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
|
5528
|
|
- return;
|
5529
|
|
-#else
|
5530
|
|
- plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
|
5531
|
|
-#endif // MESH_BED_LEVELING
|
5532
|
|
- }
|
5533
|
|
-#endif // !(DELTA || SCARA)
|
|
5512
|
+ #if !defined(DELTA) && !defined(SCARA)
|
|
5513
|
+ // Do not use feedmultiply for E or Z only moves
|
|
5514
|
+ if ( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
|
|
5515
|
+ line_to_destination();
|
|
5516
|
+ }
|
|
5517
|
+ else {
|
|
5518
|
+ #ifdef MESH_BED_LEVELING
|
|
5519
|
+ mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
|
|
5520
|
+ return;
|
|
5521
|
+ #else
|
|
5522
|
+ plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
|
|
5523
|
+ #endif // MESH_BED_LEVELING
|
|
5524
|
+ }
|
|
5525
|
+ #endif // !(DELTA || SCARA)
|
5534
|
5526
|
|
5535
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
5536
|
|
- current_position[i] = destination[i];
|
5537
|
|
- }
|
|
5527
|
+ set_current_to_destination();
|
5538
|
5528
|
}
|
5539
|
5529
|
|
5540
|
5530
|
void prepare_arc_move(char isclockwise) {
|
|
@@ -5546,9 +5536,7 @@ void prepare_arc_move(char isclockwise) {
|
5546
|
5536
|
// As far as the parser is concerned, the position is now == target. In reality the
|
5547
|
5537
|
// motion control system might still be processing the action and the real tool position
|
5548
|
5538
|
// in any intermediate location.
|
5549
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
5550
|
|
- current_position[i] = destination[i];
|
5551
|
|
- }
|
|
5539
|
+ set_current_to_destination();
|
5552
|
5540
|
refresh_cmd_timeout();
|
5553
|
5541
|
}
|
5554
|
5542
|
|
|
@@ -5718,7 +5706,16 @@ void disable_all_steppers() {
|
5718
|
5706
|
}
|
5719
|
5707
|
|
5720
|
5708
|
/**
|
5721
|
|
- *
|
|
5709
|
+ * Manage several activities:
|
|
5710
|
+ * - Check for Filament Runout
|
|
5711
|
+ * - Keep the command buffer full
|
|
5712
|
+ * - Check for maximum inactive time between commands
|
|
5713
|
+ * - Check for maximum inactive time between stepper commands
|
|
5714
|
+ * - Check if pin CHDK needs to go LOW
|
|
5715
|
+ * - Check for KILL button held down
|
|
5716
|
+ * - Check for HOME button held down
|
|
5717
|
+ * - Check if cooling fan needs to be switched on
|
|
5718
|
+ * - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
|
5722
|
5719
|
*/
|
5723
|
5720
|
void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5724
|
5721
|
|
|
@@ -5737,7 +5734,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5737
|
5734
|
&& !ignore_stepper_queue && !blocks_queued())
|
5738
|
5735
|
disable_all_steppers();
|
5739
|
5736
|
|
5740
|
|
- #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
|
|
5737
|
+ #ifdef CHDK // Check if pin should be set to LOW after M240 set it to HIGH
|
5741
|
5738
|
if (chdkActive && ms > chdkHigh + CHDK_DELAY) {
|
5742
|
5739
|
chdkActive = false;
|
5743
|
5740
|
WRITE(CHDK, LOW);
|
|
@@ -5780,14 +5777,37 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5780
|
5777
|
#endif
|
5781
|
5778
|
|
5782
|
5779
|
#if HAS_CONTROLLERFAN
|
5783
|
|
- controllerFan(); //Check if fan should be turned on to cool stepper drivers down
|
|
5780
|
+ controllerFan(); // Check if fan should be turned on to cool stepper drivers down
|
5784
|
5781
|
#endif
|
5785
|
5782
|
|
5786
|
5783
|
#ifdef EXTRUDER_RUNOUT_PREVENT
|
5787
|
5784
|
if (ms > previous_millis_cmd + EXTRUDER_RUNOUT_SECONDS * 1000)
|
5788
|
5785
|
if (degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) {
|
5789
|
|
- bool oldstatus = E0_ENABLE_READ;
|
5790
|
|
- enable_e0();
|
|
5786
|
+ bool oldstatus;
|
|
5787
|
+ switch(active_extruder) {
|
|
5788
|
+ case 0:
|
|
5789
|
+ oldstatus = E0_ENABLE_READ;
|
|
5790
|
+ enable_e0();
|
|
5791
|
+ break;
|
|
5792
|
+ #if EXTRUDERS > 1
|
|
5793
|
+ case 1:
|
|
5794
|
+ oldstatus = E1_ENABLE_READ;
|
|
5795
|
+ enable_e1();
|
|
5796
|
+ break;
|
|
5797
|
+ #if EXTRUDERS > 2
|
|
5798
|
+ case 2:
|
|
5799
|
+ oldstatus = E2_ENABLE_READ;
|
|
5800
|
+ enable_e2();
|
|
5801
|
+ break;
|
|
5802
|
+ #if EXTRUDERS > 3
|
|
5803
|
+ case 3:
|
|
5804
|
+ oldstatus = E3_ENABLE_READ;
|
|
5805
|
+ enable_e3();
|
|
5806
|
+ break;
|
|
5807
|
+ #endif
|
|
5808
|
+ #endif
|
|
5809
|
+ #endif
|
|
5810
|
+ }
|
5791
|
5811
|
float oldepos = current_position[E_AXIS], oldedes = destination[E_AXIS];
|
5792
|
5812
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS],
|
5793
|
5813
|
destination[E_AXIS] + EXTRUDER_RUNOUT_EXTRUDE * EXTRUDER_RUNOUT_ESTEPS / axis_steps_per_unit[E_AXIS],
|
|
@@ -5797,7 +5817,26 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5797
|
5817
|
plan_set_e_position(oldepos);
|
5798
|
5818
|
previous_millis_cmd = ms; // refresh_cmd_timeout()
|
5799
|
5819
|
st_synchronize();
|
5800
|
|
- E0_ENABLE_WRITE(oldstatus);
|
|
5820
|
+ switch(active_extruder) {
|
|
5821
|
+ case 0:
|
|
5822
|
+ E0_ENABLE_WRITE(oldstatus);
|
|
5823
|
+ break;
|
|
5824
|
+ #if EXTRUDERS > 1
|
|
5825
|
+ case 1:
|
|
5826
|
+ E1_ENABLE_WRITE(oldstatus);
|
|
5827
|
+ break;
|
|
5828
|
+ #if EXTRUDERS > 2
|
|
5829
|
+ case 2:
|
|
5830
|
+ E2_ENABLE_WRITE(oldstatus);
|
|
5831
|
+ break;
|
|
5832
|
+ #if EXTRUDERS > 3
|
|
5833
|
+ case 3:
|
|
5834
|
+ E3_ENABLE_WRITE(oldstatus);
|
|
5835
|
+ break;
|
|
5836
|
+ #endif
|
|
5837
|
+ #endif
|
|
5838
|
+ #endif
|
|
5839
|
+ }
|
5801
|
5840
|
}
|
5802
|
5841
|
#endif
|
5803
|
5842
|
|
|
@@ -5806,7 +5845,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5806
|
5845
|
if (delayed_move_time && ms > delayed_move_time + 1000 && !Stopped) {
|
5807
|
5846
|
// travel moves have been received so enact them
|
5808
|
5847
|
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
|
5809
|
|
- memcpy(destination, current_position, sizeof(destination));
|
|
5848
|
+ set_destination_to_current();
|
5810
|
5849
|
prepare_move();
|
5811
|
5850
|
}
|
5812
|
5851
|
#endif
|