|
@@ -30,13 +30,22 @@
|
30
|
30
|
|
31
|
31
|
#include "fwretract.h"
|
32
|
32
|
|
33
|
|
-FWRetract fwretract; // Single instance
|
|
33
|
+FWRetract fwretract; // Single instance - this calls the constructor
|
34
|
34
|
|
35
|
35
|
#include "../module/motion.h"
|
36
|
36
|
#include "../module/planner.h"
|
|
37
|
+#include "../module/stepper.h"
|
|
38
|
+
|
|
39
|
+// private:
|
|
40
|
+
|
|
41
|
+#if EXTRUDERS > 1
|
|
42
|
+ bool FWRetract::retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted
|
|
43
|
+#endif
|
|
44
|
+
|
|
45
|
+// public:
|
37
|
46
|
|
38
|
47
|
bool FWRetract::autoretract_enabled, // M209 S - Autoretract switch
|
39
|
|
- FWRetract::retracted[EXTRUDERS] = { false }; // Which extruders are currently retracted
|
|
48
|
+ FWRetract::retracted[EXTRUDERS]; // Which extruders are currently retracted
|
40
|
49
|
float FWRetract::retract_length, // M207 S - G10 Retract length
|
41
|
50
|
FWRetract::retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
|
42
|
51
|
FWRetract::retract_zlift, // M207 Z - G10 Retract hop size
|
|
@@ -45,9 +54,6 @@ float FWRetract::retract_length, // M207 S - G10 Retract len
|
45
|
54
|
FWRetract::swap_retract_length, // M207 W - G10 Swap Retract length
|
46
|
55
|
FWRetract::swap_retract_recover_length, // M208 W - G11 Swap Recover length
|
47
|
56
|
FWRetract::swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
|
48
|
|
-#if EXTRUDERS > 1
|
49
|
|
- bool FWRetract::retracted_swap[EXTRUDERS] = { false }; // Which extruders are swap-retracted
|
50
|
|
-#endif
|
51
|
57
|
|
52
|
58
|
void FWRetract::reset() {
|
53
|
59
|
autoretract_enabled = false;
|
|
@@ -59,6 +65,13 @@ void FWRetract::reset() {
|
59
|
65
|
swap_retract_length = RETRACT_LENGTH_SWAP;
|
60
|
66
|
swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
|
61
|
67
|
swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
|
|
68
|
+
|
|
69
|
+ for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
|
70
|
+ retracted[i] = false;
|
|
71
|
+ #if EXTRUDERS > 1
|
|
72
|
+ retracted_swap[i] = false;
|
|
73
|
+ #endif
|
|
74
|
+ }
|
62
|
75
|
}
|
63
|
76
|
|
64
|
77
|
/**
|
|
@@ -87,10 +100,11 @@ void FWRetract::retract(const bool retracting
|
87
|
100
|
// Simply never allow two retracts or recovers in a row
|
88
|
101
|
if (retracted[active_extruder] == retracting) return;
|
89
|
102
|
|
90
|
|
- #if EXTRUDERS < 2
|
91
|
|
- bool swapping = false;
|
|
103
|
+ #if EXTRUDERS > 1
|
|
104
|
+ if (!retracting) swapping = retracted_swap[active_extruder];
|
|
105
|
+ #else
|
|
106
|
+ const bool swapping = false;
|
92
|
107
|
#endif
|
93
|
|
- if (!retracting) swapping = retracted_swap[active_extruder];
|
94
|
108
|
|
95
|
109
|
/* // debugging
|
96
|
110
|
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
|
@@ -117,6 +131,8 @@ void FWRetract::retract(const bool retracting
|
117
|
131
|
// The current position will be the destination for E and Z moves
|
118
|
132
|
set_destination_to_current();
|
119
|
133
|
|
|
134
|
+ stepper.synchronize(); // Wait for buffered moves to complete
|
|
135
|
+
|
120
|
136
|
if (retracting) {
|
121
|
137
|
// Remember the Z height since G-code may include its own Z-hop
|
122
|
138
|
// For best results turn off Z hop if G-code already includes it
|