-
Notifications
You must be signed in to change notification settings - Fork 0
/
abl.cfg
51 lines (46 loc) · 1.71 KB
/
abl.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
### Mesh level the bed every 10th print
[gcode_macro LEVEL_BED_ADVANCED]
description: Levels the bed if the last leveling was MAX_AGE runs ago. Force leveling by setting FORCE
variable_save_at_end: 0
gcode:
{% set max_age = params.MAX_AGE|default(10)|int %}
{% set force_level = params.FORCE|default(0)|int %}
{% set save = params.SAVE|default(0)|int %}
QUERY_PROBE
M401
; load level_age from stored variables
{% set svv = printer.save_variables.variables %}
{% if "level_age" not in svv %} ; first run
SAVE_VARIABLE VARIABLE=level_age VALUE={max_age}
{% set level_age = 1 %}
{% else %} ; load level_age and increment
{% set level_age = svv.level_age %}
SAVE_VARIABLE VARIABLE=level_age VALUE={level_age|int + 1}
{% endif %}
{action_respond_info("Bed mesh age is " + level_age|string) + "."}
; Level eventually
{% if force_level or (level_age >= max_age|int) %}
{action_respond_info("Bed mesh exceeded max age. Leveling...")}
; homing if not homed yet
{% if 'xy' not in printer.toolhead.homed_axes %}
G28
{% endif %}
BED_MESH_CALIBRATE
{% if save %}
SAVE_VARIABLE VARIABLE=level_age VALUE=1 ; reset counter
# SAVE_CONFIG
{% else %}
SET_GCODE_VARIABLE MACRO=LEVEL_BED_ADVANCED VARIABLE=save_at_end VALUE=1
{% endif %}
{% else %}
{action_respond_info("Loading old bed mesh.")}
BED_MESH_PROFILE LOAD=default
{% endif %}
# runs SAVE_CONFIG if the g-code variable was set in start gcode
[gcode_macro SAVE_IF_SET]
gcode:
{% if printer["gcode_macro LEVEL_BED_ADVANCED"].save_at_end == 1 %}
{action_respond_info("Saving was requested - saving and restarting now.")}
SAVE_VARIABLE VARIABLE=level_age VALUE=1
# SAVE_CONFIG
{% endif %}