-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacro.cfg
211 lines (193 loc) · 7.39 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
[gcode_macro M106]
# Author: @stas2z
# inspired by work of @icoderus & @uladzimirpalekh
description: Set and limit fan speed to cfg value. fixspeed should be set to -1 to disable
# Editable values, set to your own
variable_minspeed_default: 0
variable_maxspeed_default: 255
variable_multiplier_default: 100
# Non-editable values, for internal use only
variable_minspeed: 0
variable_maxspeed: 255
variable_fixspeed: -1
variable_currentspeed: 0
variable_multiplier: 1
variable_firstrun: 1
rename_existing: M106.1
gcode:
{% set changed = 0 %}
{% if firstrun or 'RESET' in params %}
# reset to defaults
{% set minspeed = minspeed_default %}
{% set maxspeed = maxspeed_default %}
{% set fixspeed = -1 %}
{% set multiplier = multiplier_default / 100 %}
{% if not firstrun %}
{% set changed = 1 %}
{% endif %}
# set macro variables
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=minspeed VALUE={minspeed}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=maxspeed VALUE={maxspeed}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=multiplier VALUE={multiplier}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=fixspeed VALUE={fixspeed}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=firstrun VALUE=0
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=currentspeed VALUE=0
{% endif %}
{% if 'F' in params %}
{% set fixspeed = params.F|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=fixspeed VALUE={fixspeed}
{% set changed = 1 %}
{% endif %}
{% if 'MIN' in params %}
{% set minspeed = params.MIN|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=minspeed VALUE={minspeed}
{% set changed = 1 %}
{% endif %}
{% if 'MAX' in params %}
{% set maxspeed = params.MAX|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=maxspeed VALUE={maxspeed}
{% set changed = 1 %}
{% endif %}
{% if 'MUL' in params %}
{% set multiplier = params.MUL|float / 100.0|float %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=multiplier VALUE={multiplier}
{% set changed = 1 %}
{% endif %}
{% if fixspeed >= 0 %}
M106.1 S{fixspeed}
{% elif 'S' in params or changed %}
{% set speed = params.S|default(currentspeed)|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=currentspeed VALUE={speed}
{% if speed > 0 %}
{% set newspeed = (speed*multiplier)|int %}
{% if newspeed < minspeed %}
M106.1 S{minspeed}
{% else %}
{% if newspeed > maxspeed %}
M106.1 S{maxspeed}
{% else %}
M106.1 S{newspeed}
{% endif %}
{% endif %}
{% else %}
M107.1
{% endif %}
{% endif %}
[gcode_macro M107]
description: Switch fans off and reset M106
rename_existing: M107.1
gcode:
M106 RESET1
M107.1
[gcode_macro START_PRINT]
variable_retract: 5
gcode:
{% set extruder_temp = params.EXTRUDER_TEMP|default(240)|float %}
{% set bed_temp = params.BED_TEMP|default(70)|float %}
{% set E = printer["gcode_macro START_PRINT"].retract|float %}
CLEAR_PAUSE
M220 S100 # reset feedrate
M221 S100 # reset flowrate
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={bed_temp} # set bed t℃
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_temp * 0.75} # wait until bed is partially heated
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={extruder_temp} # set nozzle t℃
G90 # absolute positioning
M82 # absolute extrusion mode
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_temp} # wait until
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={extruder_temp} # wait until
G28 # home
G0 Z10 F1500 # raise Z
G92 E0 # reset extruder
G1 E{E} F1500 # prime
G92 E0 # reset extruder
# M117 #ENABLING the Smart Filament Sensor
# G92 E0
# SET_FILAMENT_SENSOR SENSOR=BTT ENABLE=1 ; Put your filament sensor's name after SENSOR=
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
##### set defaults #####
{% set x = params.X|default(20) %} #edit to your park position
{% set y = params.Y|default(20) %} #edit to your park position
{% set z = params.Z|default(5)|float %} #edit to your park position
{% set e = params.E|default(1) %} #edit to your retract length
##### 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 %}
{%set min_extrude_temp = printer.configfile.settings["extruder"]["min_extrude_temp"]|int %}
{%set act_extrude_temp = printer.extruder.temperature|int %}
##### end of definitions #####
#M117 #DISABLING the Smart Filament Sensor
#G92 E0
#SET_FILAMENT_SENSOR SENSOR=BTT ENABLE=0 ; Put your filament sensor's name after SENSOR=
PAUSE_BASE
G91
{% if act_extrude_temp > min_extrude_temp %}
G1 E-{e} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe}
G90
G1 X{x} Y{y} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### set defaults #####
{% set e = params.E|default(1) %} #edit to your retract length
{%set min_extrude_temp = printer.configfile.settings["extruder"]["min_extrude_temp"]|int %}
{%set act_extrude_temp = printer.extruder.temperature|int %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
G91
{% if act_extrude_temp > min_extrude_temp %}
G1 E{e} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
CANCEL_PRINT_BASE
[gcode_macro BED_PID]
gcode:
PID_CALIBRATE HEATER=heater_bed TARGET=120
[gcode_macro EXTRUDER_PID]
gcode:
M106 S255
PID_CALIBRATE HEATER=extruder TARGET=260
[gcode_macro EXTRUDER_PID]
gcode:
M106 S255
PID_CALIBRATE HEATER=extruder TARGET=260
[gcode_macro Z_OFFSET]
gcode:
G28
PROBE_CALIBRATE
[gcode_macro BED_MESH]
gcode:
G28
BED_MESH_CALIBRATE
####END MACROS#######