|
@@ -1657,7 +1657,7 @@ static void homeaxis(AxisEnum axis) {
|
1657
|
1657
|
|
1658
|
1658
|
#ifdef FWRETRACT
|
1659
|
1659
|
|
1660
|
|
- void retract(bool retracting, bool swapretract = false) {
|
|
1660
|
+ void retract(bool retracting, bool swapping=false) {
|
1661
|
1661
|
|
1662
|
1662
|
if (retracting == retracted[active_extruder]) return;
|
1663
|
1663
|
|
|
@@ -1668,7 +1668,7 @@ static void homeaxis(AxisEnum axis) {
|
1668
|
1668
|
if (retracting) {
|
1669
|
1669
|
|
1670
|
1670
|
feedrate = retract_feedrate * 60;
|
1671
|
|
- current_position[E_AXIS] += (swapretract ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder];
|
|
1671
|
+ current_position[E_AXIS] += (swapping ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder];
|
1672
|
1672
|
plan_set_e_position(current_position[E_AXIS]);
|
1673
|
1673
|
prepare_move();
|
1674
|
1674
|
|
|
@@ -1695,7 +1695,7 @@ static void homeaxis(AxisEnum axis) {
|
1695
|
1695
|
}
|
1696
|
1696
|
|
1697
|
1697
|
feedrate = retract_recover_feedrate * 60;
|
1698
|
|
- float move_e = swapretract ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
|
1698
|
+ float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
1699
|
1699
|
current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
|
1700
|
1700
|
plan_set_e_position(current_position[E_AXIS]);
|
1701
|
1701
|
prepare_move();
|
|
@@ -1770,7 +1770,7 @@ inline void gcode_G0_G1() {
|
1770
|
1770
|
#endif //FWRETRACT
|
1771
|
1771
|
|
1772
|
1772
|
prepare_move();
|
1773
|
|
- //ClearToSend();
|
|
1773
|
+ //ok_to_send();
|
1774
|
1774
|
}
|
1775
|
1775
|
}
|
1776
|
1776
|
|
|
@@ -4292,7 +4292,7 @@ inline void gcode_M303() {
|
4292
|
4292
|
destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS];
|
4293
|
4293
|
destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS];
|
4294
|
4294
|
prepare_move();
|
4295
|
|
- //ClearToSend();
|
|
4295
|
+ //ok_to_send();
|
4296
|
4296
|
return true;
|
4297
|
4297
|
}
|
4298
|
4298
|
return false;
|
|
@@ -5515,7 +5515,7 @@ void process_commands() {
|
5515
|
5515
|
SERIAL_ECHOLNPGM("\"");
|
5516
|
5516
|
}
|
5517
|
5517
|
|
5518
|
|
- ClearToSend();
|
|
5518
|
+ ok_to_send();
|
5519
|
5519
|
}
|
5520
|
5520
|
|
5521
|
5521
|
void FlushSerialRequestResend() {
|
|
@@ -5523,10 +5523,10 @@ void FlushSerialRequestResend() {
|
5523
|
5523
|
MYSERIAL.flush();
|
5524
|
5524
|
SERIAL_PROTOCOLPGM(MSG_RESEND);
|
5525
|
5525
|
SERIAL_PROTOCOLLN(gcode_LastN + 1);
|
5526
|
|
- ClearToSend();
|
|
5526
|
+ ok_to_send();
|
5527
|
5527
|
}
|
5528
|
5528
|
|
5529
|
|
-void ClearToSend() {
|
|
5529
|
+void ok_to_send() {
|
5530
|
5530
|
refresh_cmd_timeout();
|
5531
|
5531
|
#ifdef SDSUPPORT
|
5532
|
5532
|
if (fromsd[cmd_queue_index_r]) return;
|
|
@@ -5755,54 +5755,15 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
5755
|
5755
|
|
5756
|
5756
|
#endif // PREVENT_DANGEROUS_EXTRUDE
|
5757
|
5757
|
|
5758
|
|
-void prepare_move() {
|
5759
|
|
- clamp_to_software_endstops(destination);
|
5760
|
|
- refresh_cmd_timeout();
|
5761
|
|
-
|
5762
|
|
- #ifdef PREVENT_DANGEROUS_EXTRUDE
|
5763
|
|
- (void)prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]);
|
5764
|
|
- #endif
|
5765
|
|
-
|
5766
|
|
- #ifdef SCARA //for now same as delta-code
|
5767
|
|
-
|
5768
|
|
- float difference[NUM_AXIS];
|
5769
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
|
5770
|
|
-
|
5771
|
|
- float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
5772
|
|
- if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
|
5773
|
|
- if (cartesian_mm < 0.000001) { return; }
|
5774
|
|
- float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
|
5775
|
|
- int steps = max(1, int(scara_segments_per_second * seconds));
|
5776
|
|
-
|
5777
|
|
- //SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
|
5778
|
|
- //SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
|
5779
|
|
- //SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
5780
|
|
-
|
5781
|
|
- for (int s = 1; s <= steps; s++) {
|
5782
|
|
- float fraction = float(s) / float(steps);
|
5783
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction;
|
5784
|
|
-
|
5785
|
|
- calculate_delta(destination);
|
5786
|
|
- //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
|
5787
|
|
- //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]);
|
5788
|
|
- //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]);
|
5789
|
|
- //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]);
|
5790
|
|
- //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
|
5791
|
|
- //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
5792
|
|
-
|
5793
|
|
- plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder);
|
5794
|
|
- }
|
5795
|
|
-
|
5796
|
|
- #endif // SCARA
|
5797
|
|
-
|
5798
|
|
- #ifdef DELTA
|
|
5758
|
+#if defined(DELTA) || defined(SCARA)
|
5799
|
5759
|
|
|
5760
|
+ inline bool prepare_move_delta() {
|
5800
|
5761
|
float difference[NUM_AXIS];
|
5801
|
5762
|
for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
|
5802
|
5763
|
|
5803
|
5764
|
float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
5804
|
5765
|
if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
|
5805
|
|
- if (cartesian_mm < 0.000001) return;
|
|
5766
|
+ if (cartesian_mm < 0.000001) return false;
|
5806
|
5767
|
float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
|
5807
|
5768
|
int steps = max(1, int(delta_segments_per_second * seconds));
|
5808
|
5769
|
|
|
@@ -5811,18 +5772,39 @@ void prepare_move() {
|
5811
|
5772
|
// SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
5812
|
5773
|
|
5813
|
5774
|
for (int s = 1; s <= steps; s++) {
|
|
5775
|
+
|
5814
|
5776
|
float fraction = float(s) / float(steps);
|
5815
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction;
|
|
5777
|
+
|
|
5778
|
+ for (int8_t i = 0; i < NUM_AXIS; i++)
|
|
5779
|
+ destination[i] = current_position[i] + difference[i] * fraction;
|
|
5780
|
+
|
5816
|
5781
|
calculate_delta(destination);
|
|
5782
|
+
|
5817
|
5783
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
5818
|
5784
|
adjust_delta(destination);
|
5819
|
5785
|
#endif
|
|
5786
|
+
|
|
5787
|
+ //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
|
|
5788
|
+ //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]);
|
|
5789
|
+ //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]);
|
|
5790
|
+ //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]);
|
|
5791
|
+ //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
|
|
5792
|
+ //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
|
5793
|
+
|
5820
|
5794
|
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder);
|
5821
|
5795
|
}
|
|
5796
|
+ return true;
|
|
5797
|
+ }
|
5822
|
5798
|
|
5823
|
|
- #endif // DELTA
|
|
5799
|
+#endif // DELTA || SCARA
|
5824
|
5800
|
|
5825
|
|
- #ifdef DUAL_X_CARRIAGE
|
|
5801
|
+#ifdef SCARA
|
|
5802
|
+ inline bool prepare_move_scara() { return prepare_move_delta(); }
|
|
5803
|
+#endif
|
|
5804
|
+
|
|
5805
|
+#ifdef DUAL_X_CARRIAGE
|
|
5806
|
+
|
|
5807
|
+ inline bool prepare_move_dual_x_carriage() {
|
5826
|
5808
|
if (active_extruder_parked) {
|
5827
|
5809
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
|
5828
|
5810
|
// move duplicate extruder into correct duplication position.
|
|
@@ -5843,7 +5825,7 @@ void prepare_move() {
|
5843
|
5825
|
set_current_to_destination();
|
5844
|
5826
|
NOLESS(raised_parked_position[Z_AXIS], destination[Z_AXIS]);
|
5845
|
5827
|
delayed_move_time = millis();
|
5846
|
|
- return;
|
|
5828
|
+ return false;
|
5847
|
5829
|
}
|
5848
|
5830
|
}
|
5849
|
5831
|
delayed_move_time = 0;
|
|
@@ -5854,9 +5836,14 @@ void prepare_move() {
|
5854
|
5836
|
active_extruder_parked = false;
|
5855
|
5837
|
}
|
5856
|
5838
|
}
|
5857
|
|
- #endif // DUAL_X_CARRIAGE
|
|
5839
|
+ return true;
|
|
5840
|
+ }
|
5858
|
5841
|
|
5859
|
|
- #if !defined(DELTA) && !defined(SCARA)
|
|
5842
|
+#endif // DUAL_X_CARRIAGE
|
|
5843
|
+
|
|
5844
|
+#if !defined(DELTA) && !defined(SCARA)
|
|
5845
|
+
|
|
5846
|
+ inline bool prepare_move_cartesian() {
|
5860
|
5847
|
// Do not use feedrate_multiplier for E or Z only moves
|
5861
|
5848
|
if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) {
|
5862
|
5849
|
line_to_destination();
|
|
@@ -5864,12 +5851,40 @@ void prepare_move() {
|
5864
|
5851
|
else {
|
5865
|
5852
|
#ifdef MESH_BED_LEVELING
|
5866
|
5853
|
mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedrate_multiplier/100.0), active_extruder);
|
5867
|
|
- return;
|
|
5854
|
+ return false;
|
5868
|
5855
|
#else
|
5869
|
5856
|
line_to_destination(feedrate * feedrate_multiplier / 100.0);
|
5870
|
|
- #endif // MESH_BED_LEVELING
|
|
5857
|
+ #endif
|
5871
|
5858
|
}
|
5872
|
|
- #endif // !(DELTA || SCARA)
|
|
5859
|
+ return true;
|
|
5860
|
+ }
|
|
5861
|
+
|
|
5862
|
+#endif // !DELTA && !SCARA
|
|
5863
|
+
|
|
5864
|
+/**
|
|
5865
|
+ * Prepare a single move and get ready for the next one
|
|
5866
|
+ */
|
|
5867
|
+void prepare_move() {
|
|
5868
|
+ clamp_to_software_endstops(destination);
|
|
5869
|
+ refresh_cmd_timeout();
|
|
5870
|
+
|
|
5871
|
+ #ifdef PREVENT_DANGEROUS_EXTRUDE
|
|
5872
|
+ prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]);
|
|
5873
|
+ #endif
|
|
5874
|
+
|
|
5875
|
+ #ifdef SCARA
|
|
5876
|
+ if (!prepare_move_scara()) return;
|
|
5877
|
+ #elif defined(DELTA)
|
|
5878
|
+ if (!prepare_move_delta()) return;
|
|
5879
|
+ #endif
|
|
5880
|
+
|
|
5881
|
+ #ifdef DUAL_X_CARRIAGE
|
|
5882
|
+ if (!prepare_move_dual_x_carriage()) return;
|
|
5883
|
+ #endif
|
|
5884
|
+
|
|
5885
|
+ #if !defined(DELTA) && !defined(SCARA)
|
|
5886
|
+ if (!prepare_move_cartesian()) return;
|
|
5887
|
+ #endif
|
5873
|
5888
|
|
5874
|
5889
|
set_current_to_destination();
|
5875
|
5890
|
}
|
|
@@ -5889,37 +5904,37 @@ void prepare_arc_move(char isclockwise) {
|
5889
|
5904
|
|
5890
|
5905
|
#if HAS_CONTROLLERFAN
|
5891
|
5906
|
|
5892
|
|
-millis_t lastMotor = 0; // Last time a motor was turned on
|
5893
|
|
-millis_t lastMotorCheck = 0; // Last time the state was checked
|
5894
|
|
-
|
5895
|
|
-void controllerFan() {
|
5896
|
|
- millis_t ms = millis();
|
5897
|
|
- if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
|
5898
|
|
- lastMotorCheck = ms;
|
5899
|
|
- if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
|
5900
|
|
- || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
|
5901
|
|
- #if EXTRUDERS > 1
|
5902
|
|
- || E1_ENABLE_READ == E_ENABLE_ON
|
5903
|
|
- #if HAS_X2_ENABLE
|
5904
|
|
- || X2_ENABLE_READ == X_ENABLE_ON
|
5905
|
|
- #endif
|
5906
|
|
- #if EXTRUDERS > 2
|
5907
|
|
- || E2_ENABLE_READ == E_ENABLE_ON
|
5908
|
|
- #if EXTRUDERS > 3
|
5909
|
|
- || E3_ENABLE_READ == E_ENABLE_ON
|
|
5907
|
+ void controllerFan() {
|
|
5908
|
+ static millis_t lastMotor = 0; // Last time a motor was turned on
|
|
5909
|
+ static millis_t lastMotorCheck = 0; // Last time the state was checked
|
|
5910
|
+ millis_t ms = millis();
|
|
5911
|
+ if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
|
|
5912
|
+ lastMotorCheck = ms;
|
|
5913
|
+ if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
|
|
5914
|
+ || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
|
|
5915
|
+ #if EXTRUDERS > 1
|
|
5916
|
+ || E1_ENABLE_READ == E_ENABLE_ON
|
|
5917
|
+ #if HAS_X2_ENABLE
|
|
5918
|
+ || X2_ENABLE_READ == X_ENABLE_ON
|
|
5919
|
+ #endif
|
|
5920
|
+ #if EXTRUDERS > 2
|
|
5921
|
+ || E2_ENABLE_READ == E_ENABLE_ON
|
|
5922
|
+ #if EXTRUDERS > 3
|
|
5923
|
+ || E3_ENABLE_READ == E_ENABLE_ON
|
|
5924
|
+ #endif
|
5910
|
5925
|
#endif
|
5911
|
5926
|
#endif
|
5912
|
|
- #endif
|
5913
|
|
- ) {
|
5914
|
|
- lastMotor = ms; //... set time to NOW so the fan will turn on
|
|
5927
|
+ ) {
|
|
5928
|
+ lastMotor = ms; //... set time to NOW so the fan will turn on
|
|
5929
|
+ }
|
|
5930
|
+ uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
|
|
5931
|
+ // allows digital or PWM fan output to be used (see M42 handling)
|
|
5932
|
+ digitalWrite(CONTROLLERFAN_PIN, speed);
|
|
5933
|
+ analogWrite(CONTROLLERFAN_PIN, speed);
|
5915
|
5934
|
}
|
5916
|
|
- uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
|
5917
|
|
- // allows digital or PWM fan output to be used (see M42 handling)
|
5918
|
|
- digitalWrite(CONTROLLERFAN_PIN, speed);
|
5919
|
|
- analogWrite(CONTROLLERFAN_PIN, speed);
|
5920
|
5935
|
}
|
5921
|
|
-}
|
5922
|
|
-#endif
|
|
5936
|
+
|
|
5937
|
+#endif // HAS_CONTROLLERFAN
|
5923
|
5938
|
|
5924
|
5939
|
#ifdef SCARA
|
5925
|
5940
|
void calculate_SCARA_forward_Transform(float f_scara[3])
|