forked from zellneralex/klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacro.cfg
497 lines (488 loc) · 24.1 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
#[gcode_arcs]
#resolution: 0.1
#####################################################################
# Macros
#####################################################################
[gcode_macro PRINT_START]
description: All commands needed before the print
## User Paramaters
## BED_TEMP : Target temperature for the Bed. Is also used to decide
## if heatsoak is needed
## EXTRUDER_TEMP : Target temperature for the Extruder
## CHAMBER_TEMP : Target temperature for the chamber fan controll
## SOAK : Soak time in minutes
## DELTA_B : Allowed delta between actual bed temperature and target
## temperature for the decision if heat soak is needed.
## DELTA_C : Allowed delta between actual chamber temperature and target
## will wait until target reached or time is zero
## CHAMBER_SOAK : Extra Soak time if Chamber is not on target - DELTA_C
## EXTRA_SOAK : Enables Chamber Soak ('true'/'false')
## LAYER_HEIGHT : Hight of prime_line should be set to layer_hight
## Z_ADJUST : Add extra z offset via slicer
## System Varables
variable_extruder: 245
variable_bed: 100
variable_chamber: 40
variable_chamber_delta: 5
variable_redo_qgl: 'true'
variable_soak_tval: 0
variable_soak_tval_c: 0
variable_endstop: 0
variable_print_info: 'true'
variable_prime_height: 0
variable_z_adjust: 0.0
## Valid state
## Prepare : decision if heat Soak is needed
## HeatSoak: loop the time specified with SOAK
## Chamber : wait for chamber reached CHAMBER_SOAK
## Final : all what needs to be done after wait timet
variable_state: 'Prepare'
gcode:
############# Get user defines #############
{% set park_pos = printer['gcode_macro _USER_VARIABLE'].park_bed %}
{% set soak_ival = printer['gcode_macro _USER_VARIABLE'].print_start_ival|int %}
{% set soak_bed_up = printer['gcode_macro _USER_VARIABLE'].print_start_bed_up|int %}
{% set extuder_start_time = printer['gcode_macro _USER_VARIABLE'].print_start_extruder_time|int * 60 %}
{% set bed_reduce_time = printer['gcode_macro _USER_VARIABLE'].print_start_bed_time|int * 60 %}
{% set prime_mult = printer['gcode_macro _USER_VARIABLE'].print_start_prime_mult|float %}
############# Get hardware enables #############
{% set ena_neo = printer['gcode_macro _USER_VARIABLE'].neo_display|lower %}
{% set ena_chamber = printer['gcode_macro _USER_VARIABLE'].chamber|lower %}
{% set ena_caselight = printer['gcode_macro _USER_VARIABLE'].caselight|lower %}
{% set ena_filter = printer['gcode_macro _USER_VARIABLE'].filter|lower %}
{% set ena_runout = printer['gcode_macro _USER_VARIABLE'].runout|lower %}
{% set ena_relay = printer['gcode_macro _USER_VARIABLE'].relay|lower %}
{% set ena_auto_z_offset = printer['gcode_macro _USER_VARIABLE'].auto_z_offset|lower %}
############# BED temp values #############
# get actual temp from extra sensor or heater sensor
{% if 'temperature_sensor bed' in printer %}
{% set actBed = printer['temperature_sensor bed'].temperature|int %}
{% else %}
{% set actBed = printer.heater_bed.temperature|int %}
{% endif %}
# get max allow bed temp from config. Lower it by 5C to avoid shutdown
{% set cfg_bed_max = printer.configfile.settings.heater_bed.max_temp|int - 5 %}
############# Definition done #############
## Prepare phase only done at the first exection of PRINT_START
{% if state == 'Prepare' %}
############# Store input parameters only at first execution #############
{% set bed_temp = params.BED_TEMP|default(100)|int %}
{% set extruder_temp = params.EXTRUDER_TEMP|default(245)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(50)|int %}
{% set soak = params.SOAK|default(30)|int * 60 %}
{% set delta_b = params.DELTA_B|default(10)|int %}
{% set delta_c = params.DELTA_C|default(5)|int %}
{% set chamber_soak = params.CHAMBER_SOAK|default(15)|int * 60 %}
{% set extra_soak = params.EXTRA_SOAK|default('true') %}
{% set p_height = params.LAYER_HEIGHT|default(0.0)|float * prime_mult %}
{% set adjust_z = params.Z_ADJUST|default(0.0)|float %}
############# Variable Setup #############
{% set targetBed = bed_temp - delta_b %}
{% if cfg_bed_max > bed_temp + soak_bed_up %}
{% set bed_soak_temp = bed_temp + soak_bed_up %}
{% else %}
{% set bed_soak_temp = cfg_bed_max %}
{% endif %}
############# Store Values for the complete PRINT_START execution #############
SET_GCODE_VARIABLE MACRO=CANCEL_PRINT VARIABLE=execute VALUE='"false"'
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=print_info VALUE='"true"'
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=extruder VALUE={extruder_temp}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=bed VALUE={bed_temp}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=chamber VALUE={chamber_temp}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=chamber_delta VALUE={delta_c}
{% if extra_soak == 'true' and ena_chamber != 'none' %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval_c VALUE={chamber_soak}
{% else %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval_c VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=prime_height VALUE={p_height}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=z_adjust VALUE={adjust_z}
############# Get filament runout info #############
{% if ena_runout == 'switch' %}
{% if printer['filament_switch_sensor runout'].enabled|lower == 'true' %}
{% set filament_detected = printer['filament_switch_sensor runout'].filament_detected|lower %}
{% elif 'virtual_sdcard' in printer and filament_loaded in printer.save_variables.variables %}
{% set filament_detected = printer.save_variables.variables.filament_loaded %}
{% else %}
{% set filament_detected = 'true' %}
{% endif %}
{% elif ena_runout == 'motion' %}
{% if printer['filament_motion_sensor runout'].enabled|lower == 'true' %}
{% set filament_detected = printer['filament_motion_sensor runout'].filament_detected|lower %}
{% elif 'virtual_sdcard' in printer and filament_loaded in printer.save_variables.variables %}
{% set filament_detected = printer.save_variables.variables.filament_loaded %}
{% else %}
{% set filament_detected = 'true' %}
{% endif %}
{% elif ena_runout == 'file' %}
{% set filament_detected = printer.save_variables.variables.filament_loaded %}
{% else %}
{% set filament_detected = 'true' %}
{% endif %}
############# Definition done #############
_RUNOUT_INFO
{% if filament_detected == 'true' %}
{% if ena_auto_z_offset == 'flexplate' %} _DISPLAY_PLATE {% endif %}
{% if ena_relay == 'true' %} _HEATER_ON {% endif %}
{% if ena_caselight == 'true' %} _CASELIGHT_ON {% endif %}
{% if ena_neo == 'true' %} _LCD_KNOB COLOR=RED BLINK=1 {% endif %}
{% if ena_chamber == 'fan' %} M141 S0 {% endif %} ; exhaust fan off
{% if ena_filter == 'true' %} _FILTER_ON {% endif %} ; activate filter
_CG28 ; home if needed
# Move to Middle
G90
G0 Z{park_pos[2]} F1800 ; move nozzle to z high first
G0 X{park_pos[0]} Y{park_pos[1]} F18000 ; home to get toolhead in the middle
# check if soak time is 0 or if the bed is still hot
{% if (soak <= 0) or (actBed >= targetBed) %}
M117 Heating Extruder
{% if (soak <= 0) %}
_PRINT_AR T="{"Bed temp: act %3dC min %3dC (target(%3dC) - delta(%dC)) heat soak disabled" % (actBed,targetBed,bed_temp,delta_b)}"
{% else %}
_PRINT_AR T="{"Bed temp: act %3dC min %3dC (target(%3dC) - delta(%dC)) heat soak not needed" % (actBed,targetBed,bed_temp,delta_b)}"
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=redo_qgl VALUE='"false"'
M140 S{bed_temp} ; heat bed
M109 S{extruder_temp} ; heat extruder and wait
M190 S{bed_temp} ; heat bed and wait
M400 ; wait for buffer to clear
PAUSE_BASE
# go to chamber soak wait
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Chamber"'
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.1
{% else %}
M117 Heating Bed
_PRINT_AR T="{"Bed temp: act %3dC min %3dC (target(%3dC) - delta(%dC)) heat soak needed" % (actBed,targetBed,bed_temp,delta_b)}"
_PRINT_AR T="{"Set Bed temp to %3dC instead of %3dC for faster heat soak" % (bed_soak_temp,bed_temp)}"
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=redo_qgl VALUE='"true"'
M106 S90 ; switch part cooling ~35% to move air in chamber
M140 S{bed_soak_temp} ; heat bed
M400 ; wait for buffer to clear
PAUSE_BASE
# Call the wait macro the first time
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"HeatSoak"'
_PRINT_TIME TEXT="HEAT SOAK" TIME={soak}
{% if soak > soak_ival %}
# soak time is bigger than interval
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval VALUE={soak - soak_ival}
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={soak_ival}
{% else %}
# soak time is smaller than interval
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval VALUE=0
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={soak}
{% endif %}
{% endif%}
{% else %}
_PRINT_AR T="No Filament loaded, print canceled!"
CANCEL_PRINT_BASE
UPDATE_DELAYED_GCODE ID=_DELAY_SDCARD_RESET_FILE DURATION=10
{% endif%}
## Heatsoak Phase call the delay macro until time is over
{% elif state == 'HeatSoak' %}
# switch on extruder at _USER_VARIABLE.print_start_extruder_time
{% if (soak_tval) <= extuder_start_time + (extruder) - 240 %}
{%if extruder != printer.extruder.target|int %}
M104 S{extruder} ; heat extruder
{% endif %}
{% endif %}
# switch bed to first layer temp at _USER_VARIABLE.print_start_bed_time
{% if (soak_tval) <= bed_reduce_time %}
{% if bed != printer.heater_bed.target|int %}
M140 S{bed} ; heat bed
{% endif %}
{% endif %}
# check remaining time
{% if soak_tval > 0 %}
# check if interval is bigger than remaining time
{% if soak_ival >= soak_tval %}
# run last loop with time
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval VALUE=0
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={soak_tval}
{% else %}
## reduce time by interval
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval VALUE={soak_tval - soak_ival}
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={soak_ival}
{% endif %}
{% else %}
# go to chamber soak wait
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Chamber"'
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.1
_PRINT_AR T="{"Bed act temp=%3dC heat soak done" % (actBed|int)}"
{% endif %}
{% elif state == 'Chamber' %}
{% set chamber_target = chamber - chamber_delta %}
{% if ena_chamber == 'fan' %}
{% set chamber_act = printer['temperature_fan chamber'].temperature|int %}
{% elif ena_chamber == 'sensor' %}
{% set chamber_act = printer['temperature_sensor chamber'].temperature|int %}
{% else %}
{% set chamber_act = 0 %}
{% endif %}
# check remaining time and temp difference
{% if (soak_tval_c > 0) and (chamber_act|int < chamber_target|int) %}
{% if print_info == 'true' %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=print_info VALUE='"false"'
_PRINT_AR T="{"Chamber temp: act %3dC min %3dC (target(%2dC) - delta(%dC)) heat soak needed" % (chamber_act,chamber_target, chamber, chamber_delta)}"
_PRINT_TIME TEXT="CHAMBER" TIME={soak_tval_c}
{% endif %}
# check if interval is bigger than remaining time
{% if soak_ival >= soak_tval_c %}
## last loop
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval_c VALUE=0
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={soak_tval_c}
{% else %}
## reduce time by interval
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=soak_tval_c VALUE={soak_tval_c - soak_ival}
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={soak_ival}
{% endif %}
{% else %}
{% if soak_tval_c == 0 %}
{% if print_info == 'true' %}
_PRINT_AR T="{"Chamber temp: act %3dC min %3dC (target(%2dC) - delta(%dC)) heat soak disabled" % (chamber_act,chamber_target, chamber, chamber_delta)}"
{% else %}
_PRINT_AR T="{"Chamber temp: act %3dC min %3dC (target(%2dC) - delta(%dC)) heat soak timed out" % (chamber_act,chamber_target, chamber, chamber_delta)}"
{% endif %}
{% else %}
{% if print_info == 'true' %}
_PRINT_AR T="{"Chamber temp: act %3dC min %3dC (target(%2dC) - delta(%dC)) heat soak not needed" % (chamber_act,chamber_target, chamber, chamber_delta)}"
{% else %}
_PRINT_AR T="{"Chamber temp: act %3dC min %3dC (target(%2dC) - delta(%dC)) heat soak temp reached" % (chamber_act,chamber_target, chamber, chamber_delta)}"
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Final"'
UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.1
{% endif %}
## all whats need to run at the end
{% elif state == 'Final' %}
RESUME_BASE
# set status back to prepare for the next run
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Prepare"'
{% if ena_neo == 'true' %} _LCD_KNOB COLOR=RED {% endif %}
M106 S0 ; turn off part cooling fan
G21 ; set units to millimeters
G32 ; home & QGL
{% if ena_chamber == 'fan' %} M141 S{chamber} {% endif %} ; set target temp for exhaust fan
NOZZLECLEAN
G28 Z ; home Z with clean nozzle
{% if ena_auto_z_offset == 'z_calib' %} CALIBRATE_Z {% endif %}
SET_GCODE_OFFSET Z_ADJUST={z_adjust} MOVE=1
_PRINT_OFFSET
{% if prime_height > 0 %}
PRIME_LINE PRIME_HEIGHT={prime_height}
{% else %}
PRIME_LINE
{% endif %}
{% if 'temperature_sensor endstop' in printer.configfile.settings %}
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=endstop VALUE={printer['temperature_sensor endstop'].temperature}
{% endif %}
G90 ; use absolute coordinates
M83 ; use relative distances for extrusion
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1
{% endif %}
# This is called every PRINT_START intervale
# This is needed to stop PRINT_START using CANCEL_PRINT
[delayed_gcode _START_PRINT_WAIT]
gcode:
# Print remaining time
{% if printer['gcode_macro PRINT_START'].state == 'HeatSoak' %}
{% set tval = printer['gcode_macro PRINT_START'].soak_tval %}
_PRINT_TIME TEXT="HEAT SOAK" TIME={tval|int}
{% elif printer['gcode_macro PRINT_START'].state == 'Chamber' %}
{% set tval = printer['gcode_macro PRINT_START'].soak_tval_c %}
_PRINT_TIME TEXT="SOAK" TIME={tval|int}
{% endif %}
# Check CANCLE_PRINT was executed
{% if printer['gcode_macro CANCEL_PRINT'].execute == 'false' %}
PRINT_START ; Junp back to PRINT_START
{% else %}
# break loop
# insure state is correct for the next print start
SET_GCODE_VARIABLE MACRO=CANCEL_PRINT VARIABLE=execute VALUE='"false"'
SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Prepare"'
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1
{% endif %}
[gcode_macro PRINT_END]
description: All commands after the print
gcode:
SAVE_GCODE_STATE NAME=STATE_PRINT_END
##### Get Boundaries #####
{% set max_x = printer.toolhead.axis_maximum.x|float %}
{% set max_y = printer.toolhead.axis_maximum.y|float %}
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_x = printer.toolhead.position.x|float %}
{% set act_y = printer.toolhead.position.y|float %}
{% set act_z = printer.toolhead.position.z|float %}
##### Get user defines #####
{% set purge_pos = printer['gcode_macro _USER_VARIABLE'].purge %}
{% set vent_on = printer['gcode_macro _USER_VARIABLE'].vent_on|int %}
{% set retreact = printer['gcode_macro _USER_VARIABLE'].retreact_end|float * -1 %}
{% set fan_off = printer['gcode_macro _USER_VARIABLE'].fan_run_after_print|int * 60 %}
{% set vent_off = printer['gcode_macro _USER_VARIABLE'].fan_run_after_print|int * 60 + 5 %}
############# Get hardware enables #############
{% set ena_neo = printer['gcode_macro _USER_VARIABLE'].neo_display|lower %}
{% set ena_chamber = printer['gcode_macro _USER_VARIABLE'].chamber|lower %}
{% set ena_caselight = printer['gcode_macro _USER_VARIABLE'].caselight|lower %}
{% set ena_filter = printer['gcode_macro _USER_VARIABLE'].filter|lower %}
{% set ena_unload_sd = printer['gcode_macro _USER_VARIABLE'].print_end_unload_sd|lower %}
##### Calculate save move #####
{% if act_x < (max_x - 20.0) %}
{% set x_safe = 20.0 %}
{% else %}
{% set x_safe = -20.0 %}
{% endif %}
{% if act_y < (max_y - 20.0) %}
{% set y_safe = 20.0 %}
{% else %}
{% set y_safe = -20.0 %}
{% endif %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
M83 ; relative extrusion
G1 E{retreact} F1800 ; retract filament
G91 ; relative positioning
G0 X{x_safe} Y{y_safe} Z{z_safe} F20000 ; move nozzle to remove stringing
TURN_OFF_HEATERS ; turn off heaters
M107 ; turn off fan
{% if ena_chamber == 'fan' %} M141 S{vent_on} {% endif %} ; vent chamber (setting fan to below ambient)
G90 ; absolute positioning
G0 X{purge_pos[0]} Y{purge_pos[1]} F18000 ; park nozzle at brush bin
_ADD_PRINT_TIME
_SD_PRINT_STATS R='done'
_SD_PRINTER_STATS
{% if ena_neo == 'true' %} _LCD_KNOB COLOR=GREEN {% endif %}
{% if ena_caselight == 'true' %} _CASELIGHT_OFF {% endif %}
{% if ena_chamber == 'fan' %} UPDATE_DELAYED_GCODE ID=_DELAY_VENT_OFF DURATION={vent_off} {% endif %}
{% if ena_filter == 'true' %} UPDATE_DELAYED_GCODE ID=_DELAY_FILTER_OFF DURATION={fan_off} {% endif %}
{% if 'temperature_sensor endstop' in printer.configfile.settings %}
_PRINT_ENDSTOP_TEMP
{% endif %}
{% if ena_unload_sd == 'true' %} UPDATE_DELAYED_GCODE ID=_DELAY_SDCARD_RESET_FILE DURATION=10 {% endif %}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
RESTORE_GCODE_STATE NAME=STATE_PRINT_END
##### set speed and extruder factor to default #####
M220 S100
M221 S100
[gcode_macro G32]
description: Execute plate offset and QGL
gcode:
############# Get hardware enables #############
{% set ena_auto_z_offset = printer['gcode_macro _USER_VARIABLE'].auto_z_offset|lower %}
############# END of defines #############
_PRINT_AR T="Home & QGL" SHOW_LCD=true
_CG28 ; home if not already homed
BED_MESH_CLEAR
## flexplate must be excluded if switching to z_calibration
{% if ena_auto_z_offset == 'z_calib' %} SET_GCODE_OFFSET Z=0
{% elif ena_auto_z_offset == 'flexplate' %} _SET_PLATE_OFFSET {% endif %}
## check if QGL was already executed
## variable redo_qgl will always force a QGL
{% if printer['gcode_macro PRINT_START'].redo_qgl == 'true' %}
_PRINT_AR T="QGL forced by PRINT_START"
QUAD_GANTRY_LEVEL PARK=false
{% else %}
## if no QGL was done until now
{% if printer.quad_gantry_level.applied|lower == 'false' %}
_PRINT_AR T="QGL not executed yet"
QUAD_GANTRY_LEVEL PARK=false
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1
[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 %}
{% set max_accel_to_decel = printer.configfile.settings.printer.max_accel_to_decel|float %}
##### end of definition #####
{% if param_accel is defined %}
##### calc accel_to deccel #####
{% set param_accel_to_decel = (param_accel / 2.0) %}
##### limit values to config values #####
{% if param_accel < max_accel %}
{% set accel = param_accel %}
{% else %}
{% set accel = max_accel %}
{% endif %}
{% if param_accel_to_decel < max_accel_to_decel %}
{% set accel_to_decel = param_accel_to_decel %}
{% else %}
{% set accel_to_decel = max_accel_to_decel %}
{% endif %}
##### set value #####
SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel_to_decel}
{% 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 M900]
description: Set pressure advance
gcode:
SET_PRESSURE_ADVANCE ADVANCE={params.K|default(0)}
## print Offsets defined by user and/or calibrate_z z_calib flexplate
[gcode_macro _PRINT_OFFSET]
description: Print gcode offsets defined by script or user in PRINT_START
gcode:
{% set user_z_adjust = printer['gcode_macro PRINT_START'].z_adjust|default(0.0) %}
{% set z_calib_z_adjust = printer.z_calibration.last_z_offset|default(0.0) %}
{% set act_z_adjust = printer.gcode_move.homing_origin.z %}
{% set ena_auto_z_offset = printer['gcode_macro _USER_VARIABLE'].auto_z_offset|lower %}
{% if ena_auto_z_offset == 'z_calib' %}
{action_respond_info("GCODE OFFSET for Z applied from:
User %.3f
CALIBRATE_Z %.3f
Actual total %.3f" % (user_z_adjust,z_calib_z_adjust,act_z_adjust))}
{% else %}
{action_respond_info("GCODE OFFSET for Z applied from:
User %.3f
Actual total %.3f" % (user_z_adjust,act_z_adjust))}
{% endif %}
## print endstop temperature used only by PRINT_END
[gcode_macro _PRINT_ENDSTOP_TEMP]
description: Print endstop temp for start and end print
gcode:
{% set endstop_start = printer['gcode_macro PRINT_START'].endstop %}
{% set endstop_end = printer['temperature_sensor endstop'].temperature %}
{% if 'temperature_sensor bed' in printer %}
{% set actBed = printer['temperature_sensor bed'].temperature %}
{% else %}
{% set actBed = printer.heater_bed.temperature %}
{% endif %}
{action_respond_info("PRINT_END
BED temp: act %3.2fC
Endstop temp: start %2.2fC end %2.2fC" % (actBed, endstop_start, endstop_end))}
## print time value used only by PRINT_START
[gcode_macro _PRINT_TIME]
description: Helper: Print time for start macro
gcode:
##### set defaults #####
{% set text = params.TEXT|default('Timer') %}
{% set show_ar = params.SHOW_AR|default('false') %}
##### calc values for time #####
{% set minutes = ((params.TIME|int / 60) % 60)|int %}
{% set seconds = (params.TIME|int % 60)|int %}
M117 {'%s' % (TEXT)} {minutes|int}:{'%02d' % (seconds|int)}
{%if show_ar == 'true' %}
{action_respond_info("%s %d:%02d" % (text,minutes|int,seconds|int))}
{% endif %}