|
@@ -363,6 +363,7 @@ bool target_direction;
|
363
|
363
|
#endif
|
364
|
364
|
|
365
|
365
|
#ifdef SCARA
|
|
366
|
+ float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND;
|
366
|
367
|
static float delta[3] = { 0 };
|
367
|
368
|
float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1
|
368
|
369
|
#endif
|
|
@@ -1712,7 +1713,7 @@ static void homeaxis(AxisEnum axis) {
|
1712
|
1713
|
|
1713
|
1714
|
#ifdef FWRETRACT
|
1714
|
1715
|
|
1715
|
|
- void retract(bool retracting, bool swapretract = false) {
|
|
1716
|
+ void retract(bool retracting, bool swapping=false) {
|
1716
|
1717
|
|
1717
|
1718
|
if (retracting == retracted[active_extruder]) return;
|
1718
|
1719
|
|
|
@@ -1723,7 +1724,7 @@ static void homeaxis(AxisEnum axis) {
|
1723
|
1724
|
if (retracting) {
|
1724
|
1725
|
|
1725
|
1726
|
feedrate = retract_feedrate * 60;
|
1726
|
|
- current_position[E_AXIS] += (swapretract ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder];
|
|
1727
|
+ current_position[E_AXIS] += (swapping ? retract_length_swap : retract_length) / volumetric_multiplier[active_extruder];
|
1727
|
1728
|
plan_set_e_position(current_position[E_AXIS]);
|
1728
|
1729
|
prepare_move();
|
1729
|
1730
|
|
|
@@ -1750,7 +1751,7 @@ static void homeaxis(AxisEnum axis) {
|
1750
|
1751
|
}
|
1751
|
1752
|
|
1752
|
1753
|
feedrate = retract_recover_feedrate * 60;
|
1753
|
|
- float move_e = swapretract ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
|
1754
|
+ float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
1754
|
1755
|
current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
|
1755
|
1756
|
plan_set_e_position(current_position[E_AXIS]);
|
1756
|
1757
|
prepare_move();
|
|
@@ -1792,7 +1793,7 @@ inline void gcode_G0_G1() {
|
1792
|
1793
|
#endif //FWRETRACT
|
1793
|
1794
|
|
1794
|
1795
|
prepare_move();
|
1795
|
|
- //ClearToSend();
|
|
1796
|
+ //ok_to_send();
|
1796
|
1797
|
}
|
1797
|
1798
|
}
|
1798
|
1799
|
|
|
@@ -1814,7 +1815,7 @@ inline void gcode_G4() {
|
1814
|
1815
|
millis_t codenum = 0;
|
1815
|
1816
|
|
1816
|
1817
|
if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait
|
1817
|
|
- if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait
|
|
1818
|
+ if (code_seen('S')) codenum = code_value() * 1000; // seconds to wait
|
1818
|
1819
|
|
1819
|
1820
|
st_synchronize();
|
1820
|
1821
|
refresh_cmd_timeout();
|
|
@@ -2681,7 +2682,7 @@ inline void gcode_G92() {
|
2681
|
2682
|
hasP = codenum > 0;
|
2682
|
2683
|
}
|
2683
|
2684
|
if (code_seen('S')) {
|
2684
|
|
- codenum = code_value_short() * 1000UL; // seconds to wait
|
|
2685
|
+ codenum = code_value() * 1000; // seconds to wait
|
2685
|
2686
|
hasS = codenum > 0;
|
2686
|
2687
|
}
|
2687
|
2688
|
char* starpos = strchr(src, '*');
|
|
@@ -4314,7 +4315,7 @@ inline void gcode_M303() {
|
4314
|
4315
|
destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS];
|
4315
|
4316
|
destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS];
|
4316
|
4317
|
prepare_move();
|
4317
|
|
- //ClearToSend();
|
|
4318
|
+ //ok_to_send();
|
4318
|
4319
|
return true;
|
4319
|
4320
|
}
|
4320
|
4321
|
return false;
|
|
@@ -5537,7 +5538,7 @@ void process_commands() {
|
5537
|
5538
|
SERIAL_ECHOLNPGM("\"");
|
5538
|
5539
|
}
|
5539
|
5540
|
|
5540
|
|
- ClearToSend();
|
|
5541
|
+ ok_to_send();
|
5541
|
5542
|
}
|
5542
|
5543
|
|
5543
|
5544
|
void FlushSerialRequestResend() {
|
|
@@ -5545,10 +5546,10 @@ void FlushSerialRequestResend() {
|
5545
|
5546
|
MYSERIAL.flush();
|
5546
|
5547
|
SERIAL_PROTOCOLPGM(MSG_RESEND);
|
5547
|
5548
|
SERIAL_PROTOCOLLN(gcode_LastN + 1);
|
5548
|
|
- ClearToSend();
|
|
5549
|
+ ok_to_send();
|
5549
|
5550
|
}
|
5550
|
5551
|
|
5551
|
|
-void ClearToSend() {
|
|
5552
|
+void ok_to_send() {
|
5552
|
5553
|
refresh_cmd_timeout();
|
5553
|
5554
|
#ifdef SDSUPPORT
|
5554
|
5555
|
if (fromsd[cmd_queue_index_r]) return;
|
|
@@ -5777,54 +5778,15 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
5777
|
5778
|
|
5778
|
5779
|
#endif // PREVENT_DANGEROUS_EXTRUDE
|
5779
|
5780
|
|
5780
|
|
-void prepare_move() {
|
5781
|
|
- clamp_to_software_endstops(destination);
|
5782
|
|
- refresh_cmd_timeout();
|
5783
|
|
-
|
5784
|
|
- #ifdef PREVENT_DANGEROUS_EXTRUDE
|
5785
|
|
- (void)prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]);
|
5786
|
|
- #endif
|
5787
|
|
-
|
5788
|
|
- #ifdef SCARA //for now same as delta-code
|
5789
|
|
-
|
5790
|
|
- float difference[NUM_AXIS];
|
5791
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
|
5792
|
|
-
|
5793
|
|
- float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
5794
|
|
- if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
|
5795
|
|
- if (cartesian_mm < 0.000001) { return; }
|
5796
|
|
- float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
|
5797
|
|
- int steps = max(1, int(scara_segments_per_second * seconds));
|
5798
|
|
-
|
5799
|
|
- //SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
|
5800
|
|
- //SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
|
5801
|
|
- //SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
5802
|
|
-
|
5803
|
|
- for (int s = 1; s <= steps; s++) {
|
5804
|
|
- float fraction = float(s) / float(steps);
|
5805
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction;
|
5806
|
|
-
|
5807
|
|
- calculate_delta(destination);
|
5808
|
|
- //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
|
5809
|
|
- //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]);
|
5810
|
|
- //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]);
|
5811
|
|
- //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]);
|
5812
|
|
- //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
|
5813
|
|
- //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
5814
|
|
-
|
5815
|
|
- plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder);
|
5816
|
|
- }
|
5817
|
|
-
|
5818
|
|
- #endif // SCARA
|
5819
|
|
-
|
5820
|
|
- #ifdef DELTA
|
|
5781
|
+#if defined(DELTA) || defined(SCARA)
|
5821
|
5782
|
|
|
5783
|
+ inline bool prepare_move_delta() {
|
5822
|
5784
|
float difference[NUM_AXIS];
|
5823
|
5785
|
for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
|
5824
|
5786
|
|
5825
|
5787
|
float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
5826
|
5788
|
if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
|
5827
|
|
- if (cartesian_mm < 0.000001) return;
|
|
5789
|
+ if (cartesian_mm < 0.000001) return false;
|
5828
|
5790
|
float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
|
5829
|
5791
|
int steps = max(1, int(delta_segments_per_second * seconds));
|
5830
|
5792
|
|
|
@@ -5833,18 +5795,39 @@ void prepare_move() {
|
5833
|
5795
|
// SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
5834
|
5796
|
|
5835
|
5797
|
for (int s = 1; s <= steps; s++) {
|
|
5798
|
+
|
5836
|
5799
|
float fraction = float(s) / float(steps);
|
5837
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction;
|
|
5800
|
+
|
|
5801
|
+ for (int8_t i = 0; i < NUM_AXIS; i++)
|
|
5802
|
+ destination[i] = current_position[i] + difference[i] * fraction;
|
|
5803
|
+
|
5838
|
5804
|
calculate_delta(destination);
|
|
5805
|
+
|
5839
|
5806
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
5840
|
5807
|
adjust_delta(destination);
|
5841
|
5808
|
#endif
|
|
5809
|
+
|
|
5810
|
+ //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
|
|
5811
|
+ //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]);
|
|
5812
|
+ //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]);
|
|
5813
|
+ //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]);
|
|
5814
|
+ //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
|
|
5815
|
+ //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
|
5816
|
+
|
5842
|
5817
|
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder);
|
5843
|
5818
|
}
|
|
5819
|
+ return true;
|
|
5820
|
+ }
|
5844
|
5821
|
|
5845
|
|
- #endif // DELTA
|
|
5822
|
+#endif // DELTA || SCARA
|
5846
|
5823
|
|
5847
|
|
- #ifdef DUAL_X_CARRIAGE
|
|
5824
|
+#ifdef SCARA
|
|
5825
|
+ inline bool prepare_move_scara() { return prepare_move_delta(); }
|
|
5826
|
+#endif
|
|
5827
|
+
|
|
5828
|
+#ifdef DUAL_X_CARRIAGE
|
|
5829
|
+
|
|
5830
|
+ inline bool prepare_move_dual_x_carriage() {
|
5848
|
5831
|
if (active_extruder_parked) {
|
5849
|
5832
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
|
5850
|
5833
|
// move duplicate extruder into correct duplication position.
|
|
@@ -5865,7 +5848,7 @@ void prepare_move() {
|
5865
|
5848
|
set_current_to_destination();
|
5866
|
5849
|
NOLESS(raised_parked_position[Z_AXIS], destination[Z_AXIS]);
|
5867
|
5850
|
delayed_move_time = millis();
|
5868
|
|
- return;
|
|
5851
|
+ return false;
|
5869
|
5852
|
}
|
5870
|
5853
|
}
|
5871
|
5854
|
delayed_move_time = 0;
|
|
@@ -5876,9 +5859,14 @@ void prepare_move() {
|
5876
|
5859
|
active_extruder_parked = false;
|
5877
|
5860
|
}
|
5878
|
5861
|
}
|
5879
|
|
- #endif // DUAL_X_CARRIAGE
|
|
5862
|
+ return true;
|
|
5863
|
+ }
|
5880
|
5864
|
|
5881
|
|
- #if !defined(DELTA) && !defined(SCARA)
|
|
5865
|
+#endif // DUAL_X_CARRIAGE
|
|
5866
|
+
|
|
5867
|
+#if !defined(DELTA) && !defined(SCARA)
|
|
5868
|
+
|
|
5869
|
+ inline bool prepare_move_cartesian() {
|
5882
|
5870
|
// Do not use feedrate_multiplier for E or Z only moves
|
5883
|
5871
|
if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) {
|
5884
|
5872
|
line_to_destination();
|
|
@@ -5886,12 +5874,40 @@ void prepare_move() {
|
5886
|
5874
|
else {
|
5887
|
5875
|
#ifdef MESH_BED_LEVELING
|
5888
|
5876
|
mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedrate_multiplier/100.0), active_extruder);
|
5889
|
|
- return;
|
|
5877
|
+ return false;
|
5890
|
5878
|
#else
|
5891
|
5879
|
line_to_destination(feedrate * feedrate_multiplier / 100.0);
|
5892
|
|
- #endif // MESH_BED_LEVELING
|
|
5880
|
+ #endif
|
5893
|
5881
|
}
|
5894
|
|
- #endif // !(DELTA || SCARA)
|
|
5882
|
+ return true;
|
|
5883
|
+ }
|
|
5884
|
+
|
|
5885
|
+#endif // !DELTA && !SCARA
|
|
5886
|
+
|
|
5887
|
+/**
|
|
5888
|
+ * Prepare a single move and get ready for the next one
|
|
5889
|
+ */
|
|
5890
|
+void prepare_move() {
|
|
5891
|
+ clamp_to_software_endstops(destination);
|
|
5892
|
+ refresh_cmd_timeout();
|
|
5893
|
+
|
|
5894
|
+ #ifdef PREVENT_DANGEROUS_EXTRUDE
|
|
5895
|
+ prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]);
|
|
5896
|
+ #endif
|
|
5897
|
+
|
|
5898
|
+ #ifdef SCARA
|
|
5899
|
+ if (!prepare_move_scara()) return;
|
|
5900
|
+ #elif defined(DELTA)
|
|
5901
|
+ if (!prepare_move_delta()) return;
|
|
5902
|
+ #endif
|
|
5903
|
+
|
|
5904
|
+ #ifdef DUAL_X_CARRIAGE
|
|
5905
|
+ if (!prepare_move_dual_x_carriage()) return;
|
|
5906
|
+ #endif
|
|
5907
|
+
|
|
5908
|
+ #if !defined(DELTA) && !defined(SCARA)
|
|
5909
|
+ if (!prepare_move_cartesian()) return;
|
|
5910
|
+ #endif
|
5895
|
5911
|
|
5896
|
5912
|
set_current_to_destination();
|
5897
|
5913
|
}
|
|
@@ -5911,37 +5927,37 @@ void prepare_arc_move(char isclockwise) {
|
5911
|
5927
|
|
5912
|
5928
|
#if HAS_CONTROLLERFAN
|
5913
|
5929
|
|
5914
|
|
-millis_t lastMotor = 0; // Last time a motor was turned on
|
5915
|
|
-millis_t lastMotorCheck = 0; // Last time the state was checked
|
5916
|
|
-
|
5917
|
|
-void controllerFan() {
|
5918
|
|
- millis_t ms = millis();
|
5919
|
|
- if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
|
5920
|
|
- lastMotorCheck = ms;
|
5921
|
|
- if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
|
5922
|
|
- || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
|
5923
|
|
- #if EXTRUDERS > 1
|
5924
|
|
- || E1_ENABLE_READ == E_ENABLE_ON
|
5925
|
|
- #if HAS_X2_ENABLE
|
5926
|
|
- || X2_ENABLE_READ == X_ENABLE_ON
|
5927
|
|
- #endif
|
5928
|
|
- #if EXTRUDERS > 2
|
5929
|
|
- || E2_ENABLE_READ == E_ENABLE_ON
|
5930
|
|
- #if EXTRUDERS > 3
|
5931
|
|
- || E3_ENABLE_READ == E_ENABLE_ON
|
|
5930
|
+ void controllerFan() {
|
|
5931
|
+ static millis_t lastMotor = 0; // Last time a motor was turned on
|
|
5932
|
+ static millis_t lastMotorCheck = 0; // Last time the state was checked
|
|
5933
|
+ millis_t ms = millis();
|
|
5934
|
+ if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
|
|
5935
|
+ lastMotorCheck = ms;
|
|
5936
|
+ if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
|
|
5937
|
+ || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
|
|
5938
|
+ #if EXTRUDERS > 1
|
|
5939
|
+ || E1_ENABLE_READ == E_ENABLE_ON
|
|
5940
|
+ #if HAS_X2_ENABLE
|
|
5941
|
+ || X2_ENABLE_READ == X_ENABLE_ON
|
|
5942
|
+ #endif
|
|
5943
|
+ #if EXTRUDERS > 2
|
|
5944
|
+ || E2_ENABLE_READ == E_ENABLE_ON
|
|
5945
|
+ #if EXTRUDERS > 3
|
|
5946
|
+ || E3_ENABLE_READ == E_ENABLE_ON
|
|
5947
|
+ #endif
|
5932
|
5948
|
#endif
|
5933
|
5949
|
#endif
|
5934
|
|
- #endif
|
5935
|
|
- ) {
|
5936
|
|
- lastMotor = ms; //... set time to NOW so the fan will turn on
|
|
5950
|
+ ) {
|
|
5951
|
+ lastMotor = ms; //... set time to NOW so the fan will turn on
|
|
5952
|
+ }
|
|
5953
|
+ uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
|
|
5954
|
+ // allows digital or PWM fan output to be used (see M42 handling)
|
|
5955
|
+ digitalWrite(CONTROLLERFAN_PIN, speed);
|
|
5956
|
+ analogWrite(CONTROLLERFAN_PIN, speed);
|
5937
|
5957
|
}
|
5938
|
|
- uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
|
5939
|
|
- // allows digital or PWM fan output to be used (see M42 handling)
|
5940
|
|
- digitalWrite(CONTROLLERFAN_PIN, speed);
|
5941
|
|
- analogWrite(CONTROLLERFAN_PIN, speed);
|
5942
|
5958
|
}
|
5943
|
|
-}
|
5944
|
|
-#endif
|
|
5959
|
+
|
|
5960
|
+#endif // HAS_CONTROLLERFAN
|
5945
|
5961
|
|
5946
|
5962
|
#ifdef SCARA
|
5947
|
5963
|
void calculate_SCARA_forward_Transform(float f_scara[3])
|