-
Notifications
You must be signed in to change notification settings - Fork 9
/
auto_mesh.cfg
72 lines (66 loc) · 3.29 KB
/
auto_mesh.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
##
#This is based on DutchDude's automatic bed selection
#
#https://klipper.info/macro-examples-1/dutchdudes-automatic-bed-selection
[gcode_macro _LOAD_MESH_TEMP]
variable_version: 0.2
gcode:
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro _LOAD_MESH_TEMP"].version %}
{% if svv.setup_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version You should check the values in INIT_SETUP and run it to update.")}
{% endif %}
{% set BED_TEMP = params.BED_TEMP|default(0)|int %}
{ action_respond_info("- AUTOMATED BED MESH GENERATOR -")}
{ action_respond_info("Requested " + BED_TEMP|string)}
{% if BED_TEMP < 30 %}
{ action_respond_info("Your bed temp is to low, make sure it is at least 30 or higher")}
{% else %}
{% if printer.configfile.config["bed_mesh " + BED_TEMP|string ] is defined and svv.setup_mesh_lifespan > 0 and BED_TEMP == svv.setup_last_temp %}
G28 Z #remove line if you ran G28 before starting this macro
BED_MESH_PROFILE LOAD={BED_TEMP|string}
{ action_respond_info("Succesfully loaded bed_mesh "+ BED_TEMP|string)}
SAVE_VARIABLE VARIABLE=setup_mesh_lifespan VALUE={svv.setup_mesh_lifespan - 1}
{% else %}
{% if printer.configfile.config["bed_mesh " + BED_TEMP|string] is defined %}
BED_MESH_PROFILE REMOVE={BED_TEMP|string}
{% endif %}
{ action_respond_info("bed_mesh not defined, your bed temperature will go up!")}
{ action_respond_info("We will probe the bed and save the mesh as bed_mesh "+ BED_TEMP|string)}
_ADD_BED_MESH TARGET_TEMP={BED_TEMP}
SAVE_AT_END
{% endif %}
{% endif %}
[gcode_macro _ADD_BED_MESH]
description: Use in start print to add a bed mesh.
gcode:
# TODO use SVV
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro _LOAD_MESH_TEMP"].version %}
{% if svv.setup_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version \
You should check the values in INIT_SETUP and run it to update \
")}
{% endif %}
{% set TARGET_TEMP = params.TARGET_TEMP|default(30)|int %}
M190 S{TARGET_TEMP} # Wait for the bed to hit TARGET_TEMP
#G28 #remove line if you ran G28 before starting this macro
#The below runs a home and checks bed is level.
SETUP_BED TOL_CORNERS=0.2 TOL_GANTRY=0.02
BED_MESH_CALIBRATE
BED_MESH_PROFILE SAVE={TARGET_TEMP}
SAVE_VARIABLE VARIABLE=setup_mesh_lifespan VALUE=0 ;mark as not SAVE_CONFIG'd
# SAVE_VARIABLE VARIABLE=setup_last_temp VALUE={TARGET_TEMP} ; not now
SET_GCODE_VARIABLE MACRO=SAVE_AT_END VARIABLE=mesh_temp VALUE={TARGET_TEMP}
_SOUND_YES
[gcode_macro FORCE_MESH_REBUILD]
description: Expires the previous mesh lifespan, persistent.
gcode:
SAVE_VARIABLE VARIABLE=setup_mesh_lifespan VALUE=0
{ action_respond_info("The mesh will be rebuit")}
# SAVE_AT_END # not needed we do this automatically
[gcode_macro FORCE_MESH_LOAD]
description: Adds another use to the life ofthe mesh. USE WITH CARE
gcode:
SAVE_VARIABLE VARIABLE=setup_mesh_lifespan VALUE=1
{ action_respond_info("The mesh will not be rebuilt unless it does not exist")}