27
27
#include " ../gcode.h"
28
28
#include " ../../module/tool_change.h"
29
29
30
+ #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
31
+ #include " ../../module/motion.h"
32
+ #endif
33
+
30
34
#include " ../../MarlinCore.h" // for SP_X_STR, etc.
31
35
32
36
extern const char SP_X_STR[], SP_Y_STR[], SP_Z_STR[];
@@ -35,16 +39,30 @@ void M217_report(const bool eeprom=false) {
35
39
36
40
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
37
41
serialprintPGM (eeprom ? PSTR (" M217" ) : PSTR (" Toolchange:" ));
38
- SERIAL_ECHOPAIR (" S" , LINEAR_UNIT (toolchange_settings.swap_length ));
39
- SERIAL_ECHOPAIR_P (SP_E_STR, LINEAR_UNIT (toolchange_settings.extra_prime ));
40
- SERIAL_ECHOPAIR_P (SP_P_STR, LINEAR_UNIT (toolchange_settings.prime_speed ));
41
- SERIAL_ECHOPAIR (" R" , LINEAR_UNIT (toolchange_settings.retract_speed ));
42
+ SERIAL_ECHOPAIR (" S" , LINEAR_UNIT (toolchange_settings.swap_length ),
43
+ " B" , LINEAR_UNIT (toolchange_settings.extra_resume ));
44
+ SERIAL_ECHOPAIR_P (SP_E_STR, LINEAR_UNIT (toolchange_settings.extra_prime ),
45
+ SP_P_STR, LINEAR_UNIT (toolchange_settings.prime_speed ));
46
+ SERIAL_ECHOPAIR (" R" , LINEAR_UNIT (toolchange_settings.retract_speed ),
47
+ " U" , LINEAR_UNIT (toolchange_settings.unretract_speed ),
48
+ " F" , toolchange_settings.fan_speed ,
49
+ " G" , toolchange_settings.fan_time );
50
+
51
+ #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
52
+ SERIAL_ECHOPAIR (" N" , int (migration.automode ));
53
+ SERIAL_ECHOPAIR (" L" , LINEAR_UNIT (migration.last ));
54
+ #endif
42
55
43
56
#if ENABLED(TOOLCHANGE_PARK)
57
+ SERIAL_ECHOPAIR (" W" , LINEAR_UNIT (toolchange_settings.enable_park ));
44
58
SERIAL_ECHOPAIR_P (SP_X_STR, LINEAR_UNIT (toolchange_settings.change_point .x ));
45
59
SERIAL_ECHOPAIR_P (SP_Y_STR, LINEAR_UNIT (toolchange_settings.change_point .y ));
46
60
#endif
47
61
62
+ #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
63
+ SERIAL_ECHOPAIR (" V" , LINEAR_UNIT (enable_first_prime));
64
+ #endif
65
+
48
66
#else
49
67
50
68
UNUSED (eeprom);
@@ -58,48 +76,98 @@ void M217_report(const bool eeprom=false) {
58
76
/* *
59
77
* M217 - Set SINGLENOZZLE toolchange parameters
60
78
*
79
+ * // Tool change command
80
+ * Q Prime active tool and exit
81
+ *
82
+ * // Tool change settings
61
83
* S[linear] Swap length
62
- * E[linear] Purge length
84
+ * B[linear] Extra Swap length
85
+ * E[linear] Prime length
63
86
* P[linear/m] Prime speed
64
87
* R[linear/m] Retract speed
88
+ * U[linear/m] UnRetract speed
89
+ * V[linear] 0/1 Enable auto prime first extruder used
90
+ * W[linear] 0/1 Enable park & Z Raise
65
91
* X[linear] Park X (Requires TOOLCHANGE_PARK)
66
92
* Y[linear] Park Y (Requires TOOLCHANGE_PARK)
67
93
* Z[linear] Z Raise
94
+ * F[linear] Fan Speed 0-255
95
+ * G[linear/s] Fan time
96
+ *
97
+ * Tool migration settings
98
+ * A[0|1] Enable auto-migration on runout
99
+ * L[index] Last extruder to use for auto-migration
100
+ *
101
+ * Tool migration command
102
+ * T[index] Migrate to next extruder or the given extruder
68
103
*/
69
104
void GcodeSuite::M217 () {
70
105
71
- #define SPR_PARAM
72
- #define XY_PARAM
73
-
74
106
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
75
107
76
- #undef SPR_PARAM
77
- #define SPR_PARAM " SPRE"
108
+ static constexpr float max_extrude = TERN (PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 500 );
78
109
79
- static constexpr float max_extrude =
80
- #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
81
- EXTRUDE_MAXLENGTH
82
- #else
83
- 500
84
- #endif
85
- ;
110
+ if (parser.seen (' Q' )) { tool_change_prime (); return ; }
86
111
87
112
if (parser.seenval (' S' )) { const float v = parser.value_linear_units (); toolchange_settings.swap_length = constrain (v, 0 , max_extrude); }
113
+ if (parser.seenval (' B' )) { const float v = parser.value_linear_units (); toolchange_settings.extra_resume = constrain (v, -10 , 10 ); }
88
114
if (parser.seenval (' E' )) { const float v = parser.value_linear_units (); toolchange_settings.extra_prime = constrain (v, 0 , max_extrude); }
89
115
if (parser.seenval (' P' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.prime_speed = constrain (v, 10 , 5400 ); }
90
116
if (parser.seenval (' R' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.retract_speed = constrain (v, 10 , 5400 ); }
117
+ if (parser.seenval (' U' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.unretract_speed = constrain (v, 10 , 5400 ); }
118
+ #if TOOLCHANGE_FS_FAN >= 0 && FAN_COUNT > 0
119
+ if (parser.seenval (' F' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.fan_speed = constrain (v, 0 , 255 ); }
120
+ if (parser.seenval (' G' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.fan_time = constrain (v, 1 , 30 ); }
121
+ #endif
122
+ #endif
123
+
124
+ #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
125
+ if (parser.seenval (' V' )) { enable_first_prime = parser.value_linear_units (); }
91
126
#endif
92
127
93
128
#if ENABLED(TOOLCHANGE_PARK)
94
- #undef XY_PARAM
95
- #define XY_PARAM " XY"
96
- if (parser.seenval (' X' )) { toolchange_settings.change_point .x = parser.value_linear_units (); }
97
- if (parser.seenval (' Y' )) { toolchange_settings.change_point .y = parser.value_linear_units (); }
129
+ if (parser.seenval (' W' )) { toolchange_settings.enable_park = parser.value_linear_units (); }
130
+ if (parser.seenval (' X' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.change_point .x = constrain (v, X_MIN_POS, X_MAX_POS); }
131
+ if (parser.seenval (' Y' )) { const int16_t v = parser.value_linear_units (); toolchange_settings.change_point .y = constrain (v, Y_MIN_POS, Y_MAX_POS); }
98
132
#endif
99
133
100
134
if (parser.seenval (' Z' )) { toolchange_settings.z_raise = parser.value_linear_units (); }
101
135
102
- if (!parser.seen (SPR_PARAM XY_PARAM " Z" )) M217_report ();
136
+ #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
137
+ migration.target = 0 ; // 0 = disabled
138
+
139
+ if (parser.seenval (' L' )) { // Last
140
+ const int16_t lval = parser.value_int ();
141
+ if (WITHIN (lval, 0 , EXTRUDERS - 1 )) {
142
+ migration.last = lval;
143
+ migration.automode = (active_extruder < migration.last );
144
+ }
145
+ }
146
+
147
+ if (parser.seen (' A' )) // Auto on/off
148
+ migration.automode = parser.value_bool ();
149
+
150
+ if (parser.seen (' T' )) { // Migrate now
151
+ if (parser.has_value ()) {
152
+ const int16_t tval = parser.value_int ();
153
+ if (WITHIN (tval, 0 , EXTRUDERS - 1 ) && tval != active_extruder) {
154
+ migration.target = tval + 1 ;
155
+ extruder_migration ();
156
+ migration.target = 0 ; // disable
157
+ return ;
158
+ }
159
+ else
160
+ migration.target = 0 ; // disable
161
+ }
162
+ else {
163
+ extruder_migration ();
164
+ return ;
165
+ }
166
+ }
167
+
168
+ #endif
169
+
170
+ M217_report ();
103
171
}
104
172
105
173
#endif // EXTRUDERS > 1
0 commit comments