-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmacros_filament.cfg
253 lines (232 loc) · 13.2 KB
/
macros_filament.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
##### Sourced from zellneralex
#[firmware_retraction]
#retract_length: 0.75 ; length of filament (in mm) at G10/G11
#unretract_extra_length: 0 ; length of additional filament (in mm) at G11
#retract_speed: 50
#unretract_speed: 30
# Copied in unmodified
[gcode_macro _FILAMENT_BALL]
description: Helper: Round the filament tip
gcode:
G92 E0 ; zero the extruder
M83 ; relative extrusion
G1 E2 F{printer['gcode_macro _USER_VARIABLE'].speed.retract * 2}
G1 E-2
G1 E4
G1 E-4
G1 E8
G1 E-8
G1 E-25
G4 P{params.WAIT|default(0)|int * 1000}
[gcode_macro LOAD_FILAMENT]
description: Load filament. Usage: LOAD_FILAMENT [INDEX=index(current index)]
gcode:
# Load saved filament, by index or current index. If no list defined, error out.
{% if not printer.save_variables.variables.filament %}
RESPOND TYPE=error MSG="FILAMENT: No Filament array defined. See ADD_FILAMENT. Aborted."
{% else %}
# Load the filament array, check that
{% set filament = printer.save_variables.variables.filament %}
{% set _idx = params.INDEX|default(filament.index)|int %}
{% set runout = params.RUNOUT|default("false")|lower %}
{% if _idx < 0 or _idx > filament.array|length %}
{% set _out="FILAMENT: Index out of range [0..%d]. Aborted." % (filament.array|length-1) %}
RESPOND TYPE=error MSG="{_out}"
{% else %}
{% if _idx != filament.index %}
SET_FILAMENT INDEX=_idx
{% endif %}
{% set user = printer['gcode_macro _USER_VARIABLE'] %} ; load the user variable objects
{% set pos = printer['gcode_macro _USER_VARIABLE'].purge.purge %} ; load purge position?
{% set move_z = [user.z_hop,printer.toolhead.position.z]|max %} ; calc movement high (get minimum of z_hop above bed)
{% if printer.idle_timeout.state != "Printing" or printer.pause_resume.is_paused|lower == "true" %}
_CG28 ; home if not already homed
LED_LOADING
G90 ; absolute positioning
{% if runout == "false" %}
G1 Z{move_z} F{user.speed.z_hop} ; move head to min
{% endif %}
{% if not printer.extruder.can_extrude or (printer['extruder'].temperature < filament.array[_idx].hotend) %}
{% set _out="Extruder temp too low. Heating to %3.1fC" % ([printer.configfile.settings.extruder.min_extrude_temp,filament.array[filament.index].hotend]|max) %}
RESPOND TYPE=error MSG="{_out}"
LED_TOOLHEAD_HEATING
M109 S{[printer.configfile.settings.extruder.min_extrude_temp,filament.array[filament.index].hotend]|max}
LED_BUSY
{% endif %}
{% if runout == "false" %} #shift to move to purge bucket first
G1 Z{move_z} F{user.speed.z_hop} ; Move Z to higher of z_hop or current toolhead position (get toolhead to minimum of z_hop)
G1 X{pos.x} Y{pos.y} F{user.speed.travel} ; Move to purge bucket
{% endif %}
M83 ; Set to extruder relative
G1 E{user.filament.load_distance} F{user.speed.load} ; Quickly load filament
G1 E{user.filament.load_extrude} F{user.speed.retract} ; Slower final load
G1 E-{user.filament.retract.pause} ; Pull back a bit
G1 E{user.filament.load_extrude * 1.5} F{user.speed.retract} ; Purge old filament
{% if runout == "false" %}
CLEAN_NOZZLE
G1 Z{move_z} F{user.speed.z_hop}
{% endif %}
G1 E-{user.filament.retract.end} ; Retract to PRINT_END position
M109 S{printer.extruder.target} ; Restore old extruder temperature
PARK P=bed
RESPOND MSG="Filament loaded."
SAVE_VARIABLE Variable=filament_loaded VALUE=True
{% if not printer.gcode_move.absolute_coordinate %} G91 {% endif %} ; Set printer to relative
{% if printer.gcode_move.absolute_extrude %} M82 {% endif %} ; Set extruder to absolute
{% else %}
RESPOND TYPE=command MSG="Filament loading disabled while printing!"
{% endif %}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
{% if runout == "false" %}
LED_STANDBY
{% endif %}
{% endif %}
{% endif %}
[gcode_macro UNLOAD_FILAMENT]
description: Unload filament
gcode:
{% set user = printer['gcode_macro _USER_VARIABLE'] %} # load the user variable objects
{% if printer.save_variables.variables.filament %}
{% set filament = printer.save_variables.variables.filament %}
{% else %}
{% set filament = {'array': [{'name': Undef, 'hotend': printer.configfile.settings.extruder.min_extrude_temp, 'bed': 0}], 'index': 0} %}
{% endif %}
LED_UNLOADING
{% if printer.idle_timeout_state != "Printing" or printer.pause_resume_is_paused|lower == "true" %}
{% if not printer.extruder.can_extrude %} # is extruder min temp to extrude, heat up if not
{% set _out="Extruder temp too low. Heating to %3.1fC" % ([printer.configfile.settings.extruder.min_extrude_temp,filament.array[filament.index].hotend]|max) %}
RESPOND TYPE=error MSG="{_out}"
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
LED_TOOLHEAD_HEATING
M109 S{[printer.configfile.settings.extruder.min_extrude_temp,filament.array[filament.index].hotend]|max}
LED_BUSY
{% endif %}
_FILAMENT_BALL WAIT=3 # Create ball filament tip
G1 E-{user.filament.unload_distance} F{user.speed.load} # Retract the filament
M109 S{printer.extruder.target} # Restore old extruder temperature
park P=bed # Move tool head to center bed to ease new filament insertion
RESPOND MSG="Filament unloaded"
SAVE_VARIABLE VARIABLE=filament_loaded VALUE=False
PARK P=bed
{% if printer.gcode_move.absolute_extrude %} M82 {% endif %} # set extruder back to absolute
{% else %}
RESPOND TYPE=command MSG="Filament unloading disabled while printing!"
{% endif %}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
LED_STANDBY
[gcode_macro ADD_FILAMENT]
description: Add a filament to the list. Usage: ADD_FILAMENT [NAME=name(New)] [HOTEND=hotend_temp(150)] [BED=bed_temp(50)]
gcode:
{% set name = params.NAME|default('New')|string %}
{% set hotend = params.HOTEND|default(150)|float|round(1) %}
{% set bed = params.BED|default(50)|float|round(1) %}
{% if not printer.save_variables.variables.filament %}
RESPOND TYPE=command MSG="FILAMENT: Initialize Filament Array"
{% set _out="Add filament: %s with hotend temp: %3.1fC and bed temp: %3.1fC at INDEX 0" % (name,hotend,bed) %}
RESPOND TYPE=command MSG="{_out}"
{% set filament = {'array': [{'name': name, 'hotend': hotend, 'bed': bed}], 'index': 0} %}
{% else %}
{% set filament = printer.save_variables.variables.filament %}
{% set _out="FILAMENT: Add filament: %s with hotend temp: %3.1fC and bed temp: %3.1fC at INDEX %d" % (name,hotend,bed,filament.array|length) %}
RESPOND MSG="{_out}"
{% set _dummy = filament.array.append({'name': name, 'hotend': hotend, 'bed': bed}) %}
{% endif %}
SAVE_VARIABLE VARIABLE=filament VALUE="{filament}"
[gcode_macro REMOVE_FILAMENT]
description: Remove a filament from the list. Usage: REMOVE_FILAMENT INDEX-index
gcode:
{% if not printer.save_variables.variables.filament %}
RESPOND TYPE=error MSG="FILAMENT: No Filament array defined. Aborted.")
{% else %}
{% set filament = printer.save_variables.variables.filament %}
{% if 'INDEX' not in params|upper %}
RESPOND TYPE=error MSG="FILAMENT: No INDEX defined, use REMOVE_FILAMENT INDEX=index. Aborted.")
{% elif filament.array|length == 1 or params.INDEX|int == filament.index %}
RESPOND TYPE=error MSG="FILAMENT: Last or active filament can not be removed. Aborted.")
{% elif params.INDEX|int < 0 or params.INDEX|int > filament.array|length %}
{% set _out="FILAMENT: Index out of range [0..%d]. Aborted." % (filament.array|length-1) %}
RESPOND TYPE=error MSG="{_out}"
{% else %}
{% set _out="FILAMENT: Remove filament with INDEX %d from list " % (params.INDEX|int) %}
RESPOND MSG="{_out}"
{% set _dummy = filament.array.pop(params.INDEX|int) %}
SAVE_VARIABLE VARIABLE=filament VALUE="{filament}"
{% endif %}
{% endif %}
[gcode_macro LIST_FILAMENTS]
description: List all saved filaments.
gcode:
{% if not printer.save_variables.variables.filament %}
RESPOND TYPE=error MSG="FILAMENT: No filament array defined. Aborted.")
{% else %}
{% set filament = printer.save_variables.variables.filament %}
{% set _out="Active Filament: %s" % (filament.array[filament.index].name) %}
RESPOND TYPE=command MSG="{_out}"
{% for elem in range(filament.array|length)|reverse %}
{% set _out="INDEX: %d -> %s -> hotend: %3.1fC -> bed: %3.1fC" % (elem, filament.array[elem].name, filament.array[elem].hotend, filament.array[elem].bed) %}
RESPOND TYPE=command MSG="{_out}"
{% endfor %}
RESPOND TYPE=command MSG="FILAMENT: Defined Filaments"
{% endif %}
[gcode_macro SET_FILAMENT]
description: Set active filament. Usage: SET_FILAMENT INDEX=index
gcode:
{% if not printer.save_variables.variables.filament %}
RESPOND TYPE=error MSG="FILAMENT: No Filament array defined. Aborted."
{% else %}
{% set filament = printer.save_variables.variables.filament %}
{% set _idx = params.INDEX|default(filament.index)|int %}
{% if 'INDEX' not in params|upper %}
RESPOND TYPE=error MSG="FILAMENT: No INDEX defined, use SET_FILAMENT INDEX=index. Aborted."
{% elif _idx < 0 or _idx >= filament.array|length %}
{% set _out="FILAMENT: Index out of range [0..%d]. Aborted." % (filament.array|length-1) %}
RESPOND TYPE=error MSG="{_out}"
{% else %}
{% set _dummy = filament.update({'index': _idx}) %}
SAVE_VARIABLE VARIABLE=filament VALUE="{filament}"
{% set _out="FILAMENT: Set filament: %s with hotend: %3.1fC, bed: %3.1fC" %
(filament.array[filament.index].name,filament.array[filament.index].hotend,filament.array[filament.index].bed) %}
RESPOND MSG="{_out}"
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
{% endif %}
{% endif %}
# Inspired by zellneralex--reduced to one prime line
#OBSOLETE with KAMP
# [gcode_macro PRIME_LINE]
# description: Purge nozzle at defined position
# gcode:
# {% set user = printer["gcode_macro _USER_VARIABLE"] %}
# {% set prime = user.prime %}
# {% set prime_height = params.PRIME_HEIGHT|default(prime.pos.z ) %} ; Get prime line height parameter or set default
# {% set move_z = [user.z_hop, printer.toolhead.position.z]|max %} ; Calc movement high -- largest of user variable or current toolhead position
# {% if prime.dir|string == "X+" %}
# {% set line = 'X%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %}
# {% elif prime.dir|string == "X-" %}
# {% set line = 'X-%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %}
# {% elif prime.dir|string == "Y+" %}
# {% set line = 'Y%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %}
# {% elif prime.dir|string == "Y-" %}
# {% set line = 'Y-%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %}
# {% else %}
# {action_raise_error("_USER_VARIABLE.prime.dir is not specified as X+, X-, Y+, or Y-")}
# {% endif %}
# RESPOND TYPE=command MSG="Prime Line"
# _CG28 ; Home if not already homed
# G92 E0 ; Reset extruder
# G90 ; Absolute positioning
# G1 Z{move_z} F{user.speed.z_hop} ; Move toolhead up
# G1 X{prime.pos.x} Y{user.prime.pos.y} F{user.speed.travel} ; Move to start position
# G1 Z{prime_height} F{user.speed.z_hop} ; Move toolhead down
# G91 ; Relative positioning
# {% for segment in range(prime.seg|int) %} ; Draw line
# G1 {line}
# {% endfor %}
# G1 E -{user.filament.retract.end} F{user.speed.retract} ; quick retract to break loose
# G1 Z{move_z} F{user.speed.z_hop} ; Move toolhead up
# G1 E {user.filament.retract.end} F{user.speed.retract} ; return filament to nozzle
# G90 ; Absolute positioning
# G1 X{user.park.center.x} Y{user.park.center.y} F{user.speed.travel} ; Move to center bed
# G92 E0 ; Reset extruder
# {% if not printer.gcode_move.absolute_coordinate %} G91 {% endif %} ; Set printer back to relativbe
# {% if printer.gcode_move.absolute_extrude %} M82 {% endif %} ; Set extruder back to absolute
# UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1