-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.cfg
259 lines (245 loc) · 7.21 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
# __ __
# | \/ |
# | \ / | __ _ ___ _ __ ___ ___
# | |\/| |/ _` |/ __| '__/ _ \/ __|
# | | | | (_| | (__| | | (_) \__ \
# |_| |_|\__,_|\___|_| \___/|___/
#
# Macros Configurations - Hatchbox Alpha
[gcode_macro PAUSE]
description: Pause the current print
rename_existing: PAUSE_BASE
gcode:
##### set defaults #####
{% set x = params.X|default(0) %}
{% set y = params.Y|default(-140) %}
{% set z = params.Z|default(10)|float %}
{% set e = params.E|default(1) %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
RESPOND MSG="Pausing..."
PAUSE_BASE
G91
G1 E-{e} F2100
G1 Z{z_safe}
G90
[gcode_macro M600]
description: Filament change
variable_hotend_temp: 0
variable_m600_enabled: 0
gcode:
##### set defaults #####
{% set x = params.X|default(0) %}
{% set y = params.Y|default(-140) %}
{% set z = params.Z|default(10)|float %}
{% set e = params.E|default(1) %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
SAVE_GCODE_STATE NAME=M600_state
SET_IDLE_TIMEOUT TIMEOUT=86400
SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_enabled VALUE=1
SET_GCODE_VARIABLE MACRO=M600 VARIABLE=hotend_temp VALUE={printer.extruder.target}
RESPOND MSG="Pausing..."
PAUSE
G91
G1 E-{e} F2100
G1 Z{z_safe}
G90
G1 X{x} Y{y} F2500
RESPOND MSG="Unloading filament..."
G91
G0 E-10 F300
G0 E-30 F800
M400
RESPOND MSG="Heating stopped!"
M109 S0
M106 S0
[gcode_macro RESUME]
description: Resume the current print
rename_existing: RESUME_BASE
gcode:
##### set defaults #####
{% set e = params.E|default(1) %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
SET_IDLE_TIMEOUT TIMEOUT=1800
G91
{% if printer["gcode_macro M600"].m600_enabled == 1 %}
RESPOND MSG="Heating..."
M109 S{printer["gcode_macro M600"].hotend_temp}
RESPOND MSG="Loading filament..."
G0 E50 F800
G0 E30 F300
M400
M106 S255
SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_enabled VALUE=0
{% else %}
G1 E{e} F2100
{% endif %}
RESPOND MSG="Resuming..."
RESUME_BASE {get_params}
[gcode_macro CANCEL_PRINT]
description: Cancel the current print
rename_existing: CANCEL_PRINT_BASE
gcode:
RESPOND MSG="Printing canceled!"
G28
M106 S0
M104 S0
M140 S0
CANCEL_PRINT_BASE
[gcode_macro PID_BED_65]
description: Start Bed PID
gcode:
{% if printer.idle_timeout.state == "Printing" %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
M106
G1 Z50 F1500
RESPOND MSG="Bed PID in progress..."
PID_CALIBRATE HEATER=heater_bed TARGET={params.TEMP|default(65)}
G28
SAVE_CONFIG
{% endif %}
[gcode_macro PID_HOTEND_220]
description: Start Hotend PID
gcode:
{% if printer.idle_timeout.state == "Printing" %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
M106
G1 Z50 F1500
RESPOND MSG="Hotend PID in progress..."
PID_CALIBRATE HEATER=extruder TARGET={params.TEMP|default(220)}
G28
SAVE_CONFIG
{% endif %}
[gcode_macro DELTA_CALIBRATION]
description: Start Delta Calibration
gcode:
{% if printer.idle_timeout.state == "Printing" %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
SET_GCODE_OFFSET Z=0
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
DELTA_CALIBRATE
G1 X0 Y0 Z50 F2500
G28
SAVE_CONFIG
{% endif %}
# [gcode_macro BED_LEVELING]
# description: Start Bed Leveling
# gcode:
# {% if printer.idle_timeout.state == "Printing" %}
# RESPOND TYPE=error MSG="This macro cannot be used while printing!"
# {% else %}
# {% if printer.toolhead.homed_axes != "xyz" %}
# G28
# {% endif %}
# G1 X0 Y0 Z50 F2500
# BED_MESH_CALIBRATE
# G1 X0 Y0 Z50 F2500
# G28
# SAVE_CONFIG
# {% endif %}
[gcode_macro MOVE_TO_Z0]
description: Move to Z=0
gcode:
{% if printer.idle_timeout.state == "Printing" %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
G1 Z0 F2500
{% endif %}
[gcode_macro M204]
description: Set default Acceleration
rename_existing: M204.1
gcode:
{% set f = params.F|default(0.5)|float %}
{% if 'S' in params %}
{% set s = params.S|float %}
SET_VELOCITY_LIMIT ACCEL={s} ACCEL_TO_DECEL={ s * f }
{% else %}
{% if 'P' in params %}
{% set p = params.P|float %}
{% if 'T' in params %}
{% set t = params.T|float %}
{% if p < t %}
SET_VELOCITY_LIMIT ACCEL={p} ACCEL_TO_DECEL={ p * f }
{% else %}
SET_VELOCITY_LIMIT ACCEL={t} ACCEL_TO_DECEL={ t * f }
{% endif %}
{% else %}
SET_VELOCITY_LIMIT ACCEL={p} ACCEL_TO_DECEL={ p * f }
{% endif %}
{% elif 'T' in params %}
{% set t = params.T|float %}
SET_VELOCITY_LIMIT ACCEL={t} ACCEL_TO_DECEL={ t * f }
{% endif %}
{% endif %}
[gcode_macro M205]
description: Alternative to Jerk
gcode:
{% if 'X' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X|int}
{% elif 'Y' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y|int}
{% endif %}
[gcode_macro SET_GCODE_OFFSET]
description: Save Z-Offset value
rename_existing: _SET_GCODE_OFFSET
gcode:
{% if printer.save_variables.variables.gcode_offsets %}
{% set offsets = printer.save_variables.variables.gcode_offsets %}
{% else %}
{% set offsets = {'x': None,'y': None,'z': None} %}
{% endif %}
{% set ns = namespace(offsets={'x': offsets.x,'y': offsets.y,'z': offsets.z}) %}
_SET_GCODE_OFFSET {% for p in params %}{'%s=%s '% (p, params[p])}{% endfor %}
{%if 'X' in params %}{% set null = ns.offsets.update({'x': params.X}) %}{% endif %}
{%if 'Y' in params %}{% set null = ns.offsets.update({'y': params.Y}) %}{% endif %}
{%if 'Z' in params %}{% set null = ns.offsets.update({'z': params.Z}) %}{% endif %}
{%if 'Z_ADJUST' in params %}
{%if ns.offsets.z == None %}{% set null = ns.offsets.update({'z': 0}) %}{% endif %}
{% set null = ns.offsets.update({'z': (ns.offsets.z | float) + (params.Z_ADJUST | float)}) %}
{% endif %}
SAVE_VARIABLE VARIABLE=gcode_offsets VALUE="{ns.offsets}"
[delayed_gcode LOAD_GCODE_OFFSETS]
initial_duration: 2
gcode:
{% if printer.save_variables.variables.gcode_offsets %}
{% set offsets = printer.save_variables.variables.gcode_offsets %}
_SET_GCODE_OFFSET {% for axis, offset in offsets.items() if offsets[axis] %}{ "%s=%s " % (axis, offset) }{% endfor %}
{ action_respond_info("Loaded gcode offsets from saved variables [%s]" % (offsets)) }
{% endif %}