forked from mtw3d/mtw_klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros-mtw.cfg
214 lines (192 loc) · 6.73 KB
/
macros-mtw.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
###
# Macros for all MTW Printers
#
# NOTE: DO NOT EDIT THESE MACROS!
# If you wish to change the behavior of any of these macros, copy the macro from here
# to the macros-custom.cfg file and make your changes there. That way you will not
# lose any changes you make if we offer an updated version of this file. That file is
# loaded after this one, so any macros defined there will override any of the same
# name defined here.
###
[gcode_macro __fan_config]
variable_toolindex: 0
variable_speed: 0
gcode:
RESPOND PREFIX="info" MSG="Macro > Fan config > ok"
[gcode_macro M106]
gcode:
{% set fanspeed = 255 %}
{% if params.S is defined %}
{% set fanspeed = params.S|int %}
{% endif %}
{% if fanspeed < 0 %}
{% set fanspeed = 0 %}
{% endif %}
{% if fanspeed > 255 %}
{% set fanspeed = 255 %}
{% endif %}
RESPOND PREFIX="info" MSG="Macro > M106 > speed {fanspeed}"
FANSPEED SPEED={fanspeed}
[gcode_macro M107]
gcode:
RESPOND PREFIX="info" MSG="Macro > M107 > speed 0"
FANSPEED SPEED=0
[gcode_macro FANSPEED]
gcode:
{% set SPEED = params.SPEED|default(255)|int %}
RESPOND PREFIX="info" MSG="Macro > fanspeed > SET FAN to { params.SPEED|int }"
SET_GCODE_VARIABLE MACRO=_fan_config VARIABLE=speed VALUE={ params.SPEED|int }
{% if params.SPEED is defined %}
{% if params.SPEED|int == 255 %}
{% set realspeed = 1 %}
{% else %}
{% if params.SPEED|int == 0 %}
{% set realspeed = 0 %}
{% else %}
{% set realspeed = 0.003921*params.SPEED|int %}
{% endif %}
{% endif %}
{% else %}
{% set realspeed = 0 %}
{% endif %}
RESPOND PREFIX="info" MSG="Macro > fanspeed > SET FAN realspeed to {realspeed}"
SET_PIN PIN=fan_{printer.toolhead.extruder} VALUE={realspeed}
SET_PIN PIN=fan_x_axis VALUE={realspeed}
[gcode_macro G28]
rename_existing: G28.0
gcode:
CLEAR_PAUSE
SET_DUAL_CARRIAGE CARRIAGE=0
G28.0
park_extruder
[gcode_macro home]
gcode:
{% set ns = namespace(NEED2HOME = false) %}
{% for AXIS in ["x", "y", "z"] %}
{% if AXIS in printer.toolhead.homed_axes %}
RESPOND MSG="{AXIS} is already homed"
{% else %}
RESPOND MSG="{AXIS} not homed"
{% set ns.NEED2HOME = true %}
{% endif %}
{% endfor %}
{% if ns.NEED2HOME == true %}
G28
RESPOND MSG="homing"
{% endif %}
[gcode_macro ABL]
gcode:
CLEAR_PAUSE
G28
BED_MESH_CALIBRATE
PARK_extruder
G1 Y150
SAVE_CONFIG
######################################################################
## Filament Change ##
######################################################################
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 130mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "SWAP_RESUME" gcode.
######################################################################
## Filament Change ##
######################################################################
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 130mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "SWAP_RESUME" gcode.
[gcode_macro M600]
########### Gcode ############
gcode:
{% set X = params.X|default(printer.configfile.config["stepper_x"]["position_endstop"]|string)|int %}
{% set Y = params.Y|default(printer.configfile.config["stepper_y"]["position_endstop"]|string)|int %}
{% set Z = params.Z|default(10)|int %}
{% set E = params.E|default(-20)|int %}
{% set tool = params.tool|default(0)|int %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-5 F4000
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000 ;park position
G0 E10 F500 ;extrude filament to get better blob on end
G0 E{E} F600 ;retract additional filament to move out of melt zone
G92 E0
SET_FILAMENT_SENSOR SENSOR=e{TOOL}_runout ENABLE=0
# Use this command resume during a mid print filament swap (DONT USE OCTO/MAINSAIL/DWC RESUME)
[gcode_macro SWAP_RESUME]
gcode:
RESTORE_GCODE_STATE NAME=M600_state
SET_FILAMENT_SENSOR SENSOR=e0_runout ENABLE=1
SET_FILAMENT_SENSOR SENSOR=e1_runout ENABLE=1
resume
[gcode_macro blttest]
gcode: BLTOUCH_DEBUG COMMAND=self_test
[gcode_macro bltreset]
gcode: BLTOUCH_DEBUG COMMAND=reset
[gcode_macro bltdown]
gcode: BLTOUCH_DEBUG COMMAND=pin_down
[gcode_macro bltup]
gcode: BLTOUCH_DEBUG COMMAND=pin_up
[gcode_macro PIDBED]
gcode:
{% set TEMP = params.TEMP|default(60)|int %}
{% set SAVE = params.SAVE|default(1)|int %}
PID_CALIBRATE HEATER=heater_bed TARGET={TEMP|int}
{% if SAVE==1 %}
RESPOND MSG="Saving"
save_config
{% else %}
RESPOND MSG="Value Not Saved"
{% endif %}
[gcode_macro PIDT0]
gcode:
{% set TEMP = params.TEMP|default(204)|int %}
{% set SAVE = params.SAVE|default(1)|int %}
PID_CALIBRATE HEATER=extruder TARGET={TEMP}
{% if SAVE==1 %}
RESPOND MSG="Saving"
save_config
{% else %}
RESPOND MSG="Value Not Saved"
{% endif %}
[gcode_macro PIDT1]
gcode:
{% set TEMP = params.TEMP|default(204)|int %}
{% set SAVE = params.SAVE|default(1)|int %}
PID_CALIBRATE HEATER=extruder1 TARGET={TEMP|int}
{% if SAVE==1 %}
RESPOND MSG="Saving"
save_config
{% else %}
RESPOND MSG="Value Not Saved"
{% endif %}
[gcode_macro PID_ALL]
gcode:
PIDBED Save=0
PIDT0 Save=0
PIDT1
[gcode_macro initial_calibration]
gcode:
PIDbed Save=0
PIDT0 Save=0
PIDT1 Save=0
ABL
[gcode_macro Z_clear_print]
gcode:
{% set jump = params.jump|default(5)|int %}
RESPOND MSG="Z cur Position: {printer.gcode_move.position.z}"
RESPOND MSG="Z max Position: {printer.configfile.config["stepper_z"]["position_max"]|float}"
{% if printer.gcode_move.position.z < printer.configfile.config["stepper_z"]["position_max"]|float - JUMP|float %}
G1 Z{ printer.gcode_move.position.z + JUMP|float }
RESPOND MSG="moving to Z{ printer.gcode_move.position.z + JUMP|float }"
{% elif printer.gcode_move.position.z >= printer.configfile.config["stepper_z"]["position_max"]|float %}
Respond MSG="Already at max Z height"
{% else %}
G1 Z{ printer.configfile.config["stepper_z"]["position_max"]|float }
RESPOND MSG="moving to Z{ printer.configfile.config["stepper_z"]["position_max"]|float }"
{% endif %}