-
Notifications
You must be signed in to change notification settings - Fork 4
/
macros.cfg
265 lines (252 loc) · 8.64 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
260
261
262
263
264
265
[gcode_macro ACCEL_OVERRIDE]
description: Overrides SQV or acceleration value based on type
# default
variable_accel_0: 0
variable_decel_0: 0
variable_sqv_0: 0
# internal perimeter
variable_accel_1: 0
variable_decel_1: 0
variable_sqv_1: 0
# external perimeter
variable_accel_2: 0
variable_decel_2: 0
variable_sqv_2: 0
# solid infil
variable_accel_3: 0
variable_decel_3: 0
variable_sqv_3: 0
# sparse infil
variable_accel_4: 0
variable_decel_4: 0
variable_sqv_4: 0
# top solid infil
variable_accel_5: 0
variable_decel_5: 0
variable_sqv_5: 0
# default support
variable_accel_6: 0
variable_decel_6: 0
variable_sqv_6: 0
# interface support
variable_accel_7: 0
variable_decel_7: 0
variable_sqv_7: 0
# brim & skirt
variable_accel_8: 0
variable_decel_8: 0
variable_sqv_8: 0
# bridges
variable_accel_9: 0
variable_decel_9: 0
variable_sqv_9: 0
# interface support
variable_accel_10: 0
variable_decel_10: 0
variable_sqv_10: 0
# overhangs
variable_accel_11: 0
variable_decel_11: 0
variable_sqv_11: 0
# gap fill
variable_accel_12: 0
variable_decel_12: 0
variable_sqv_12: 0
# thin walls
variable_accel_13: 0
variable_decel_13: 0
variable_sqv_13: 0
# ironing
variable_accel_14: 0
variable_decel_14: 0
variable_sqv_14: 0
# travel
variable_accel_15: 0
variable_decel_15: 0
variable_sqv_15: 0
# first layer
variable_accel_16: 0
variable_decel_16: 0
variable_sqv_16: 0
# first object over raft interface
variable_accel_17: 0
variable_decel_17: 0
variable_sqv_17: 0
gcode:
{% if 'TYPE' in params %}
{% set type = params.TYPE %}
{% set action = 0 %}
{% if 'ACCEL' in params %}
{% set accel = params.ACCEL|int %}
{% set accel_var = "accel_" + type %}
SET_GCODE_VARIABLE MACRO=ACCEL_OVERRIDE VARIABLE={accel_var} VALUE={accel}
{% set action = 1 %}
{% endif %}
{% if 'DECEL' in params %}
{% set decel = params.DECEL|int %}
{% set decel_var = "decel_" + type %}
SET_GCODE_VARIABLE MACRO=ACCEL_OVERRIDE VARIABLE={decel_var} VALUE={decel}
{% set action = 1 %}
{% endif %}
{% if 'SQV' in params %}
{% set sqv = params.SQV|int %}
{% set sqv_var = "sqv_" + type %}
SET_GCODE_VARIABLE MACRO=ACCEL_OVERRIDE VARIABLE={sqv_var} VALUE={sqv}
{% set action = 1 %}
{% endif %}
{% if action == 0 %}
{% set variable_accel = "accel_" + type %}
{% set accel = printer["gcode_macro ACCEL_OVERRIDE"][variable_accel]|int %}
{% if accel > 0 %}
SET_VELOCITY_LIMIT ACCEL={accel} RESPOND=0
{% elif 'DEFAULT' in params %}
SET_VELOCITY_LIMIT ACCEL={params.DEFAULT} RESPOND=0
{% endif %}
{% set variable_decel = "decel_" + type %}
{% set decel = printer["gcode_macro ACCEL_OVERRIDE"][variable_decel]|int %}
{% if decel > 0 %}
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={decel} RESPOND=0
{% elif 'DEFAULT' in params %}
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={params.DEFAULT} RESPOND=0
{% endif %}
{% set variable_sqv = "sqv_" + type %}
{% set sqv = printer["gcode_macro ACCEL_OVERRIDE"][variable_sqv]|int %}
{% if sqv > 0 %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={sqv} RESPOND=0
{% else %}
{% set max_sqv = printer.configfile.settings.printer.square_corner_velocity|float %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={max_sqv} RESPOND=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro PRINT_FEATURE]
variable_pause_infill_layer: 0
gcode:
{% if params.TYPE == "4" and printer.print_stats.info.current_layer == pause_infill_layer %}
SET_PAUSE_AT_INFILL LAYER=0
PAUSE
{% endif %}
[gcode_macro SET_PAUSE_AT_INFILL]
gcode:
SET_GCODE_VARIABLE MACRO=PRINT_FEATURE VARIABLE=pause_infill_layer VALUE={params.LAYER}
# 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 %}
{action_respond_info("%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 %}
{action_respond_info("%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}
[gcode_macro M204]
description: Set and limit acceleration to cfg value
rename_existing: M204.1
gcode:
##### get accel from parameter #####
{% if 'S' in params and params.S|float > 0 %}
{% set param_accel = params.S|float %}
{% elif 'P' in params and 'T' in params and params.P|float > 0 and params.T|float > 0 %}
{% if params.P|float > params.T|float %}
{% set param_accel = params.T|float %}
{% else %}
{% set param_accel = params.P|float %}
{% endif %}
{% endif %}
##### get limits from config #####
{% set max_accel = printer.configfile.settings.printer.max_accel|float %}
##### end of definition #####
{% if param_accel is defined %}
{% set factor_accel = (param_accel % 100)|int %}
{% set param_accel = param_accel - factor_accel %}
##### limit values to config values #####
{% if param_accel < max_accel %}
{% set accel = param_accel %}
{% else %}
{% set accel = max_accel %}
{% endif %}
##### set value #####
ACCEL_OVERRIDE TYPE={factor_accel} DEFAULT={accel}
PRINT_FEATURE TYPE={factor_accel}
{% else %}
{% set get_params = [] %}
{% for key in params %}
{% if key is not in ['M'] %}
{% set get_params = get_params.append(key + params[key]) %}
{% endif %}
{% endfor %}
{action_respond_info("Invalid M204 command \"M204 %s\"" % get_params|join(" "))}
{% endif %}
[gcode_macro QUERY_STATE]
gcode:
RESPOND MSG={printer.idle_timeout.state|lower}
[gcode_macro QUERY_PAUSE]
gcode:
RESPOND MSG={printer.pause_resume.is_paused|lower}
[gcode_macro M106]
description: Set and limit fan speed to cfg value. fixspeed should be set to -1 to disable
variable_minspeed: 0
variable_maxspeed: 255
variable_fixspeed: -1
rename_existing: M106.1
gcode:
{% if 'MIN' in params %}
{% set minspeed = params.MIN|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=minspeed VALUE={minspeed}
{% endif %}
{% if 'MAX' in params %}
{% set maxspeed = params.MAX|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=maxspeed VALUE={maxspeed}
{% endif %}
{% if 'F' in params %}
{% set fixspeed = params.F|int %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=fixspeed VALUE={fixspeed}
{% endif %}
{% if 'RESET' in params %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=minspeed VALUE=0
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=maxspeed VALUE=255
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=fixspeed VALUE=-1
{% endif %}
{% if fixspeed >= 0 %}
M106.1 S{fixspeed}
{% elif 'S' in params %}
{% set speed = params.S|default(0)|int %}
{% if speed > 0 %}
{% if speed < minspeed %}
M106.1 S{minspeed}
{% else %}
{% if speed > maxspeed %}
M106.1 S{maxspeed}
{% else %}
M106.1 S{speed}
{% endif %}
{% endif %}
{% else %}
M106.1 S0
{% endif %}
{% endif %}