forked from xblax/flashforge_ad5m_klipper_mod
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmacros.cfg
526 lines (460 loc) · 19.2 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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# define overrides for Mainsail/Fluidd predefined macros - see client.cfg
[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos : True ; use custom park coordinates for x,y [True/False]
variable_custom_park_x : -105.0 ; custom x position; value must be within your defined min and max of X
variable_custom_park_y : -105.0 ; custom y position; value must be within your defined min and max of Y
variable_custom_park_dz : 10.0 ; custom dz value; the value in mm to lift the nozzle when move to park position
variable_speed_hop : 25.0 ; z move speed in mm/s
variable_speed_move : 300.0 ; move speed in mm/s
variable_user_cancel_macro: "_CANCEL_PRINT_WITH_AUDIO_WARNING"
variable_park_at_cancel : True ; allow to move the toolhead to park while execute CANCEL_PRINT [True/False]
variable_park_at_cancel_x : 105 ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True
variable_park_at_cancel_y : 105 ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True
variable_runout_sensor : "filament_switch_sensor runout_sensor"
gcode:
[gcode_macro START_PRINT]
gcode:
{% set bed_temp = params.BED_TEMP|default(60)|float %} ; bed temp, usually set by slicer
{% set extruder_temp = params.EXTRUDER_TEMP|default(200)|float %} ; extruder temp, usually set by slicer
{% set disable_priming = params.DISABLE_PRIMING|default(false) %} ; allow disabling of priming before print
{% set disable_skew = params.DISABLE_SKEW_CORRECT|default(false) %}; if true it will not apply the skew correction profile
{% set force_leveling = params.FORCE_LEVELING|default(false) %} ; if true it forces the bed level process
M140 S{bed_temp} ; start bed heating
SET_SKEW CLEAR=1 ; reset skew profile if loaded
SET_GCODE_OFFSET Z=0.0 ; reset the G-Code Z offset (adjust Z offset if needed)
G28 ; home the printer
# auto leveling, if no mesh loaded or force_leveling was set
{%if (not printer['bed_mesh'].profile_name) or force_leveling %}
AUTO_BED_LEVEL BED_TEMP={bed_temp} EXTRUDER_TEMP={extruder_temp}
{% endif %}
G90 ; use absolute coordinates
G1 Z10 F1800 ; move the nozzle near the bed
# wait for bed to reach temp, don't wait for stabilization
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_temp}
M109 S{extruder_temp} ; set and wait for nozzle to reach temperature
# prime nozzle before print if not disabled
{% if not disable_priming %}
_PRIME_NOZZLE
{% endif %}
# load skew profile
{% if not disable_skew %}
SKEW_PROFILE LOAD=skew_profile
{% endif %}
[gcode_macro _CANCEL_PRINT_WITH_AUDIO_WARNING]
gcode:
_COMMON_END_PRINT
M300 S116 P350
M300 S61 P1000
[gcode_macro END_PRINT]
gcode:
G91 ; relative positioning
G1 X-2 Y-2 E-5 F2000 ; move away while retracting filament
_COMMON_END_PRINT
PLAY_MIDI FILE="getitem.mid" C=0
[gcode_macro _COMMON_END_PRINT]
# _COMMON_END_PRINT is used by END_PRINT and CANCEL_PRINT
gcode:
SET_SKEW CLEAR=1
M104 S0 ; turn off extruder temperature
M140 S0 ; turn off bed temperature
M107 ; turn off part cooling fan
G90 ; absolute positioning
G1 X105 Y105 Z220 F1500 ; move near end stop position
M84 ; disable motors
# Use Pause/Resume for M24/M25
[gcode_macro M24]
rename_existing: M24.1
gcode:
{% if printer.pause_resume.is_paused %}
RESUME
{% else %}
M24.1
{% endif %}
[gcode_macro M25]
rename_existing: M25.1
gcode:
PAUSE
[gcode_macro _PRIME_NOZZLE]
gcode:
# Copied from Flashforge AD5M Orca Slicer Profile
G90
M83
G1 E-1.5 F800
G1 X110 Y-110 F6000
G1 E2 F800
G1 Y-110 X55 Z0.25 F4800
G1 X-55 E8 F2400
G1 Y-109.6 F2400
G1 X55 E5 F2400
G1 Y-110 X55 Z0.45 F4800
G1 X-55 E8 F2400
G1 Y-109.6 F2400
G1 X55 E5 F2400
G92 E0
[gcode_macro AUTO_BED_LEVEL]
gcode:
{% set bed_temp = params.BED_TEMP|default(60)|float %}
{% set extruder_temp = params.EXTRUDER_TEMP|default(200)|float %}
{% set profile = params.PROFILE|default("auto") %}
# clear old mesh and home if necessary
BED_MESH_CLEAR
{% if not "xyz" in printer.toolhead.homed_axes %}
G28
{% endif %}
# bed heating
G90 ; absolute coordinates
G1 Z10 F1800 ; raise bed
M140 S{bed_temp} ; set bed temp
# wait for bed to reach temp, don't wait for stabilization
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_temp}
LOAD_CELL_TARE ; reset tare before manual probe
# nozzle heating
M104 S{extruder_temp} ; set nozzle temperature
# wait for nozzle to reach temp, don't wait for stabilization
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={extruder_temp}
# wipe to left
G90 ; absolute coordinates
G1 X50 Y110 Z5 F18000 ; get into position
PROBE ; moove nozzle to bed
G91 ; relative position
G1 X-40 F900 ; wipe move left
# wipe to right
G90 ; absolute coordinates
G1 X-50 Y110 Z5 F18000 ; get into position
PROBE ; moove nozzle to bed
G91 ; relative position
G1 X40 F900 ; wipe move right
# wait for nozzle cooldown to 120°
M106 S255 ; turn on fan
M104 S0 ; turn of noozle heating
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=120
M107 ; turn off fan
# move to remove cold filament
G1 X10 F300
# start the calibration
BED_MESH_CALIBRATE PROFILE={profile}
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: _BED_MESH_CALIBRATE_ORIG
gcode:
G90 ; absolute coordinates
G1 Z2 F1800 ; move noozle near bed
LOAD_CELL_TARE ; reset tare before leveling
_BED_MESH_CALIBRATE_ORIG {rawparams}
[gcode_macro Z_OFFSET_APPLY_ENDSTOP]
# This macro is replaced because saving the z-offset to the endstop would not have the expected outcome
# on this printer. The endstop is separate from the probe. After bed leveling before print, the offset
# would be ineffective.
rename_existing: _Z_OFFSET_APPLY_ENDSTOP
gcode:
RESPOND MSG="Notice: z-offset should not be saved to endstop on this printer. This command runs Z_OFFSET_APPLY_PROBE instead."
Z_OFFSET_APPLY_PROBE
[gcode_macro LOAD_FILAMENT]
variable_load_distance: 125
gcode:
{% set speed = params.SPEED|default(450) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 60 %}
SAVE_GCODE_STATE NAME=load_state
G91
G92 E0
G1 E{load_distance} F{speed} ; extrude with 7.5mm/s
RESTORE_GCODE_STATE NAME=load_state
[gcode_macro UNLOAD_FILAMENT]
variable_unload_distance: 75
gcode:
{% set speed = params.SPEED|default(450) %}
SAVE_GCODE_STATE NAME=unload_state
G91
G92 E0
G1 E-{unload_distance} F{speed} ; unload
RESTORE_GCODE_STATE NAME=unload_state
[gcode_macro PURGE_FILAMENT]
variable_purge_distance: 25
gcode:
{% set speed = params.SPEED|default(450) %}
SAVE_GCODE_STATE NAME=purge_state
G91
G92 E0
G1 E{purge_distance} F{speed} ; purge
RESTORE_GCODE_STATE NAME=purge_state
[gcode_macro LOAD_MATERIAL]
description: Manual filament loading / change
variable_initial_target_temp: 0
gcode:
# save gcode state
SAVE_GCODE_STATE NAME=load_material_state
# save heating state
SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL VARIABLE=initial_target_temp VALUE={printer["extruder"].target}
_LOAD_MATERIAL_SELECT
[gcode_macro _LOAD_MATERIAL_SELECT]
gcode:
{% if not printer["extruder"].target >= printer.configfile.settings['extruder'].min_extrude_temp %}
# material selection
RESPOND TYPE=command MSG="action:prompt_begin Material Selection"
RESPOND TYPE=command MSG="action:prompt_text Select the material type to heat the nozzle."
RESPOND TYPE=command MSG="action:prompt_button_group_start"
RESPOND TYPE=command MSG="action:prompt_button PLA|_LOAD_MATERIAL_HEATUP TEMP=200|primary"
RESPOND TYPE=command MSG="action:prompt_button PETG|_LOAD_MATERIAL_HEATUP TEMP=230|primary"
RESPOND TYPE=command MSG="action:prompt_button ABS|_LOAD_MATERIAL_HEATUP TEMP=250|primary"
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Abort|_LOAD_MATERIAL_END"
RESPOND TYPE=command MSG="action:prompt_show"
{% else %}
# skip preheating dialog, but wait for target temp
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={printer["extruder"].target}
_LOAD_MATERIAL_ACTION
{% endif %}
[gcode_macro _LOAD_MATERIAL_HEATUP]
gcode:
{% set extruder_temp = params.TEMP|default(200)|float %}
M104 S{extruder_temp}
RESPOND TYPE=command MSG=action:prompt_end
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={extruder_temp}
_LOAD_MATERIAL_ACTION
[gcode_macro _LOAD_MATERIAL_ACTION]
gcode:
# loading / unloading
RESPOND TYPE=command MSG="action:prompt_begin Filament Loading"
RESPOND TYPE=command MSG="action:prompt_text Select filament loading action."
RESPOND TYPE=command MSG="action:prompt_button_group_start"
RESPOND TYPE=command MSG="action:prompt_button Load|LOAD_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button Unload|UNLOAD_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button Purge|PURGE_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Done|_LOAD_MATERIAL_END"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _LOAD_MATERIAL_END]
gcode:
RESPOND TYPE=command MSG="action:prompt_end"
# restore old temp
M104 S{printer["gcode_macro LOAD_MATERIAL"].initial_target_temp}
# restore gcode state
RESTORE_GCODE_STATE NAME=load_material_state
[gcode_macro _FILAMENT_RUNOUT_EVENT]
gcode:
PAUSE
M400
RESPOND TYPE=command MSG="action:prompt_begin Filament runout detected"
RESPOND TYPE=command MSG="action:prompt_text The filament sensor has detected filament runout. Please load filament and press resume."
RESPOND TYPE=command MSG="action:prompt_button_group_start"
RESPOND TYPE=command MSG="action:prompt_button Load|LOAD_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button Unload|UNLOAD_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button Purge|PURGE_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Resume|_INTERACTIVE_LOAD_END"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro M600]
gcode:
{% set X = params.X|default(printer['gcode_macro _CLIENT_VARIABLE'].custom_park_x)|float %}
{% set Y = params.Y|default(printer['gcode_macro _CLIENT_VARIABLE'].custom_park_y)|float %}
{% set Z = params.Z|default(printer['gcode_macro _CLIENT_VARIABLE'].custom_park_dz)|float %}
PAUSE X={X} Y={Y} Z_MIN={Z}
M400
RESPOND TYPE=command MSG="action:prompt_begin Filament change"
RESPOND TYPE=command MSG="action:prompt_text Filament change requested. Please load new filament and press resume."
RESPOND TYPE=command MSG="action:prompt_button_group_start"
RESPOND TYPE=command MSG="action:prompt_button Load|LOAD_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button Unload|UNLOAD_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button Purge|PURGE_FILAMENT|primary"
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Resume|_INTERACTIVE_LOAD_END"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _INTERACTIVE_LOAD_END]
gcode:
RESPOND TYPE=command MSG="action:prompt_end"
RESUME
[gcode_macro LOAD_CELL_TARE]
variable_success: 0
gcode:
# reset success
SET_GCODE_VARIABLE MACRO=LOAD_CELL_TARE VARIABLE=success VALUE=0
# try set tare, up to 10 times
{% for i in range(10) %}
_LOAD_CELL_TARE_IF_NO_SUCCESS
{% endfor %}
# final check if successfull
_LOAD_CELL_TARE_FINAL_CHECK
[gcode_macro _LOAD_CELL_TARE_IF_NO_SUCCESS]
gcode:
{% if not printer["gcode_macro LOAD_CELL_TARE"].success %}
_LOAD_CELL_TARE_SET
_LOAD_CELL_TARE_CHECK
{% endif %}
[gcode_macro _LOAD_CELL_TARE_SET]
gcode:
# Tare is set by toggeling _level_h1 pin
SET_PIN PIN=_level_h1 VALUE=0
G4 P500
M400
SET_PIN PIN=_level_h1 VALUE=1
G4 P500
M400
SET_PIN PIN=_level_h1 VALUE=0
G4 P500
M400
SET_PIN PIN=_level_h1 VALUE=1
G4 P500
M400
[gcode_macro _LOAD_CELL_TARE_CHECK]
gcode:
# If level check pin is set, tare is successfull.
{% if "PRESSED" in printer['gcode_button _check_level_pin'].state %}
SET_GCODE_VARIABLE MACRO=LOAD_CELL_TARE VARIABLE=success VALUE=1
{% endif %}
[gcode_macro _LOAD_CELL_TARE_FINAL_CHECK]
gcode:
# Check success
{% if printer["gcode_macro LOAD_CELL_TARE"].success %}
# Toggle level clear plin.
# No sure what the level clear pin does. But we do the same as the stock software.
SET_PIN PIN=_level_clear VALUE=0
G4 P10
M400
SET_PIN PIN=_level_clear VALUE=1
RESPOND TYPE=echo MSG="Load cell tare success."
# Else raise error
{% else %}
{action_raise_error("Load cell tare failed.")}
{% endif %}
[gcode_shell_command backlight]
command: setsid -f backlight
timeout: 1.
verbose: False
[gcode_macro LCD_ON]
description: Turn on the lcd screen and set the brightness in percent.
gcode:
{% set brightness = params.BACKLIGHT|default("50") %}
RUN_SHELL_COMMAND CMD=backlight PARAMS="{brightness}"
[gcode_macro LCD_OFF]
description: Turn off the lcd screen.
gcode:
LCD_ON BACKLIGHT=0
[gcode_shell_command audio_freq]
command: audio freq
timeout: 3
verbose: False
[gcode_shell_command audio_midi]
command: setsid -f audio midi
timeout: 30
verbose: False
[gcode_macro M300]
gcode:
# Use a default 1kHz tone if S is omitted.
{% set S = params.S|default(1000)|int %}
# Use a 10ms duration is P is omitted.
{% set P = params.P|default(10)|float %}
RUN_SHELL_COMMAND CMD=audio_freq PARAMS="-f {S} -d {P / 1000}"
[gcode_macro PLAY_MIDI]
gcode:
{% set FILE = params.FILE|default("getitem.mid")|string %}
{% set C = params.C|default(0)|string %}
RUN_SHELL_COMMAND CMD=audio_midi PARAMS="-m /usr/share/midis/{FILE} -c {C}"
[gcode_shell_command reboot-stock-system]
command: reboot-stock-system
timeout: 5
verbose: False
[gcode_macro REBOOT_STOCK_SYSTEM]
description: Reboot the printer to stock system.
gcode:
{% if printer["idle_timeout"].state == "Printing" %}
{action_raise_error("Not possible during print.")}
{% endif %}
RESPOND TYPE=command MSG="action:prompt_begin Question"
RESPOND TYPE=command MSG="action:prompt_text The printer will reboot and start the stock Flashforge system. Select REBOOT to continue."
RESPOND TYPE=command MSG="action:prompt_footer_button Abort|RESPOND TYPE=command MSG=action:prompt_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Reboot|_REBOOT_STOCK_SYSTEM|error"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _REBOOT_STOCK_SYSTEM]
gcode:
TURN_OFF_HEATERS
M84 ; disable stepper motors
RUN_SHELL_COMMAND CMD=reboot-stock-system
[gcode_shell_command remove-klipper-mod]
command: remove-klipper-mod -f
timeout: 5
verbose: False
[gcode_macro REMOVE_KLIPPER_MOD]
description: Reboot the printer to stock system.
gcode:
{% if printer["idle_timeout"].state == "Printing" %}
{action_raise_error("Not possible during print.")}
{% endif %}
RESPOND TYPE=command MSG="action:prompt_begin Question"
RESPOND TYPE=command MSG="action:prompt_text Klipper Mod will remove itself from the printer. All data related to the mod including G-Codes files will be lost. Select REMOVE to continue."
RESPOND TYPE=command MSG="action:prompt_footer_button Abort|RESPOND TYPE=command MSG=action:prompt_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Remove|_REMOVE_KLIPPER_MOD|error"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _REMOVE_KLIPPER_MOD]
gcode:
TURN_OFF_HEATERS
M84 ; disable stepper motors
RUN_SHELL_COMMAND CMD=remove-klipper-mod
## Shutdown commands
[gcode_shell_command stop-and-sync]
command: sh -c /usr/libexec/shutdown
timeout: 15
verbose: True
[gcode_shell_command shutdown-ad5m]
command: systemctl poweroff
timeout: 15
verbose: False
[gcode_macro SHUTDOWN]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Question"
RESPOND TYPE=command MSG="action:prompt_text Klipper Mod will shutdown. This will end any active prints. Are you sure?"
RESPOND TYPE=command MSG="action:prompt_footer_button Abort|RESPOND TYPE=command MSG=action:prompt_end"
RESPOND TYPE=command MSG="action:prompt_footer_button Shutdown|_SHUTDOWN_STAGE|error"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _POWER_OFF]
gcode:
SET_PIN PIN=_power_off VALUE=0
[gcode_macro _SHUTDOWN_BUTTON_TRIGGER]
variable_trigger_allowed: False
gcode:
{% if trigger_allowed %}
# Reset button state, otherwise only one trigger can occur
SET_PIN PIN=_clear_power_off VALUE=1
# There is a deboucing circuit which needs some delay
G4 P500
# Disable pin again otherwise on reset the button will be triggered 1-3 times
SET_PIN PIN=_clear_power_off VALUE=0
RESPOND TYPE=error MSG="Shutdown triggered by button"
SHUTDOWN
{% endif %}
[delayed_gcode _PRO_BUTTON_BOUNCE_GUARD]
# Guard is needed as the button might trigger 0-2 times on RESTART
initial_duration: 1
gcode:
SET_GCODE_VARIABLE MACRO=_SHUTDOWN_BUTTON_TRIGGER VARIABLE=trigger_allowed VALUE=True
[gcode_macro _SHUTDOWN_STAGE]
gcode:
# remove promt as sometimes it gets stuck in fluidd
RESPOND TYPE=command MSG=action:prompt_end
RUN_SHELL_COMMAND CMD=stop-and-sync
# power off will not do anything on a ad5m non pro
_POWER_OFF
RUN_SHELL_COMMAND CMD=shutdown-ad5m
[gcode_macro AUTO_SHUTDOWN]
gcode:
UPDATE_DELAYED_GCODE ID=AUTO_SHUTDOWN_CHECK DURATION=30
[delayed_gcode AUTO_SHUTDOWN_CHECK]
gcode:
{% if printer.idle_timeout.state == "Idle" or printer.idle_timeout.state == "Ready" %}
{% if printer.extruder.temperature < 50.0 and printer.heater_bed.temperature < 50.0 %}
{% if printer.extruder.target == 0.0 and printer.heater_bed.target == 0.0 %}
UPDATE_DELAYED_GCODE ID=AUTO_SHUTDOWN_CHECK DURATION=0
_SHUTDOWN_STAGE
{% else %}
UPDATE_DELAYED_GCODE ID=AUTO_SHUTDOWN_CHECK DURATION=2
{% endif %}
{% else %}
{% if printer.idle_timeout.state == "Printing" %}
UPDATE_DELAYED_GCODE ID=AUTO_SHUTDOWN_CHECK DURATION=0
{% else %}
{% if printer.extruder.target == 0.0 and printer.heater_bed.target == 0.0 %}
UPDATE_DELAYED_GCODE ID=AUTO_SHUTDOWN_CHECK DURATION=2
{% else %}
UPDATE_DELAYED_GCODE ID=AUTO_SHUTDOWN_CHECK DURATION=0
{% endif %}
{% endif %}
{% endif %}
{% endif %}