forked from strayr/strayr-k-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpause_park.cfg
114 lines (97 loc) · 4.31 KB
/
pause_park.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
###############################################################################
#
# PAUSE and PARK
#
# Implemlents a PARK command that moves the toolhead and bed somewhere safe
# using minimum and maximum axis data from the config file so it should
# work without additional configuration. For use in PAUSE, CANCEL_PRINT,
# END_PRINT, START_PRINT, M600 etc,. Anywhere we need to put the toolhead
# somewhere safe.
#
# Consider https://github.com/mainsail-crew/MainsailOS/blob/master/src/modules/mainsail/filesystem/home/pi/klipper_config/mainsail.cfg
# it is newer and potentially better maintained.
#
# PAUSE and RESUME save position, do a retract and park.
#
# Use the following lines in you your printer cfg
# [include strayr-k-macros/common.cfg] # only needed once
#
# PAUSE and RESUME use the Save Variables functionality for thier retraction
# behaviour, I shall add some standaline versions that require direct editing.
#
# For standalone use replace this line
# {% set e = svv.filament_pause_retraction|float %} #comment out this line if you want a standalone macro
# With a hard coded value
# {% set e = 3|float %}
#
####
[pause_resume] # Required, harmless to define twice
[display_status] # Helpful, can remove if no display
[gcode_macro PARK]
gcode:
{% set z_max = printer.toolhead.axis_maximum.z %}
{% set z_pos = printer.toolhead.position.z %}
{% set y_max = printer.toolhead.axis_maximum.y %}
{% set y_min = printer.toolhead.axis_minimum.y %}
{% set x_min = printer.toolhead.axis_minimum.x %}
{% set travel_speed = printer.toolhead.max_velocity * 0.7 * 60 %}
{% set z_travel_speed = printer.configfile.settings.printer.max_z_velocity * 60 %}
{% set park_height = (z_max*0.65)|int %}
## This sets your park position, it should be safe, BUT test carfully
## It uses the data from printer.toolhead which is the live data on where the toolhead can be moved
## If this gets it wrong, check your config file for min/max positions is correct
{% set x = params.X|default(x_min + 5) %} #edit to your park position
{% set y = params.Y|default(y_min + 5) %} #edit to your park position
{% set z = params.Z|default(park_height)|float %} #edit to your park position
{% if z_pos > (z_max ) %}
M117 Z {z_pos} Cant raise
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
{% elif z_pos > park_height + 0.04 %}
#M117 Z {z_pos} goto { (( z_max - 10 - z_pos) * 0.5 ) + z_pos }
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
G1 Z { (( z_max - 10 - z_pos) * 0.5 ) + z_pos } F600
{% elif z_pos < park_height -0.04 %}
#M117 Z {z_pos} goto {park_height}
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
G1 Z {z} F{z_travel_speed}
{% else %}
M117 I think we are already at park height
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
{% endif %}
G1 Y {y} X {x} F{travel_speed}
[gcode_macro PRESENT]
gcode:
{% set my_y = printer.toolhead.axis_maximum.y - 5 %}
PARK Y={my_y}
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
##### set defaults #####
{% set svv = printer.save_variables.variables %}
{% set e = svv.filament_pause_retraction|float %} #comment out this line if you want a standalone macro
# {% set e = 3|float %} #and uncomment this one
{% set x = params.X|default(printer.toolhead.axis_minimum.x + 2 ) %} #edit to your park position
{% set y = params.Y|default(printer.toolhead.axis_minimum.y + 2) %} #edit to your park position
##### end of definitions #####
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
{%if printer.extruder.can_extrude %}
G91
G1 E-{e} F2100 #negative for retraction
G90
{% endif %}
PARK X={x} Y={y}
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
##### set defaults #####
{% set svv = printer.save_variables.variables %}
{% set e = svv.filament_pause_retraction|float %} #comment out this line if you want a standalone macro
# {% set e = 3|float %} #and uncomment this one
{%if printer.extruder.can_extrude %}
G91
G1 E{e} F2100 #we really want a positive extrude here
G90
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME