-
Notifications
You must be signed in to change notification settings - Fork 0
/
variable_heat_soaking.cfg
52 lines (44 loc) · 1.77 KB
/
variable_heat_soaking.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
# This is still work in progress
# !!! code is untested and will not work !!!
[gcode_macro _BED_SOAK_VARS]
variable_park_position: 150,150,50 # toolhead park position during soak
variable_measure_interval: 5 # interval to measure a new mesh in minutes
variable_soak_ok_delta: 0.02 # variance between two meshes to define soaking as finished
gcode:
[gcode_macro BED_SOAK]
gcode:
{% set soak_minutes = params.MINUTES|default(15)|int %}
{% set vars = ptiner['gcode_macro _BED_SOAK_VARS'] %}
{% set loop_count = soak_minutes / vars.measure_interval %}
{% if 'xyz' not in printer.toolhead.homed_axes %} G28 {% endif %}
# initial mesh
BED_MESH_CALIBRATE
# clear last_range variable
SET_GCODE_VARIABLE MACRO=_CHEK_MESH_RANGE VARIABLE=last_range VALUE=999
# loop through meshes
{% for n in range(0,loop_count) %}
_CHEK_MESH_RANGE
{% endfor %}
[gcode_macro _CHEK_MESH_RANGE]
variable_last_range = 999
gcode:
{% set vars = ptiner['gcode_macro _BED_SOAK_VARS'] %}
{% set ns = namespace() %}
{% set ns.min = 999 %}
{% set ns.max = -999 %}
{% for row in printer.bed_mesh.mesh_matrix %}
{% for point in row %}
{% if point < ns.min %} {% set ns.min = point %} {% endif %}
{% if point > ns.max %} {% set ns.max = point %} {% endif %}
{% endfor %}
{% endfor %}
{% set range = ns.max - ns.min %}
{% set range_Delta = (last_range|float - range)|abs %}
{% if range_Delta > vars.soak_ok_delta %}
# mesh changed too much -> update last_range for next loop, wait and do a new mesh
SET_GCODE_VARIABLE MACRO=_CHEK_MESH_RANGE VARIABLE=last_range VALUE={range}
G4 P{vars.measure_interval * 60 * 1000} # wait interval times
BED_MESH_CALIBRATE
{% else %}
# delta small enough -> do nothing to end for loop fast
{% endif %}