-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainsail.cfg
100 lines (85 loc) · 5.37 KB
/
mainsail.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
## Mainsail klipper macro definitions
##
## Copyright (C) 2022 Alex Zellner <alexander.zellner@googlemail.com>
##
## This file may be distributed under the terms of the GNU GPLv3 license
## Version 2.0
## add [include mainsail.cfg] to your printer.cfg
## Customization:
## copy the following macro to your printer.cfg (outside of mainsail.cfg)
#[gcode_macro _CLIENT_VARIABLE]
#variable_use_custom_pos : False ; use custom park coordinates for x,y [True/False]
#variable_custom_park_x : 0.0 ; custom x position; value must be within your defined min and max of X
#variable_custom_park_y : 0.0 ; custom y position; value must be within your defined min and max of Y
#variable_custom_park_dz : 2.0 ; custom dz value; the value in mm to lift the nozzle when move to park position
#variable_retract : 1.0 ; the value to retract while PAUSE
#variable_cancel_retract : 5.0 ; the value to retract while CANCEL_PRINT
#variable_speed_retract : 35.0 ; retract speed in mm/s
#variable_unretract : 1.0 ; the value to unretract while RESUME
#variable_speed_unretract : 35.0 ; unretract speed in mm/s
#variable_speed_hop : 15.0 ; z move speed in mm/s
#variable_speed_move : 100.0 ; move speed in mm/s
#variable_park_at_cancel : False ; allow to move the toolhead to park while execute CANCEL_PRINT [True,False]
## !!! Caution [firmware_retraction] must be defined in the printer.cfg if you set use_fw_retract: True !!!
#variable_use_fw_retract : False ; use fw_retraction instead of the manual version [True/False]
#gcode:
## After you uncomment it add your custom values
## You now can use your PAUSE macro direct in your M600 here a short example:
#[gcode_macro M600]
#description: Filament change
#gcode: PAUSE X=10 Y=10 Z_MIN=50
## That will park your head front left with a minimum hight of 50mm above the bed. If your head
## is already above 50mm it will use only the z_hop specified with dz.
[virtual_sdcard]
path: ~/printer_data/gcodes
on_error_gcode: CANCEL_PRINT
[pause_resume]
[display_status]
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
CANCEL_PRINT_BASE
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
{% set z = params.Z|default(10)|int %}
{% if printer['pause_resume'].is_paused|int == 0 %}
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE={z} ; set z hop variable for reference in resume macro
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=etemp VALUE={printer['extruder'].target} ; set hotend temp variable for reference in resume macro
SAVE_GCODE_STATE NAME=PAUSE ; save current print position for resume
PAUSE_BASE
{% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max
G91 ; relative positioning
G1 Z{z} F900 ; raise Z up by z hop amount
G1 E-3
{% else %}
{ action_respond_info("Pause zhop exceeds maximum Z height.") } ; if z max is exceeded, show message and set zhop value for resume to 0
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE=0
{% endif %}
G90 ; absolute positioning
_PARK_TOOL
SAVE_GCODE_STATE NAME=PAUSEPARK ; save parked position in case toolhead is moved during the pause (otherwise the return zhop can error)
SET_IDLE_TIMEOUT TIMEOUT=43200 ; set timeout to 12 hours
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
variable_zhop: 0
variable_etemp: 0
gcode:
# Parameters
{% set e = params.E|default(3)|int %}
{% if printer['pause_resume'].is_paused|int == 1 %}
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
{% if etemp > 0 %}
M109 S{etemp|int} ; wait for hotend to heat back up
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=100 ; go back to parked position in case toolhead was moved during pause (otherwise the return zhop can error)
G91 ; relative positioning
M83 ; relative extruder positioning
G1 Z{zhop * -1} E{e} F900 ; prime nozzle by E, lower Z back down
RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=100 ; restore position
RESUME_BASE ; resume print
{% endif %}