-
Notifications
You must be signed in to change notification settings - Fork 3
/
macros.cfg
226 lines (208 loc) · 6.86 KB
/
macros.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# MMMS_START: Initializes the 3MS to the provided INITIAL_TOOL. Use in your PRINT_START macro.
[gcode_macro MMMS_START]
gcode:
CLEAR_TOOL
{% set initial_tool = params.INITIAL_TOOL|int %}
{% set fsensor_delay = printer["gcode_macro MMMS_SETTINGS"].fsensor_delay|int %}
M118 3MS Start
M118 Initial Tool: T{initial_tool}
CHECK_FSENSOR V=0 MSG="Please unload filament and resume."
SYNC_TOOL TOOL={initial_tool}
DISABLE_FSENSOR
MMMS_LOAD
G4 P{fsensor_delay}
ENABLE_FSENSOR
G4 P{fsensor_delay}
CHECK_FSENSOR V=1 MSG="Please load T{initial_tool} and resume."
SAVE_VARIABLE VARIABLE=p VALUE={initial_tool}
# MMMS_END: Unloads the 3MS. Use in your PRINT_END macro.
[gcode_macro MMMS_END]
gcode:
{% set current_tool = printer.save_variables.variables.p|default(-1)|int %}
{% set fsensor_delay = printer["gcode_macro MMMS_SETTINGS"].fsensor_delay|int %}
CLEAR_TOOL
M118 3MS End
{% if current_tool > -1 %}
SYNC_TOOL TOOL={current_tool}
G4 P{fsensor_delay/2}
DISABLE_FSENSOR
MMMS_UNLOAD
G4 P{fsensor_delay}
{% endif %}
ENABLE_FSENSOR
G4 P{fsensor_delay}
CHECK_FSENSOR V=0 MSG="Please unload T{current_tool} and resume."
ENABLE_FSENSOR
# Unloads 3MS by provided/default DISTANCE, SPEED, in 50mm increments
[gcode_macro MMMS_UNLOAD]
gcode:
{% set distance = params.DISTANCE|default(printer["gcode_macro MMMS_SETTINGS"].unload_distance)|int %}
{% set speed = params.SPEED|default(printer["gcode_macro MMMS_SETTINGS"].unload_speed)|int %}
{% set step_size = printer["gcode_macro MMMS_SETTINGS"].step_size %}
{% set times = (distance // step_size)|int %}
M83
{% for _ in range(times) %}
G1 E-{step_size} F{speed}
{% endfor %}
G1 E-{distance - (times * step_size)} F{speed}
# Loads 3MS by provided/default DISTANCE, SPEED, in 50mm incremenents
[gcode_macro MMMS_LOAD]
gcode:
{% set distance = params.DISTANCE|default(printer["gcode_macro MMMS_SETTINGS"].load_distance)|int %}
{% set speed = params.SPEED|default(printer["gcode_macro MMMS_SETTINGS"].load_speed)|int %}
{% set step_size = printer["gcode_macro MMMS_SETTINGS"].step_size %}
{% set times = (distance // step_size)|int %}
M83
{% for _ in range(times) %}
G1 E{step_size} F{speed}
{% endfor %}
G1 E{distance - (times * step_size)} F{speed}
[gcode_macro Toolchange]
gcode:
{% set p = printer.save_variables.variables.p|default(-1)|int %}
{% set fsensor_delay = printer["gcode_macro MMMS_SETTINGS"].fsensor_delay|int %}
{% set t = params.T|int %}
M118 T{p} -> T{t}
{% if p != t %}
{% if p > -1 %}
DISABLE_FSENSOR
G4 P{fsensor_delay/2}
MMMS_UNLOAD
DESYNC_TOOL TOOL={p}
G4 P{fsensor_delay}
ENABLE_FSENSOR
G4 P{fsensor_delay}
CHECK_FSENSOR V=0 MSG="Please unload T{p} and resume."
{% endif %}
SYNC_TOOL TOOL={t}
MMMS_LOAD
G4 P{fsensor_delay}
ENABLE_FSENSOR
DISABLE_FSENSOR
G4 P{fsensor_delay}
ENABLE_FSENSOR
G4 P{fsensor_delay}
CHECK_FSENSOR V=1 MSG="Please load T{t} and resume." R=4
{% endif %}
SAVE_VARIABLE VARIABLE=p VALUE={t}
[gcode_macro ENABLE_FSENSOR]
gcode:
{% set fsensor = printer["gcode_macro MMMS_SETTINGS"].fsensor_name %}
SET_FILAMENT_SENSOR SENSOR={fsensor} ENABLE=1
[gcode_macro DISABLE_FSENSOR]
gcode:
{% set fsensor = printer["gcode_macro MMMS_SETTINGS"].fsensor_name %}
SET_FILAMENT_SENSOR SENSOR={fsensor} ENABLE=0
# Check filament sensor "fsensor" to match with provided V. Else notify the user and PAUSE.
[gcode_macro CHECK_FSENSOR]
gcode:
{% set v = params.V|int %}
{% set msg = params.MSG|string %}
{% set r = params.R|default(0)|int %}
{% set retry_dist = printer["gcode_macro MMMS_SETTINGS"].retry_dist %}
{% set retry_speed = printer["gcode_macro MMMS_SETTINGS"].retry_speed %}
{% set fsensor_delay = printer["gcode_macro MMMS_SETTINGS"].fsensor_delay %}
{% set fsensor = printer["gcode_macro MMMS_SETTINGS"].fsensor_name %}
{% set m117 = msg or "Sensor Check Fail" %}
{% if (printer["filament_switch_sensor "+(fsensor|string)].filament_detected|int) != v %}
{% if r != 0 %}
M117 Retry
M83
{% if r > 0 %}
G1 E{retry_dist} F{retry_speed}
{% set new_r = r - 1 %}
{% else %}
G1 E-{retry_dist} F{retry_speed}
{% set new_r = r + 1 %}
{% endif %}
ENABLE_FSENSOR
DISABLE_FSENSOR
ENABLE_FSENSOR
G4 P{fsensor_delay}
CHECK_FSENSOR V={v} MSG="{msg}" R={new_r}
{% else %}
M117 {m117}
PAUSE
{% endif %}
{% endif %}
# Set the sync of provided TOOL to SYNC with extruder
### --- Comment if using the 3MS instead of your printer's extruder --- ###
[gcode_macro SET_TOOL_SYNC]
gcode:
{% set tool = params.TOOL|int %}
{% set sync = params.SYNC|int %}
{% set motion_queue = "extruder" if sync == 1 else "" %}
SYNC_EXTRUDER_MOTION EXTRUDER=3ms{ tool } MOTION_QUEUE={ motion_queue }
{% if sync == 1 %}
SAVE_VARIABLE VARIABLE=synced VALUE={tool}
{% endif %}
### --- Comment if using the 3MS instead of your printer's extruder --- ###
# [gcode_macro SET_TOOL_SYNC]
# gcode:
# {% set tool = params.TOOL|int %}
# {% set sync = params.SYNC|int %}
# {% set ext_name = "3ms"+(tool|str) %}
# {% if tool == 0 %}
# {% set ext_name = "extruder" %}
# {% endif %}
# {% set motion_queue = "extruder" if sync == 1 else "" %}
# SYNC_EXTRUDER_MOTION EXTRUDER={ext_name} MOTION_QUEUE={ motion_queue }
# {% if sync == 1 %}
# SAVE_VARIABLE VARIABLE=synced VALUE={tool}
# {% endif %}
# Desync all tools, then sync provided TOOL to extruder
[gcode_macro SYNC_TOOL]
gcode:
{% set tool = params.TOOL|int %}
{% set num_tools = printer["gcode_macro MMMS_SETTINGS"].num_tools|int %}
{% for t in range(num_tools) %}
{% if t != tool %}
DESYNC_TOOL TOOL={t}
{% endif %}
{% endfor %}
SET_TOOL_SYNC TOOL={tool} SYNC=1
# Sync to current tool on Klipper startup
[delayed_gcode sync_startup]
initial_duration: 1.
gcode:
{% set p = printer.save_variables.variables.p|default(-1)|int %}
{% if p > -1 %}
SYNC_TOOL TOOL={p}
{% else %}
DESYNC_ALL_TOOLS
{% endif %}
# Desync provided TOOL from the extruder
[gcode_macro DESYNC_TOOL]
gcode:
{% set tool = params.TOOL|int %}
SET_TOOL_SYNC TOOL={tool} SYNC=0
SAVE_VARIABLE VARIABLE=synced VALUE=-1
# Set previous to -1 (no filament loaded)
[gcode_macro CLEAR_TOOL]
gcode:
SAVE_VARIABLE VARIABLE=p VALUE=-1
# Desync all tools from the extruder
[gcode_macro DESYNC_ALL_TOOLS]
gcode:
{% set num_tools = printer["gcode_macro MMMS_SETTINGS"].num_tools|int %}
{% for tool in range(num_tools) %}
DESYNC_TOOL TOOL={tool}
{% endfor %}
SAVE_VARIABLE VARIABLE=synced VALUE=-1
# Alias for Toolchange T=0
[gcode_macro T0]
gcode:
Toolchange T=0
# Alias for Toolchange T=1
[gcode_macro T1]
gcode:
Toolchange T=1
### Uncomment below if more than two tools
# # Alias for Toolchange T=2
# [gcode_macro T2]
# gcode:
# Toolchange T=2
# # Alias for Toolchange T=3
# [gcode_macro T3]
# gcode:
# Toolchange T=3