-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflap_temp_control.cfg
371 lines (323 loc) · 15.6 KB
/
flap_temp_control.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#################################################################################################################
#############################################_____ _ __ ____ ############################################
############################################| ___| | \_\ | _ \ ############################################
########################################### | |_ | | /_\ | |_) |############################################
############################################| _| | |___ / _ \| __/ ############################################
############################################|_| |_____/_/ \_\_| ############################################
#################################################################################################################
#
# [Filament Loading À la Prusa]
#
# Project Page https://github.com/spooknik/FLAP
#
# V1.4 - Flap-ocalypse
#################################################################################################################
#################################################################################################################
[gcode_macro _TEMP_VARIABLES]
# Add or remove your own materials here. Format: ["ABS",240,220,100] ["Material",Load Temp, Min Load Temp, Bed Temp]
variable_materials: [["ABS",240,220,100],["ASA",260,240,105],["PETG",230,210,85],["PLA",215,200,60],
["FLEX",215,200,60],["PC",260,240,105],["PA",290,280,50]]
# NO TOUCH #
variable_user_load_temp: 0
variable_user_min_load_temp: 0
variable_user_bed_temp: 0
gcode:
# BEGIN LOAD #
[gcode_macro LOAD_PROMPT] # Thank you why_me!
gcode:
{% set materials = printer['gcode_macro _TEMP_VARIABLES'].materials %}
RESPOND TYPE=command MSG="action:prompt_begin Preheat for Load"
RESPOND TYPE=command MSG="action:prompt_text Insert filament and choose a material"
RESPOND TYPE=command MSG="action:prompt_button_group_start"
{% for idx in range(0, materials|length) %}
{% set s = "action:prompt_button " + materials[idx][0] + ' - ' + materials[idx][1]|string + '/' + materials[idx][3]|string + "|LOAD_FILAMENT INDEX='" + idx|string + "'" %} # Thank you Aubey!
RESPOND TYPE=command MSG="{s}"
{% endfor %}
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro LOAD_FILAMENT]
gcode:
{% set index = params.INDEX|int %}
{% set material = printer['gcode_macro _TEMP_VARIABLES'].materials[index] %}
RESPOND TYPE=command MSG=action:prompt_end # Close the prompt
M118 FLAP: {material[0]} Selected
SET_GCODE_VARIABLE MACRO=_TEMP_VARIABLES VARIABLE=user_load_temp VALUE={material[1]}
SET_GCODE_VARIABLE MACRO=_TEMP_VARIABLES VARIABLE=user_min_load_temp VALUE={material[2]}
SET_GCODE_VARIABLE MACRO=_TEMP_VARIABLES VARIABLE=user_bed_temp VALUE={material[3]}
# Save https://www.klipper3d.org/Command_Templates.html#save-variables-to-disk
# This is the only point where variables are written to disk. This is kept to a minimum.
SAVE_VARIABLE VARIABLE=user_load_temp VALUE={material[1]}
SAVE_VARIABLE VARIABLE=user_min_load_temp VALUE={material[2]}
SAVE_VARIABLE VARIABLE=user_bed_temp VALUE={material[3]}
filament_load
# END LOAD #
# BEGIN UNLOAD #
[gcode_macro UNLOAD_PROMPT] # Thank you why_me!
gcode:
{% set materials = printer['gcode_macro _TEMP_VARIABLES'].materials %}
RESPOND TYPE=command MSG="action:prompt_begin Preheat for unload"
RESPOND TYPE=command MSG="action:prompt_text Which material are you unloading?"
RESPOND TYPE=command MSG="action:prompt_button_group_start"
{% for idx in range(0, materials|length) %}
{% set s = "action:prompt_button " + materials[idx][0] + ' - ' + materials[idx][1]|string + '°C' + "|UNLOAD_FILAMENT INDEX='" + idx|string + "'" %} # Thank you Aubey!
RESPOND TYPE=command MSG="{s}"
{% endfor %}
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro UNLOAD_FILAMENT]
gcode:
{% set index = params.INDEX|int %}
{% set material = printer['gcode_macro _TEMP_VARIABLES'].materials[index] %}
RESPOND TYPE=command MSG=action:prompt_end # Close the prompt
M118 FLAP: {material[0]} Selected
SET_GCODE_VARIABLE MACRO=_TEMP_VARIABLES VARIABLE=user_load_temp VALUE={material[1]}
SET_GCODE_VARIABLE MACRO=_TEMP_VARIABLES VARIABLE=user_min_load_temp VALUE={material[2]}
SET_GCODE_VARIABLE MACRO=_TEMP_VARIABLES VARIABLE=user_bed_temp VALUE={material[3]}
filament_unload
# END UNLOAD #
# BEGIN PROMPTS #
[gcode_macro PURGE_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Loading Filament"
RESPOND TYPE=command MSG="action:prompt_text Is the filament loaded correctly?"
RESPOND TYPE=command MSG="action:prompt_footer_button YES|PURGE_FINISH|primary"
RESPOND TYPE=command MSG="action:prompt_footer_button PURGE MORE|TEMP_CHECK"
RESPOND TYPE=command MSG="action:prompt_footer_button RETRY|RETRY_LOAD_TEMP" # unloads and loads again
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro LOAD_RETRY_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Retry Loading"
RESPOND TYPE=command MSG="action:prompt_text Insert Filament and press OKAY to load"
RESPOND TYPE=command MSG="action:prompt_footer_button Okay|RETRY_LOAD2|primary"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro COLOR_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Color Change"
RESPOND TYPE=command MSG="action:prompt_text Press OKAY to unload filament."
RESPOND TYPE=command MSG="action:prompt_footer_button OKAY|COLOR_CHANGE|primary"
RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|CANCEL_MACRO|warning"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro RUNOUT_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Filament Runout Detected"
RESPOND TYPE=command MSG="action:prompt_text The print is paused. Press OKAY to unload."
RESPOND TYPE=command MSG="action:prompt_footer_button Unload|TEMP_CHECK_RUNOUT|primary" # Exit
RESPOND TYPE=command MSG="action:prompt_footer_button Cancel Print|CANCEL_MACRO|warning" #CANCEL_PRINT
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro INSERT_NEW_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Load New Filament"
RESPOND TYPE=command MSG="action:prompt_text Insert new filament and press OKAY to load"
RESPOND TYPE=command MSG="action:prompt_footer_button OKAY|TEMP_CHECK_RUNOUT2|primary" # Load
RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL PRINT|CANCEL_MACRO|warning" # #CANCEL_PRINT
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro RESTORE_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Filament Loaded"
RESPOND TYPE=command MSG="action:prompt_text Press OKAY to resume print."
RESPOND TYPE=command MSG="action:prompt_footer_button RESUME |RESUME_RUNOUT|primary" # Load
RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL PRINT|CANCEL_MACRO|warning" # #CANCEL_PRINT
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro NO_FILAMENT_PROMPT]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin No Filament Detected"
RESPOND TYPE=command MSG="action:prompt_text Please insert filament and press OKAY"
RESPOND TYPE=command MSG="action:prompt_footer_button OKAY|TEMP_CHECK_RUNOUT2|primary" # Next
RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|CANCEL_MACRO|warning" #CANCEL_PRINT
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro UNLOAD_COMPLETE]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Unload Complete"
RESPOND TYPE=command MSG="action:prompt_text Remove filament from printer and press Okay"
RESPOND TYPE=command MSG="action:prompt_footer_button Okay|UNLOAD_FINAL|primary"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro RESUME_READY]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Filament Loaded"
RESPOND TYPE=command MSG="action:prompt_text Press OKAY to resume print"
RESPOND TYPE=command MSG="action:prompt_footer_button Okay|UNLOAD_FINAL|primary"
RESPOND TYPE=command MSG="action:prompt_footer_button Cancel|CANCEL_MACRO|warning" #CANCEL_PRINT
RESPOND TYPE=command MSG="action:prompt_show"
# END PROMPTS #
[gcode_macro RETRY_LOAD_TEMP]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=0 # I dunno why, but if it works...
SET_GCODE_VARIABLE MACRO=_SENSOR_VARIABLES VARIABLE=load_retry VALUE=1
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
M118 FLAP: Checking if extruder is ready...
{% if (printer.extruder.target == 0) %}
#REHEAT_HOTEND_RUNOUT
M118 FLAP: Hotend not heated, reheating...
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={temp.user_load_temp}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp.user_load_temp}
M118 FLAP: Hotend heated
RETRY_LOAD
{% else %}
RETRY_LOAD
{% endif %}
[gcode_macro RETRY_LOAD]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
M118 FLAP: Unloading...
filament_unload_init
[gcode_macro RETRY_LOAD2]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
M118 FLAP: Checking if extruder is ready...
{% if (printer.extruder.target == 0) %}
M118 FLAP: Hotend not heated, reheating...
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={temp.user_load_temp}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp.user_load_temp}
M118 FLAP: Hotend heated
SET_GCODE_VARIABLE MACRO=_SENSOR_VARIABLES VARIABLE=load_retry VALUE=0
filament_load
{% else %}
SET_GCODE_VARIABLE MACRO=_SENSOR_VARIABLES VARIABLE=load_retry VALUE=0
filament_load
{% endif %}
[gcode_macro COLOR_CHANGE]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
M118 FLAP: Color Change Started
TEMP_CHECK_RUNOUT
[gcode_macro UNLOAD_FINAL]
gcode:
{% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %}
RESPOND TYPE=command MSG=action:prompt_end
{% if (sensor.load_retry == 1) %}
{% if (sensor.paused_state == 1) %}
LOAD_RETRY_PROMPT
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=0
M118 FLAP: Filament unload complete!
[gcode_macro TEMP_CHECK]
# Because we called a prompt while the hotend is heated we don't know how long it takes the user to interact
# Idle Timeout could have kicked in and the hotend could be cold.
# So we need to double check the temps are good.
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
M118 FLAP: Checking if extruder is ready...
#{% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target < temp.user_load_temp) %} # checking one last time for minimum extrusion temperature
#{% if printer.extruder.target < temp.user_load_temp %}
{% if(printer.extruder.target == 0) %}
REHEAT_HOTEND
M118 FLAP: Hotend not heated, reheating...
#{% elif printer.extruder.target = temp.user_load_temp %} maybe
{% else %}
filament_purge
M118 FLAP: Hotend heated, purging...
{% endif %}
[gcode_macro REHEAT_HOTEND]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={temp.user_load_temp}
M118 FLAP: Hotend reheating!
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp.user_load_temp}
M118 FLAP: Hotend ready!
filament_purge
[gcode_macro TEMP_CHECK_RUNOUT]
# Because we called a prompt while the hotend is heated we don't know how long it takes the user to interact
# Idle Timeout could have kicked in and the hotend could be cold.
# So we need to double check the temps are good.
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
M118 FLAP: Checking if extruder is ready...
{% if (printer.extruder.target == 0) %}
#REHEAT_HOTEND_RUNOUT
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={temp.user_load_temp}
M118 FLAP: Hotend reheating!
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp.user_load_temp}
M118 FLAP: Hotend ready!
filament_change_state2
{% else %}
filament_change_state2
M118 FLAP: Hotend is heated
{% endif %}
[gcode_macro REHEAT_HOTEND_RUNOUT]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={temp.user_load_temp}
M118 FLAP: Hotend reheating!
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp.user_load_temp}
M118 FLAP: Hotend ready!
filament_change_state2
[gcode_macro TEMP_CHECK_RUNOUT2]
# Because we called a prompt while the hotend is heated we don't know how long it takes the user to interact
# Idle Timeout could have kicked in and the hotend could be cold.
# So we need to double check the temps are good.
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
{% if (printer['filament_switch_sensor filament_sense'].filament_detected|lower == 'false')%} # Check if filament is acutally present
M118 FLAP: No filament loaded #test
INSERT_NEW_PROMPT # Go back a step
{% elif (printer.extruder.target == 0) %}
REHEAT_HOTEND_RUNOUT2
M118 Hotend not heated! Reheating...
{% else %}
filament_load_runout
M118 Hotend heated...
{% endif %}
#M118 Printer Extruder Target : { printer.extruder.target }
#M118 User Min Load temp : { temp.user_min_load_temp }
#M118 User Load temp : { temp.user_load_temp }
#{% if (printer.extruder.target == 0) %}
# REHEAT_HOTEND_RUNOUT2
# M118 Hotend not heated! Reheating...
#{% else %}
# filament_load_runout
# M118 Hotend heated...
#{% endif %}
[gcode_macro REHEAT_HOTEND_RUNOUT2]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={temp.user_load_temp}
M118 Hotend reheating!
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp.user_load_temp}
M118 Hotend ready!
filament_load_runout
[gcode_macro PURGE_FINISH]
gcode:
{% set temp = printer['gcode_macro _TEMP_VARIABLES'] %}
{% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %}
RESPOND TYPE=command MSG=action:prompt_end
UPDATE_DELAYED_GCODE ID=clear_unloadbusy DURATION=2 # Need to run this
M118 FLAP: Filament load complete!
{% if (sensor.cooldown_load|lower == 'true') %}
{% if sensor.runout_state == 0 %}
M118 FLAP: Setting Extruder temp to: {sensor.cooldown_load_temp}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={sensor.cooldown_load_temp}
{% endif %}
{% endif %}
{% if sensor.runout_state == 1 %}
{% if (sensor.auto_resume|lower == 'true') %}
M118 FLAP: Resuming Print
RESUME
{% endif %}
{% endif %}
[gcode_macro CANCEL_MACRO]
gcode:
RESPOND TYPE=command MSG=action:prompt_end
CANCEL_PRINT
M118 Print cancelled
[gcode_macro RUNOUT_STAGE] # This runs between RUNOUT_PROMPT and INSERT_NEW_PROMPT
gcode:
RESPOND TYPE=command MSG=action:prompt_end # Close the prompt
# Yea, this is just an info box.
[gcode_macro RESUME_STAGE] # This runs between RUNOUT_PROMPT and INSERT_NEW_PROMPT
gcode:
RESPOND TYPE=command MSG=action:prompt_end # Close the prompt
RESUME
M118 Print resuming...
[gcode_macro FILAMENT_LOAD_STAGE] # This runs between RUNOUT_PROMPT and INSERT_NEW_PROMPT
gcode:
RESPOND TYPE=command MSG=action:prompt_end # Close the prompt
filament_load