-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtooldock.cfg
96 lines (92 loc) · 3.27 KB
/
tooldock.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
#Tool docking init
[gcode_macro DOCK_INIT]
variable_tool_present: False
variable_tool_zone_x:0
variable_tool_zone_y:0
variable_tool_park_x:0
variable_tool_park_y:0
variable_tool_home_x:None
variable_tool_home_y:None
gcode:
# Tool Home is used to set a return location after performing a tool pickup.
# Otherwise the default behaviour is to return to the location the prior tool was in.
[gcode_macro TOOL_HOME]
default_parameter_HOME:None
gcode:
{% if HOME %}
{% set home=HOME.split(',') %}
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_home_x VALUE={ home[0]|float }
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_home_y VALUE={ home[1]|float }
{% endif %}
#TOOL_PICKUP will move to the defined ZONE,
[gcode_macro TOOL_PICKUP]
default_parameter_ZONE_X:0
default_parameter_ZONE_Y:0
default_parameter_PARK_X:0
default_parameter_PARK_Y:0
default_parameter_OFFSET_X:0
default_parameter_OFFSET_Y:0
default_parameter_OFFSET_Z:0
gcode:
SAVE_GCODE_STATE NAME=tool_pickup_state
{% set home = printer['gcode_move'].gcode_position %}
{% set home_x = printer["gcode_macro DOCK_INIT"].tool_home_x %}
{% set home_y = printer["gcode_macro DOCK_INIT"].tool_home_y %}
{% if home_x is none or home_y is none %}
{% set home_x = home.x %}
{% set home_y = home.y %}
{% endif %}
{ action_respond_info("home X%s Y%s Z%s" % (home.x, home.y, home.z)) }
#Drop the Z 5mm relative
G91;
G1 Z5;
#Set us back to absolute mode.
G90;
{% if printer["gcode_macro DOCK_INIT"].tool_present %}
#If we have a tool, drop it off
TOOL_DROPOFF
{% else %}
#If we don't have a tool but the lock is engaged, unlock it.
TOOL_UNLOCK
{% endif %}
#Move to tool zone.
G1 X{ZONE_X} Y{ZONE_Y} F7200;
#Park tool on posts.
G1 X{PARK_X} Y{PARK_Y} F3600;
#Lock Tool in place
TOOL_LOCK
#Move to tool zone.
G1 X{ZONE_X} Y{ZONE_Y} F3600;
#Save the state so we can drop the tool later.
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_zone_x VALUE={ZONE_X}
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_zone_y VALUE={ZONE_Y}
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_park_x VALUE={PARK_X}
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_park_y VALUE={PARK_Y}
#Mark that we have a tool.
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_present VALUE=True;
#Set tool Offsets
SET_GCODE_OFFSET X={OFFSET_X} Y={OFFSET_Y} Z={OFFSET_Z}
#Return back to our origin.
G1 X{home_x} Y{home_y} z{home.z} F3600;
RESTORE_GCODE_STATE NAME=tool_pickup_state
SET_GCODE_OFFSET X={OFFSET_X} Y={OFFSET_Y} Z={OFFSET_Z}
[gcode_macro TOOL_DROPOFF]
gcode:
SAVE_GCODE_STATE NAME=tool_dropoff_state
{% if printer["gcode_macro DOCK_INIT"].tool_present %}
SET_GCODE_OFFSET X=0 Y=0 Z=0
#Make sure we are in absolute mode.
G90
#Move to tool zone.
G1 X{printer["gcode_macro DOCK_INIT"].tool_zone_x} Y{printer["gcode_macro DOCK_INIT"].tool_zone_y} F7200;
#Park tool on posts.
G1 X{printer["gcode_macro DOCK_INIT"].tool_park_x} Y{printer["gcode_macro DOCK_INIT"].tool_park_y} F3600;
#Unlock
TOOL_UNLOCK
#Move to tool zone.
G1 X{printer["gcode_macro DOCK_INIT"].tool_zone_x} Y{printer["gcode_macro DOCK_INIT"].tool_zone_y} F3600;
#Set variable to indicate that tool is not present.
SET_GCODE_VARIABLE MACRO=DOCK_INIT VARIABLE=tool_present VALUE=False;
{% endif %}
RESTORE_GCODE_STATE NAME=tool_dropoff_state
SET_GCODE_OFFSET X=0 Y=0 Z=0