-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.cfg
419 lines (320 loc) · 12.6 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
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
[gcode_macro POWER_OFF]
gcode:
{% set STATE = printer.print_stats.state %}
{% set NOCHECK = params.NOCHECK | default(0) %}
{% if NOCHECK == "1" or (STATE != "printing" and STATE != "paused") %}
M118 Wait for cooldown extruder
SET_HEATER_TEMPERATURE HEATER="extruder"
TEMPERATURE_WAIT SENSOR="extruder" MAXIMUM=50
SET_PIN PIN=printer_ac VALUE=0
UPDATE_DELAYED_GCODE ID=_delayed_power_off DURATION=5
{% else %}
M118 Still printing or paused
{% endif %}
[delayed_gcode _delayed_power_off]
gcode:
{action_call_remote_method("shutdown_machine")}
[gcode_macro PAUSE]
rename_existing: PAUSE_BASE
gcode:
# {% set STATE = printer.print_stats.state %}
# {% if STATE != "paused" %}
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=1 TRANSMIT=1
SET_LED LED="extruder" RED=1 GREEN=0.65 BLUE=0 TRANSMIT=1 #orange, pause
M118 Pause print
PAUSE_BASE {rawparams}
# save extruder temperature
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=last_extruder_temp VALUE="{printer.extruder.target}"
_PARK
# {% endif %}
[gcode_macro M600]
description: Filament change
gcode:
PAUSE
UNLOAD_FILAMENT
M118 Change filament
[gcode_macro RESUME]
variable_last_extruder_temp: 0
rename_existing: RESUME_BASE
gcode:
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=1 TRANSMIT=1
M118 Resume print
# restore extruder temperature
SET_LED LED="extruder" RED=1 GREEN=0 BLUE=1 TRANSMIT=1 #purple, heatup
M118 Resume print, heat nozzle up to {last_extruder_temp}°C
M109 S{last_extruder_temp}
RESUME_BASE {rawparams}
SET_LED LED="extruder" RED=1 GREEN=1 BLUE=1 TRANSMIT=1 #white, print
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
variable_park: True
gcode:
M118 Cancel print
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=1 TRANSMIT=1
SET_LED LED="extruder" RED=0 GREEN=1 BLUE=1 TRANSMIT=1 #cyan, shutdown
_PARK
_SHUTDOWN
CANCEL_PRINT_BASE {rawparams}
SET_LED LED="extruder" RED=0 GREEN=1 BLUE=0 TRANSMIT=1 #green, ready
[gcode_macro START_PRINT]
description: Internal
Startcode to prepare a new printing
triggered by slicer
gcode:
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=1 TRANSMIT=1
SET_LED LED="extruder" RED=0 GREEN=0 BLUE=1 TRANSMIT=1 #blue, start
CLEAR_PAUSE
BED_MESH_PROFILE LOAD=default
#Get Bed and Extruder temperature from Slicer GCode
{% set BED_TEMP = params.BED_TEMP | default(60) | float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP | default(200) | float %}
{% set MIN_X = printer.toolhead.axis_minimum.x | float %}
{% set MIN_Y = printer.toolhead.axis_minimum.y | float %}
{% set MAX_X = printer.toolhead.axis_maximum.x | float %}
{% set MAX_Y = printer.toolhead.axis_maximum.y | float %}
#M118 Pre-Heat Nozzle ({EXTRUDER_TEMP*0.75}°C)
#M104 S{EXTRUDER_TEMP*0.75}
M118 Heat Bed ({BED_TEMP}°C)
{% set BED_TEMP_CURRENT = printer.heater_bed.temperature %}
SET_LED LED="extruder" RED=1 GREEN=0 BLUE=1 TRANSMIT=1 #purple, heatup
M190 S{BED_TEMP}
{% if BED_TEMP_CURRENT < BED_TEMP - 20 %}
M118 Wait 5 min for the bed temperature to settle
G4 P{ 5 * 60 * 1000 }
{% endif %}
SET_LED LED="extruder" RED=0 GREEN=0 BLUE=1 TRANSMIT=1 #blue, start
# Init
M83 # relative extrusion mode
G90 # use absolute coordinates
G92 E0 # reset extruder
# Home
{% if 'xy' in printer.toolhead.homed_axes %}
G28 Z
{% else %}
G28
{% endif %}
BED_MESH_CLEAR
BED_MESH_CALIBRATE PROFILE=adapt ADAPTIVE=1 #METHOD=scan
G0 Z25 F{15 * 60}
G0 X{MIN_X} Y{MAX_Y * 0.8} F{50 * 60}
SET_LED LED="extruder" RED=1 GREEN=0 BLUE=1 TRANSMIT=1 #purple, heatup
M118 Heat Nozzle ({EXTRUDER_TEMP}°C)
M104 S{EXTRUDER_TEMP}
M109 S{EXTRUDER_TEMP}
SET_LED LED="extruder" RED=0 GREEN=0 BLUE=1 TRANSMIT=1 #blue, start
_PRIME_LINE
M117
G92 E0 # reset extruder
# G90 # Reset to absolut mode
# M82
SET_LED LED="extruder" RED=1 GREEN=1 BLUE=1 TRANSMIT=1 #white, print
[gcode_macro END_PRINT]
description: Internal
Endcode to finalize made printing
triggered by slicer
variable_unload_filament: 0
variable_power_off: 0
gcode:
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=1 TRANSMIT=1
SET_LED LED="extruder" RED=0 GREEN=1 BLUE=1 TRANSMIT=1 #cyan, shutdown
M118 End print
_PARK
{% if unload_filament > 0 %}
UNLOAD_FILAMENT
{% endif %}
_SHUTDOWN
{% if power_off > 0 %}
SET_LED LED="extruder" RED=1 GREEN=1 BLUE=0 TRANSMIT=1 #orange, pause
SET_LED LED="chamber" RED=0.25 GREEN=0.25 BLUE=0 WHITE=0 TRANSMIT=1
M118 Power off after cooldown extruder
POWER_OFF NOCHECK=1
{% else %}
SET_LED LED="extruder" RED=0 GREEN=1 BLUE=0 TRANSMIT=1 #green, ready
{% endif %}
[gcode_macro UNLOAD_ON_END_PRINT]
description:
If ENABLED > 0, END_PRINT script unloads filament before shutdown
gcode:
{% set unload_enabled = params.ENABLED | default(1) %}
SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=unload_filament VALUE={unload_enabled}
[gcode_macro POWER_OFF_END_PRINT]
description:
If ENABLED > 0, END_PRINT script powers the machine of after end print
gcode:
{% set power_off_enabled = params.ENABLED | default(1) %}
SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=power_off VALUE={power_off_enabled}
[gcode_macro _SHUTDOWN]
description: Shutdown the printer
gcode:
G92 E0 # Reset Extruder
G90 # Reset to absolute mode
TURN_OFF_HEATERS
M106 S0 # Turn of extruder-fan
M220 S100 # Reset Speed factor override percentage to default (100%)
M221 S100 # Reset Extruder flow rate override percentage to default (100%)
M84 # Disable steppers # Solved by RUN_IDLE_TIMEOUT
[gcode_macro _PRIME_LINE]
description: Purges and wipes the Nozzle
gcode:
SAVE_GCODE_STATE NAME=_fd_prime_line_state_b
{% set MIN_X = printer.toolhead.axis_minimum.x | float %}
{% set MIN_Y = printer.toolhead.axis_minimum.y | float %}
{% set MAX_X = printer.toolhead.axis_maximum.x | float %}
{% set MAX_Y = printer.toolhead.axis_maximum.y | float %}
{% set START_X = MIN_X | float %}
{% set START_Y = MAX_Y * 0.8 | float %}
{% set START_Z = 25 | float %}
{% set DIAMETER_NOZZLE = printer.configfile.settings.extruder.nozzle_diameter | float %}
{% set DIAMETER_FILAMENT = printer.configfile.settings.extruder.filament_diameter | float %}
{% set MAX_CROSSSECTION = printer.configfile.settings.extruder.max_extrude_cross_section | float %} # 4.0 * DIAMETER_NOZZLE**2
{% set NOZZLE_VOLUME = 65 | float %}
{% set PI = 3.141592653589793 | float %}
{% set CROSSSECTION_NOZZLE = PI * DIAMETER_NOZZLE**2 / 4.0 | float %}
{% set CROSSSECTION_FILAMENT = PI * DIAMETER_FILAMENT**2 / 4.0 | float %}
{% set EXT_HEIGHT_DEFAULT = 0.75 * DIAMETER_NOZZLE | float %}
{% set EXT_WIDTH_DEFAULT = EXT_HEIGHT_DEFAULT + DIAMETER_NOZZLE | float %}
# {% set EXT_CROSSSECTION = EXT_WIDTH_DEFAULT * EXT_HEIGHT_DEFAULT | float %}
{% set EXT_CROSSSECTION = MAX_CROSSSECTION * 0.85 | float %}
{% set MOVE_LENGTH = NOZZLE_VOLUME / EXT_CROSSSECTION | float %}
{% set FILA_LENGTH = NOZZLE_VOLUME / CROSSSECTION_FILAMENT | float %}
G90 ; use absolute coordinates
G92 E0 ; reset extruder position
M83 # E Relative
M118 Purge Nozzle
G0 X{START_X} Y{START_Y} Z{START_Z} F{50 * 60} ; go to start position
G91
G1 E2 F{20 * 60} ; deretraction after the initial one before nozzle cleaning
G1 Y{"%.3f" % (-0.25 * MOVE_LENGTH)} Z{"%.3f" % ((-1.0 * START_Z) + EXT_HEIGHT_DEFAULT)} E{FILA_LENGTH * 0.25} F{8.5 * 60}
G1 Y{"%.3f" % (-0.25 * MOVE_LENGTH)} E{FILA_LENGTH * 0.25} F{8.5 * 60}
G1 Y{"%.3f" % (-0.25 * MOVE_LENGTH)} E{FILA_LENGTH * 0.25} F{11 * 60}
G1 Y{"%.3f" % (-0.25 * MOVE_LENGTH)} E{FILA_LENGTH * 0.25} F{13.5 * 60}
M118 Wipe Nozzle
G0 Y{"%.3f" % (-3)} Z{"%.3f" % (0.05 - EXT_HEIGHT_DEFAULT)} F{135 * 60} ; wipe, move close to the bed
G0 Y{"%.3f" % (-3)} Z{"%.3f" % (EXT_HEIGHT_DEFAULT - 0.05)} F{135 * 60} ; wipe, move quickly away from the bed
RESTORE_GCODE_STATE NAME=_fd_prime_line_state_b
[gcode_macro _PARK]
gcode:
SAVE_GCODE_STATE NAME=_fd_park_state
M118 Park extruder
{% set PARK_X = printer.toolhead.axis_minimum.x | float %}
{% set PARK_Y = printer.toolhead.axis_maximum.y * 0.8| float %}
{% set PARK_Z = printer.toolhead.position.z | float %}
{% if not (printer.toolhead.position.x == PARK_X and printer.toolhead.position.y == PARK_Y) %}
{% set PARK_Z = printer.toolhead.position.z + 50.0 | float %}
{% if PARK_Z > printer.toolhead.axis_maximum.z %}
{% set PARK_Z = printer.toolhead.axis_maximum.z %}
{% endif %}
# {% if printer.extruder.can_extrude %}
# M83 # relative extrusion
# G1 E-1 F{40 * 60} # retract filament
# {% endif %}
{% endif %}
G91
G0 Z3 F{15 * 60}
G90 # use absolute coordinates
G0 X{PARK_X} Y{PARK_Y} F{150 * 60} # move to corner of the bed to avoid ooze over centre
G0 Z{PARK_Z} F{15 * 60} # move to corner of the bed to avoid ooze over centre
RESTORE_GCODE_STATE NAME=_fd_park_state
[gcode_macro _RUN_IDLE_TIMEOUT]
description: Internal
Starts if idle timeout has expired
triggered by klipper
gcode:
{% if printer.pause_resume.is_paused %}
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=last_extruder_temp VALUE="{printer.extruder.target}"
M118 Idle timeout, hotend cooldown
M104 S0 # cooldown the hotend
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=1 TRANSMIT=1
{% else %}
M118 Idle timeout, poweroff
_SHUTDOWN
M84
SET_LED LED="chamber" RED=0 GREEN=0 BLUE=0 WHITE=0.25 TRANSMIT=1
{% endif %}
#[delayed_gcode _report_temp]
# initial_duration: 2.
[gcode_macro _report_temp]
gcode:
{% set BED_TEMP_CURRENT = printer.heater_bed.temperature %}
{% set BED_TEMP_TARGET = printer.heater_bed.target %}
{% set NOZZLE_TEMP_CURRENT = printer.extruder.temperature %}
{% set NOZZLE_TEMP_TARGET = printer.extruder.target %}
{% set NRED = 0 %}
{% set NGREEN = 0 %}
{% set NBLUE = 0 %}
{% set NWHITE = 0 %}
{% if NOZZLE_TEMP_TARGET < 35 %}
{% set NGREEN = 1 %}
{% else %}
{% if NOZZLE_TEMP_TARGET > NOZZLE_TEMP_CURRENT + 1 %}
{% set NRED = 1 %}
{% elif NOZZLE_TEMP_TARGET < NOZZLE_TEMP_CURRENT - 1 %}
{% set NBLUE = 1 %}
{% else %}
{% set NRED = 1 %}
{% set NGREEN = 1 %}
{% set NBLUE = 1 %}
{% endif %}
{% endif %}
{% set PNRED = 0 %}
{% set PNGREEN = 0 %}
{% set PNBLUE = 0 %}
{% set PNWHITE = 0 %}
{% if NOZZLE_TEMP_TARGET < 35 %}
{% set PNGREEN = 1 %}
{% else %}
{% if NOZZLE_TEMP_TARGET > NOZZLE_TEMP_CURRENT + 1 %}
{% set PNRED = 1 %}
{% elif NOZZLE_TEMP_TARGET < NOZZLE_TEMP_CURRENT - 1 %}
{% set PNBLUE = 1 %}
{% else %}
{% set PNWHITE = 1 %}
{% endif %}
{% endif %}
{% set PBRED = 0 %}
{% set PBGREEN = 0 %}
{% set PBBLUE = 0 %}
{% set PBWHITE = 0 %}
{% if BED_TEMP_TARGET < 35 %}
{% set PBGREEN = 1 %}
{% else %}
{% if BED_TEMP_TARGET > BED_TEMP_CURRENT + 1 %}
{% set PBRED = 1 %}
{% elif BED_TEMP_TARGET < BED_TEMP_CURRENT - 1 %}
{% set PBBLUE = 1 %}
{% else %}
{% set PBWHITE = 1 %}
{% endif %}
{% endif %}
SET_LED LED="extruder" RED={NRED} GREEN={NGREEN} BLUE={NBLUE} TRANSMIT=1
SET_LED LED="chamber" RED={PBRED} GREEN={PBGREEN} BLUE={PBBLUE} WHITE={PBWHITE} INDEX=1 TRANSMIT=0
SET_LED LED="chamber" RED={PBRED} GREEN={PBGREEN} BLUE={PBBLUE} WHITE={PBWHITE} INDEX=2 TRANSMIT=0
SET_LED LED="chamber" RED={PNRED} GREEN={PNGREEN} BLUE={PNBLUE} WHITE={PNWHITE} INDEX=3 TRANSMIT=0
SET_LED LED="chamber" RED={PNRED} GREEN={PNGREEN} BLUE={PNBLUE} WHITE={PNWHITE} INDEX=4 TRANSMIT=1
UPDATE_DELAYED_GCODE ID=_report_temp DURATION=2
[gcode_macro LOAD_FILAMENT]
description: KlipperScreen
variable_load_distance: 60
#variable_purge_distance: 10
gcode:
{% set speed = params.PURGE_SPEED | default(8 * 60) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 60 | default ( params.LOAD_SPEED ) %}
SAVE_GCODE_STATE NAME=load_filament_state
G91
G92 E0
G1 E{load_distance} F{300}
RESTORE_GCODE_STATE NAME=load_filament_state
[gcode_macro UNLOAD_FILAMENT]
description: KlipperScreen
variable_unload_distance: 20
#variable_purge_distance: 10
gcode:
{% set speed = params.PURGE_SPEED | default(8 * 60) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 60 | default ( params.UNLOAD_SPEED ) %}
SAVE_GCODE_STATE NAME=unload_filament_state
G91
G92 E0
G1 E2 F300
G1 E-{unload_distance} F{900} # fast-unload
RESTORE_GCODE_STATE NAME=unload_filament_state