forked from bootuz-dinamon/ender3-v3-se-full-klipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macro.cfg
296 lines (272 loc) · 13.2 KB
/
macro.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
[gcode_macro PID_EXTRUDER]
gcode:
PID_CALIBRATE HEATER=extruder TARGET=210
SAVE_CONFIG
[gcode_macro PID_BED]
gcode:
PID_CALIBRATE HEATER=heater_bed TARGET=60
SAVE_CONFIG
#Cura start g-code
# START_PRINT EXTRUDER_TEMP={material_print_temperature_layer_0} BED_TEMP={material_bed_temperature_layer_0}
# All start end g-codes:
# https://github.com/rootiest/zippy_guides/blob/main/guides/macros.md#slicer-settings
[gcode_macro START_PRINT] # START_PRINT
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
M140 S{BED_TEMP}
# WLED_ON STRIP=roof PRESET=6
; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
G28 ; Home all axes
# Wait for bed to reach temperature
M190 S{BED_TEMP}
# Set and wait for nozzle to reach temperature
M109 S{EXTRUDER_TEMP}
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish
BED_MESH_PROFILE LOAD=default
[gcode_macro FILAMENT_LOAD]
gcode:
{% set load = params.L|default(100)|float * 0.5 %}
{% set extruder_temp = params.T|default(210)|float %}
SAVE_GCODE_STATE NAME=FILAMENT_LOAD_STATE
LOW_TEMP_CHECK T={extruder_temp}
M118 Loading filament
M83 # relative extrusion
G1 E{load} F1500 # extrude fast
G4 P1000 # wait 1 second
G1 E{load} F200 # extrude slow
RESTORE_GCODE_STATE NAME=FILAMENT_LOAD_STATE
BEEP
[gcode_macro FILAMENT_UNLOAD]
gcode:
{% set unload = params.U|default(100)|float %}
{% set extruder_temp = params.T|default(200)|float %}
SAVE_GCODE_STATE NAME=FILAMENT_UNLOAD_STATE
LOW_TEMP_CHECK T={extruder_temp}
M118 Unloading filament
M83 # relative extrusion
G1 E2 F200 # extrude a little
G1 E-10 F200 # retract a little
G1 E-{unload} F1500 # retract a lot
RESTORE_GCODE_STATE NAME=FILAMENT_UNLOAD_STATE
[gcode_macro LOW_TEMP_CHECK]
gcode:
{% set extruder_temp = params.T|default(200)|float %}
{% if printer.extruder.target > extruder_temp %} # if there is a setpoint for extruder
{% set extruder_temp = printer.extruder.target %}
{% endif %}
{% if printer.extruder.temperature < extruder_temp %} # heat to the target
M118 Heating to {extruder_temp}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={extruder_temp}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={extruder_temp}
{% endif %}
[gcode_macro BEEP]
gcode:
{% set duration = params.P|default(100)|float %}
SET_PIN PIN=beeper VALUE=1
G4 P{duration}
SET_PIN PIN=beeper VALUE=0
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
##### get user parameters or use default #####
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] | default({}) %}
{% set allow_park = client.park_at_cancel | default(false) | lower == 'true' %}
{% set retract = client.cancel_retract | default(5.0) | abs %}
##### define park position #####
{% set park_x = "" if (client.park_at_cancel_x | default(none) is none)
else "X=" ~ client.park_at_cancel_x %}
{% set park_y = "" if (client.park_at_cancel_y | default(none) is none)
else "Y=" ~ client.park_at_cancel_y %}
{% set custom_park = park_x | length > 0 or park_y | length > 0 %}
##### end of definitions #####
# restore idle_timeout time if needed
{% if printer['gcode_macro PAUSE'].restore_idle_timeout > 0 %}
SET_IDLE_TIMEOUT TIMEOUT={printer['gcode_macro PAUSE'].restore_idle_timeout}
{% endif %}
{% if (custom_park or not printer.pause_resume.is_paused) and allow_park %} _TOOLHEAD_PARK_PAUSE_CANCEL {park_x} {park_y} {% endif %}
_CLIENT_RETRACT LENGTH={retract}
TURN_OFF_HEATERS
M106 S0
# clear pause_next_layer and pause_at_layer as preparation for next print
SET_PAUSE_NEXT_LAYER ENABLE=0
SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0
CANCEL_PRINT_BASE
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
variable_restore_idle_timeout: 0
gcode:
##### get user parameters or use default #####
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] | default({}) %}
{% set idle_timeout = client.idle_timeout | default(0) %}
{% set temp = printer[printer.toolhead.extruder].target if printer.toolhead.extruder != '' else 0 %}
{% set restore = printer.toolhead.extruder != '' and params.RESTORE | default(1) | int == 1 %}
##### end of definitions #####
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=last_extruder_temp VALUE="{{'restore': restore, 'temp': temp}}"
# set a new idle_timeout value
{% if idle_timeout > 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=restore_idle_timeout VALUE={printer.configfile.settings.idle_timeout.timeout}
SET_IDLE_TIMEOUT TIMEOUT={idle_timeout}
{% endif %}
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL {rawparams}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
variable_last_extruder_temp: {'restore': False, 'temp': 0}
gcode:
##### get user parameters or use default #####
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] | default({}) %}
{% set velocity = printer.configfile.settings.pause_resume.recover_velocity %}
{% set sp_move = client.speed_move | default(velocity) %}
##### end of definitions #####
# restore idle_timeout time if needed
{% if printer['gcode_macro PAUSE'].restore_idle_timeout > 0 %}
SET_IDLE_TIMEOUT TIMEOUT={printer['gcode_macro PAUSE'].restore_idle_timeout}
{% endif %}
{% if printer.idle_timeout.state | upper == "IDLE" and last_extruder_temp.restore %}
M109 S{last_extruder_temp.temp}
{% endif %}
_CLIENT_EXTRUDE
RESUME_BASE VELOCITY={params.VELOCITY | default(sp_move)}
# Usage: SET_PAUSE_NEXT_LAYER [ENABLE=[0 | 1]] [MACRO=<name>]
[gcode_macro SET_PAUSE_NEXT_LAYER]
description: Enable a pause if the next layer is reached
gcode:
{% set pause_next_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_next_layer %}
{% set ENABLE = params.ENABLE | default(1) | int != 0 %}
{% set MACRO = params.MACRO | default(pause_next_layer.call, True) %}
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_next_layer VALUE="{{ 'enable': ENABLE, 'call': MACRO }}"
# Usage: SET_PAUSE_AT_LAYER [ENABLE=[0 | 1]] [LAYER=<number>] [MACRO=<name>]
[gcode_macro SET_PAUSE_AT_LAYER]
description: Enable/disable a pause if a given layer number is reached
gcode:
{% set pause_at_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_at_layer %}
{% set ENABLE = params.ENABLE | int != 0 if params.ENABLE is defined
else params.LAYER is defined %}
{% set LAYER = params.LAYER | default(pause_at_layer.layer) | int %}
{% set MACRO = params.MACRO | default(pause_at_layer.call, True) %}
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{ 'enable': ENABLE, 'layer': LAYER, 'call': MACRO }}"
# Usage: SET_PRINT_STATS_INFO [TOTAL_LAYER=<total_layer_count>] [CURRENT_LAYER= <current_layer>]
[gcode_macro SET_PRINT_STATS_INFO]
rename_existing: SET_PRINT_STATS_INFO_BASE
description: Overwrite, to get pause_next_layer and pause_at_layer feature
variable_pause_next_layer: { 'enable': False, 'call': "PAUSE" }
variable_pause_at_layer : { 'enable': False, 'layer': 0, 'call': "PAUSE" }
gcode:
{% if pause_next_layer.enable %}
RESPOND TYPE=echo MSG='{"%s, forced by pause_next_layer" % pause_next_layer.call}'
{pause_next_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE
SET_PAUSE_NEXT_LAYER ENABLE=0
{% elif pause_at_layer.enable and params.CURRENT_LAYER is defined and params.CURRENT_LAYER | int == pause_at_layer.layer %}
RESPOND TYPE=echo MSG='{"%s, forced by pause_at_layer [%d]" % (pause_at_layer.call, pause_at_layer.layer)}'
{pause_at_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE
SET_PAUSE_AT_LAYER ENABLE=0
{% endif %}
SET_PRINT_STATS_INFO_BASE {rawparams}
##### internal use #####
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
gcode:
##### get user parameters or use default #####
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] | default({}) %}
{% set velocity = printer.configfile.settings.pause_resume.recover_velocity %}
{% set use_custom = client.use_custom_pos | default(false) | lower == 'true' %}
{% set custom_park_x = client.custom_park_x | default(0.0) %}
{% set custom_park_y = client.custom_park_y | default(0.0) %}
{% set park_dz = client.custom_park_dz | default(2.0) | abs %}
{% set sp_hop = client.speed_hop | default(15) * 60 %}
{% set sp_move = client.speed_move | default(velocity) * 60 %}
##### get config and toolhead values #####
{% set origin = printer.gcode_move.homing_origin %}
{% set act = printer.gcode_move.gcode_position %}
{% set max = printer.toolhead.axis_maximum %}
{% set cone = printer.toolhead.cone_start_z | default(max.z) %} ; height as long the toolhead can reach max and min of an delta
{% set round_bed = True if printer.configfile.settings.printer.kinematics is in ['delta','polar','rotary_delta','winch']
else False %}
##### define park position #####
{% set z_min = params.Z_MIN | default(0) | float %}
{% set z_park = [[(act.z + park_dz), z_min] | max, (max.z - origin.z)] | min %}
{% set x_park = params.X if params.X is defined
else custom_park_x if use_custom
else 0.0 if round_bed
else (max.x - 5.0) %}
{% set y_park = params.Y if params.Y is defined
else custom_park_y if use_custom
else (max.y - 5.0) if round_bed and z_park < cone
else 0.0 if round_bed
else (max.y - 5.0) %}
##### end of definitions #####
_CLIENT_RETRACT
{% if "xyz" in printer.toolhead.homed_axes %}
G90
G1 Z{z_park} F{sp_hop}
G1 X{x_park} Y{y_park} F{sp_move}
{% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %}
{% else %}
RESPOND TYPE=echo MSG='Printer not homed'
{% endif %}
[gcode_macro _CLIENT_EXTRUDE]
description: Extrudes, if the extruder is hot enough
gcode:
##### get user parameters or use default #####
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] | default({}) %}
{% set use_fw_retract = (client.use_fw_retract | default(false) | lower == 'true') and (printer.firmware_retraction is defined) %}
{% set length = params.LENGTH | default(client.unretract) | default(1.0) | float %}
{% set speed = params.SPEED | default(client.speed_unretract) | default(35) %}
{% set absolute_extrude = printer.gcode_move.absolute_extrude %}
##### end of definitions #####
{% if printer.toolhead.extruder != '' %}
{% if printer[printer.toolhead.extruder].can_extrude %}
{% if use_fw_retract %}
{% if length < 0 %}
G10
{% else %}
G11
{% endif %}
{% else %}
M83
G1 E{length} F{(speed | float | abs) * 60}
{% if absolute_extrude %}
M82
{% endif %}
{% endif %}
{% else %}
RESPOND TYPE=echo MSG='Extruder not hot enough'
{% endif %}
{% endif %}
[gcode_macro _CLIENT_RETRACT]
description: Retracts, if the extruder is hot enough
gcode:
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] | default({}) %}
{% set length = params.LENGTH | default(client.retract) | default(1.0) | float %}
{% set speed = params.SPEED | default(client.speed_retract) | default(35) %}
_CLIENT_EXTRUDE LENGTH=-{length | float | abs} SPEED={speed | float | abs}
[gcode_macro PRINT_END]
description: End of printing
variable_machine_depth: 220
gcode:
G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 z50 ;Raise Z more
G90 ;Absolute positioning
G1 X0 Y{machine_depth} ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M84 X Y E ;Disable all steppers but Z
BEEP
# UPDATE_DELAYED_GCODE ID=DELAYED_PRINTER_OFF DURATION=60
# WLED_ON STRIP=roof PRESET=4