-
Notifications
You must be signed in to change notification settings - Fork 2
/
adv_filament_swap.cfg
741 lines (610 loc) · 22.7 KB
/
adv_filament_swap.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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
#####################################################
### ADVANCED FILAMENT SWAP by JACKSON92 #############
#####################################################
# Github: https://github.com/92jackson/mainsail-advanced-filament-swap
# Discord: https://discord.gg/e3eXGTJbjx
#####################################################
# This script provides guided M600 (filament change)
# for Mainsail (poss also compatible with Fluidd??)
#####################################################
# This script was inspired by Jay Lexx's MOM script
#####################################################
#####################################################
#
#
############################################
###--- SETUP ---############################
############################################
#
# STEP 1: Connect to your printer via SFTP
# STEP 2: Save this file in your config folder (i.e: home/pi/klipper_config/adv_filament_swap.cfg)
# STEP 3: Override index.html in /home/pi/mainsail with the one included with this script
# STEP 4: Include this file in your printer.cfg (i.e [include adv_filament_swap.cfg])
# OPTIONAL: Tweak any of the default values below in [ADVPAUSE_CFG] as required - from line #120
# OPTIONAL: Point your run-out pin to RUN_OUT in your printer.cfg
#
############################################
###--- USAGE IN CURA ---####################
############################################
# STEP 1) Extensions > Post Processing > Modify G-Code
# STEP 2) Add a script -> Filament Change
# STEP 3) Set "Layer" to the layer number you want the switch to occur
# STEP 4) Repeat Step 3 for however many changes you require (:
#
# N.B. You can also manaually send FILAMENT_SWAP in the console to
# trigger a filament swap.
#
############################################
###--- MACRO DESCRIPTIONS ---###############
############################################
#
# [ADVPAUSE_CFG]
# Runs M600/run out/load/unload/finish events
#
# [M600]
# Filament change code sent by slicer
#
# [RUN_OUT]
# ***Point your run-out pin to this macro in your printer.cfg***
#
# [FILAMENT_SWAP]
# Send this manually if you'd like to trigger a manual
# filament swap
#
# [LOAD_NEW]
# Purge long - new filament. Sent by the pop-up alerts.
#
# [PURGE_EXTRA]
# Purge short - new filament. Sent by the pop-up alerts.
#
# [FINISH_SWAP]
# Ends the filament swap process and resumes the print.
# Sent by the pop-up alerts.
#
# [PUSH_UPDATE]
# Handles messages sent to the console which are then read by my
# Alert generator in the replacement index.html
#
# [PAUSE] and [RESUME]
# Handles the actual pausing and resuming of the running print
#
# [M125]
# Park head
#
# [M701]
# Load filament
#
# [M702]
# Unload filament
#
# [LOW_TEMP_CHECK T]
# Heat up process & temperature processor
# uses printer’s [extruder] section max_temp & min_extrude_temp
#
# [IGNORE_M600 RESET=True]
# [IGNORE_M600] can be sent to the console during a print to ignore
# accidental M600 commands. Use RESET=True flag to listen to M600 commands again.
# Does not affect [RUN_OUT] or manual use of [FILAMENT_SWAP]
#
# [MAKE_NOISE]
# Plays sounds for M600 and [RUN_OUT] events. You can also add:
# MAKE_NOISE SOUND='END' to your print finish macro, enjoy (:
#
# [SILENT] silences [MAKE_NOISE] commands
# [SILENT RESET=True] resets [SILENT] commands
################################################################################################
# Delete sections [respond], [pause_resume] and [save_variables] if already in your printer.cfg
################################################################################################
[pause_resume]
recover_velocity: 100
[respond]
[save_variables]
filename: ~/variables.cfg
#######################
[gcode_macro ADVPAUSE_CFG]
#######################
##########################################################
##########################################################
##########################################################
### --- CUSTOMISE YOUR DEFAULT VALUES HERE ---############
##########################################################
##########################################################
##########################################################
variable_default_temp: 200
# Default temperature to heat up if M600 issued in terminal
# Ignored if a target temperature is already set at launch ( M104 / M109 )
# or started within a printjob
variable_cooldown: 1
# Whether the hotend should cool down or not when pause started
# 1 - Hotend cools down when paused (Recommended for safety)
# 0 - Hotend stays hot
variable_park_x: 0 # Ignored if 0 and printer.toolhead.axis_maximum.x is used instead
variable_park_y: 0 # Ignored if 0 and printer.toolhead.axis_maximum.y is used instead
# x and y park positions, only used if != 0
variable_park_z: 25
# mm to raise z from current height (this is a relative value)
variable_zmin: 50
# If current z height is below zmin (as an absolute value), head will lift to zmin ( as relative value) instead of park_z
# making it easier to clean the nozzle at that height
variable_load_new: 150
# mm to load filament (average length needed to purge out a totally different color)
variable_purge: 20
# Extract xx mm filament extra after loading if more purging is required to remove the old color
variable_unload: 300
# Total mm to unload filament (bowden tube length)
variable_unload_speed: 1000
# Speed at which filament is unloaded
variable_load_speed: 200
# Speed at which filament is loaded
variable_park_speed: 10000
# Speed at which hotend is moved to park position
variable_retract_park: 6.5
# Amount to retract on PAUSE to prevent oozing
# also used to as amount to extrude on RESUME
variable_timeout: 43200
# The time (S) the printer is allowed to wait
# for user input when [RUN_OUT] or [M600]
# 43200 == 12 hours, useful if you
# like to print overnight/while at work and
# you could miss the alert
########################################
###--- OUTPUT MESSAGES AND ALERTS ---###
########################################
#### Basic HTML can be used. Warning: Klipper will fail on certain special characters, so edit with caution ####
variable_homing_head_msg: "Homing the print head"
# Message pushed to console when PAUSE and homing, this will occur if you filament swap while the printer is in standby mode, not during a print
variable_parking_head_msg: "Parking the print head in the maintenance position"
# Message pushed to console when PAUSE and parking print head
variable_purge_msg: "Purging an extra 20mm of filament ..." #20mm refers to {purge} set above
variable_load_new_msg: "Loading 150mm of new filament ..." #150mm refers to {load_new} set above
variable_unload_msg: "Unloading your filament ..."
# Messages pushed to console when loading and unloading filament
variable_temp_set_msg: "The hotend's temperature is set to"
variable_heating_msg: "Heating the hotend to"
# Messages pushed to console when the hotend is heating to allow the filament load/unload
variable_alert_5999_msg: "<h1>Filament swap complete!</h1> <p>Resuming print, please wait.</p>"
# Message pushed to console when the filament swap is complete and the print is resuming
variable_alert_6001_msg: "<h1>Filament loaded!</h1> <p>Use <a class='command'>PURGE_EXTRA</a> to bleed more or <a class='command'>FINISH_SWAP</a> to resume printing.</p>"
# Message pushed to console when either LOAD_NEW or PURGE is complete
variable_alert_5998_alrt: "<h1>Your printer has run out of filament!</h1> <p><b>WARNING:</b> To prevent damage, the remaining filament needs to be pulled away from the run-out sensor before continuing <i>(grab the exposed filament between the run-out sensor and the extruder and pull upwards)</i>.</p><p>Then click <a class='command'>FILAMENT_SWAP</a> to start the filament replacement process."
variable_alert_5998_macro: "FILAMENT_SWAP"
# Pop up alert shown on RUN_OUT and the macro used for the button on that alert
variable_alert_5998_msg: "To resume printing, click <a class='command'>FILAMENT_SWAP</a>"
# Message pushed to console to indicate that the printer is waiting for input from the user on RUN_OUT
variable_alert_6000_alrt_a: "<h1>Your current filament is unloading.</h1> <p>Please wait ...</p>"
# Pop up alert shown on FILAMENT_SWAP/M600 to indicate that the filament is unloading
variable_alert_6000_alrt_b: "<h1>It's time to load in your new filament.</h1> <p>Manually pull the old filament from the extruder and then push your new filament through until it reaches the hotend.</p><ul><li><p>Use <a class='command'>LOAD_NEW</a> to bleed through 150mm of a new colour.</p></li><li><p>Use <a class='command'>PURGE_EXTRA</a> to push out 20mm extra.</p></li></ul><p>Once the new colour is fully bled through, click <a class='command'>FINISH_SWAP</a> to resume your print/state.</p>"
variable_alert_6000_macro_b: "LOAD_NEW::PURGE_EXTRA::FINISH_SWAP"
# Pop up alert shown once the filament has unloaded on FILAMENT_SWAP/M600
##########################################################
##########################################################
##########################################################
### --- YOU SHOULD NOT NEED TO EDIT PAST THIS POINT ---###
##########################################################
##########################################################
##########################################################
variable_temperature: 0
variable_curralertcount : 0
variable_ispaused : 0
variable_swapping : 0
variable_ignore_m600 : 0
gcode:
{% set NEWJOB = params.NEWJOB|default(6000)|int %}
{% set curralertcount = printer.save_variables.variables.alertcount %}
{% if curralertcount == null %}
{% set curralertcount = 0 %}
{% endif %}
{% if NEWJOB == 5998 %}
#Ignore run-out sensor if already swapping filament
{% if swapping == 0 %}
{% set curralertcount = curralertcount +1 %}
SAVE_VARIABLE VARIABLE=alertcount VALUE={curralertcount}
PUSH_UPDATE TYPE=1 COLOR="red" ALARM=true MACRO="{alert_5998_macro}" PUSH="{alert_5998_alrt}"
PAUSE
{% if cooldown|int == 1 %}
M104 S0
{% endif %}
PUSH_UPDATE PUSH="{alert_5998_msg}"
SET_IDLE_TIMEOUT TIMEOUT={timeout}
{% endif %}
{% endif %}
{% if (NEWJOB == 600 or NEWJOB == 6000) %}
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=swapping VALUE=1
{% set curralertcount = curralertcount +1 %}
SAVE_VARIABLE VARIABLE=alertcount VALUE={curralertcount}
PUSH_UPDATE TYPE=1 PUSH="{alert_6000_alrt_a}"
PAUSE
LOW_TEMP_CHECK T={temperature}
M702
{% set curralertcount = curralertcount +1 %}
SAVE_VARIABLE VARIABLE=alertcount VALUE={curralertcount}
PUSH_UPDATE TYPE=1 COLOR="green" ALARM=true MACRO="{alert_6000_macro_b}" PUSH="{alert_6000_alrt_b}"
{% if (NEWJOB == 600 and cooldown|int == 1) %}
M104 S0
{% endif %}
SET_IDLE_TIMEOUT TIMEOUT={timeout}
{% endif %}
{% if (NEWJOB == 6001 or NEWJOB == 6002) %}
{% if NEWJOB == 6001 %}
M701
{% else %}
M701 PURGE
{% endif %}
PUSH_UPDATE PUSH="{alert_6001_msg}"
{% endif %}
{% if NEWJOB == 5999 %}
PUSH_UPDATE TYPE=-1 PUSH="{alert_5999_msg}"
{% if temperature == 0 %}
M109 S0
{% else %}
M109 S{temperature}
{% endif %}
RESUME
{% endif %}
##################
[gcode_macro M600]
##################
gcode:
{% if printer["gcode_macro ADVPAUSE_CFG"].ignore_m600 == 0 %}
MAKE_NOISE SOUND='FILAMENT_SWAP'
ADVPAUSE_CFG NEWJOB=600
{% endif %}
#####################
[gcode_macro RUN_OUT]
#####################
# Point your run-out pin to this macro in your printer.cfg
description: Trigger a run-out alert
gcode:
{% if swapping == 0 %}
MAKE_NOISE SOUND='RUN_OUT'
ADVPAUSE_CFG NEWJOB=5998 # Run-out
{% else %}
M118 "error: Already running M600!"
{% endif %}
###########################
[gcode_macro FILAMENT_SWAP]
###########################
description: Triggers a change of filament
gcode:
ADVPAUSE_CFG NEWJOB=6000 # Starts manual swap
######################
[gcode_macro LOAD_NEW]
######################
description: Purges 300mm of filament
gcode:
ADVPAUSE_CFG NEWJOB=6001 # Load filament
#########################
[gcode_macro PURGE_EXTRA]
#########################
description: Purges 20mm of filament (use when reloading the same colour or when there's only a tiny bit of old colour still bleeding through the new)
gcode:
ADVPAUSE_CFG NEWJOB=6002 # Purge 20mm
#########################
[gcode_macro FINISH_SWAP]
#########################
description: Finish the filament change and resume print
gcode:
ADVPAUSE_CFG NEWJOB=5999 # Resume print
#########################
[gcode_macro PUSH_UPDATE]
#########################
variable_lastalert : 0
variable_currupdatecount : 0
gcode:
{% set UPDATE = params.PUSH %}
{% set TYPE = params.TYPE|default(0)|int %}
{% set ATTRBUILDER = "" %}
{% if TYPE == -1 %}
{% set ATTRBUILDER = "class='alert-usr-close'" %}
{% endif %}
{% if TYPE == 0 %}
{% set ATTRBUILDER = "class='soft-alert-usr'" %}
{% if params.TIMED is defined %}
{% set ATTRBUILDER = ATTRBUILDER + " eta='" + params.TIMED|default(60) + "'" %}
{% endif %}
{% endif %}
{% if TYPE == 1 %}
{% set ATTRBUILDER = "class='alert-usr'" %}
{% if params.MACRO is defined %}
{% set ATTRBUILDER = ATTRBUILDER + " macro='" + params.MACRO|default("") + "'" %}
{% endif %}
{% if params.COLOR is defined %}
{% set ATTRBUILDER = ATTRBUILDER + " color='" + params.COLOR|default("") + "'" %}
{% endif %}
{% if params.ALARM is defined %}
{% set ATTRBUILDER = ATTRBUILDER + " alarm='true'" %}
{% endif %}
{% endif %}
{% set curralertcount = printer.save_variables.variables.alertcount %}
{% if curralertcount == null %}
{% set curralertcount = 0 %}
{% endif %}
{% if curralertcount > lastalert %}
{% set currupdatecount = 0 %}
SET_GCODE_VARIABLE MACRO=PUSH_UPDATE VARIABLE=currupdatecount VALUE={currupdatecount}
SET_GCODE_VARIABLE MACRO=PUSH_UPDATE VARIABLE=lastalert VALUE={curralertcount}
{% endif %}
SET_GCODE_VARIABLE MACRO=PUSH_UPDATE VARIABLE=currupdatecount VALUE={currupdatecount + 1}
RESPOND TYPE=command MSG="<span alertid='{curralertcount}' push='{currupdatecount}' {ATTRBUILDER}>{UPDATE}</span>"
###################
[gcode_macro PAUSE]
###################
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
{% if printer["gcode_macro ADVPAUSE_CFG"].ispaused|int == 0 %}
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=temperature VALUE={printer.extruder.target}
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{printer["gcode_macro ADVPAUSE_CFG"].retract_park} F2100
{% endif %}
M125
{% endif %}
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=ispaused VALUE=1
####################
[gcode_macro RESUME]
####################
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{% else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
#{% if printer["gcode_macro ADVPAUSE_CFG"].swapping|int == 0 %}
#Extrude same amount which was retracted at Pause
G1 E{printer["gcode_macro ADVPAUSE_CFG"].retract_park} F2100
#{% else %}
#Extrude a small amount to account for new filament dripping from nozzle after swap
# G1 E2 F2100
#{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=ispaused VALUE=0
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=swapping VALUE=0
RESUME_BASE {get_params}
##################
[gcode_macro M125]
##################
gcode:
# if not yet homed
{% if printer.toolhead.homed_axes != "xyz" %}
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].homing_head_msg}"
G28
{% endif %}
##### set park positon for x,y,z #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 2.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 2.0 %}
{% if printer["gcode_macro ADVPAUSE_CFG"].park_x != 0 %}
{% set x_park = printer["gcode_macro ADVPAUSE_CFG"].park_x %}
{% endif %}
{% if printer["gcode_macro ADVPAUSE_CFG"].park_y != 0 %}
{% set y_park = printer["gcode_macro ADVPAUSE_CFG"].park_y %}
{% endif %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - printer["gcode_macro ADVPAUSE_CFG"].park_z) %}
{% if act_z < printer["gcode_macro ADVPAUSE_CFG"].zmin %}
{% set z_safe = printer["gcode_macro ADVPAUSE_CFG"].zmin %}
{% else %}
{% set z_safe = printer["gcode_macro ADVPAUSE_CFG"].park_z %}
{% endif %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].parking_head_msg}"
G91
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F{printer["gcode_macro ADVPAUSE_CFG"].park_speed|int}
##################
[gcode_macro M701]
##################
gcode:
M83
G92 E0.0
LOW_TEMP_CHECK
{% if params.PURGE is defined %}
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].purge_msg}" TIMED={(printer["gcode_macro ADVPAUSE_CFG"].purge|int / printer["gcode_macro ADVPAUSE_CFG"].load_speed|int) * 60}
G1 E{printer["gcode_macro ADVPAUSE_CFG"].purge|int} F{printer["gcode_macro ADVPAUSE_CFG"].load_speed|int}
{% else %}
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].load_new_msg}" TIMED={(printer["gcode_macro ADVPAUSE_CFG"].load_new|int / printer["gcode_macro ADVPAUSE_CFG"].load_speed|int) * 60}
G1 E{printer["gcode_macro ADVPAUSE_CFG"].load_new|int} F{printer["gcode_macro ADVPAUSE_CFG"].load_speed|int}
{% endif %}
# Retract a little to prevent ooze
G1 E-{printer["gcode_macro ADVPAUSE_CFG"].retract_park} F2100
G92 E0.0
# Wait 20s to make sure all G1 moves have completed before moving on. Poss bug with klipper moving on to next command before last G1 completed(?)
G4 S20
##################
[gcode_macro M702]
##################
gcode:
LOW_TEMP_CHECK
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].unload_msg}" TIMED={(printer["gcode_macro ADVPAUSE_CFG"].unload|int / printer["gcode_macro ADVPAUSE_CFG"].unload_speed|int) * 60}
G91
# Quickly push 15mm to prevent end being deformed on unload
G1 E15 F500
# Unload
G1 E-{printer["gcode_macro ADVPAUSE_CFG"].unload|int} F{printer["gcode_macro ADVPAUSE_CFG"].unload_speed|int}
G92 E0.0
G90
# Wait 20s to make sure all G1 moves have completed before moving on. Poss bug with klipper moving on to next command before last G1 completed(?)
G4 S20
############################
[gcode_macro LOW_TEMP_CHECK]
############################
gcode:
{% if not params.OVERRIDE is defined %}
{% if params.T is defined %}
{% set TMP=params.T|int%}
{% if printer.configfile.config.extruder.max_temp is defined %}
{% if params.T|int>printer.configfile.config.extruder.max_temp|int %}
{% set TMP=printer["gcode_macro ADVPAUSE_CFG"].default_temp|int %}
{% endif %}
{% endif %}
{% if TMP|int==0 %}
{% set TMP=printer["gcode_macro ADVPAUSE_CFG"].default_temp|int %}
{% endif %}
{% else %}
{% set TMP=printer["gcode_macro ADVPAUSE_CFG"].default_temp|int %}
{% if printer["gcode_macro ADVPAUSE_CFG"].temperature|int > 0 %}
{% set TMP=printer["gcode_macro ADVPAUSE_CFG"].temperature %}
{% endif %}
{% endif %}
{% if printer.configfile.config.extruder.min_extrude_temp is defined %}
{% if TMP|int<printer.configfile.config.extruder.min_extrude_temp|int %}
{% set TMP=printer["gcode_macro ADVPAUSE_CFG"].default_temp %}
{% endif%}
{% endif %}
{% else %}
{% if params.T is defined %}
{% set TMP=params.T|int %}
{% else %}
{% set TMP=printer["gcode_macro ADVPAUSE_CFG"].default_temp %}
{% endif %}
{% endif %}
# If extruder is hot enough/within -5 degrees celsius of the set temperature
{% if (printer.extruder.temperature|int + 5) >= TMP|int %}
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].temp_set_msg} {TMP}oC"
M104 S{TMP}
{% else %}
PUSH_UPDATE PUSH="{printer["gcode_macro ADVPAUSE_CFG"].heating_msg} {TMP}oC"
M109 S{TMP}
{% endif %}
#########################
[gcode_macro IGNORE_M600]
#########################
description: Ignore accidental M600 commands during print
gcode:
{% if params.RESET is defined %}
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=ignore_m600 VALUE=0
M118 Listening for M600 commands
{% else %}
SET_GCODE_VARIABLE MACRO=ADVPAUSE_CFG VARIABLE=ignore_m600 VALUE=1
M118 Ignoring M600 commands
{% endif %}
##################
[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(100)|int %}
SET_PIN PIN=beeper_pin VALUE=0.85 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=beeper_pin VALUE=0
####################
[gcode_macro SILENT]
####################
gcode:
{% if params.RESET is defined %}
SET_GCODE_VARIABLE MACRO=MAKE_NOISE VARIABLE=make_silent VALUE=False
M118 Listening for MAKE_NOISE commands
{% else %}
SET_GCODE_VARIABLE MACRO=MAKE_NOISE VARIABLE=make_silent VALUE=True
M118 Ignoring MAKE_NOISE commands
{% endif %}
########################
[gcode_macro MAKE_NOISE]
########################
description: Output tunes
variable_make_silent: False
gcode:
{% if make_silent != True %}
{% if params.SOUND == 'END' %}
M300 P251 S784 ; Cake?
M300 P249 S740
M300 P249 S659
M300 P252 S659
M300 P267 S740
M300 P250 S294
M300 P249 S370
M300 P251 S294
M300 P251 S247
M300 P249 S294
M300 P249 S370
M300 P252 S294
M300 P267 S220
M300 P250 S294
M300 P249 S370
M300 P251 S440
M300 P251 S784
M300 P249 S740
M300 P249 S659
M300 P252 S659
M300 P267 S220
M300 P250 S740
M300 P249 S370
M300 P251 S294
M300 P251 S587
M300 P249 S294
M300 P249 S659
M300 P252 S440
M300 P267 S220
M300 P250 S294
M300 P249 S370
M300 P251 S294
M300 P251 S247
M300 P249 S294
M300 P249 S370
M300 P252 S440
M300 P267 S659
M300 P250 S330
M300 P249 S740
M300 P251 S784
M300 P251 S247
M300 P249 S330
M300 P249 S659
M300 P252 S554
M300 P267 S220
M300 P250 S587
M300 P249 S392
M300 P251 S330
M300 P251 S659
M300 P249 S330
M300 P249 S440
M300 P252 S440
M300 P267 S220
M300 P498 S740
{% elif params.SOUND == 'RUN_OUT' %}
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
{% elif params.SOUND == 'FILAMENT_SWAP' %}
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
M300 S900 P300
{% endif %}
{% endif %}