-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathG1.cfg
41 lines (35 loc) · 1.17 KB
/
G1.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
[gcode_macro G1]
variable_pa_map_dict: {}
rename_existing: G99999
gcode:
{ action_respond_info("Printer is currently %s." % ( printer.idle_timeout.state )) }
{% set p=[] %}
{% for key in params %}
{% set p = p.append(key + params[key]) %}
{% endfor %}
{% if params.F is defined %}
{% set g1 = printer["gcode_macro G1"] %}
{% if "pa_map_dict" in g1 %}
{% set pa_map = g1.pa_map_dict %}
# M118 {pa_map}
{% endif %}
{% set original_pa = 0.0617 %}
{% set speed = params.F|int/60 %}
M118 {speed}
{% if speed < 100 %}
{% if speed in pa_map %}
# { action_respond_info("Exists in map!") }
{% set pa = pa_map[speed] %}
{% else %}
# { action_respond_info("Calculate new PA!") }
{% set pa = original_pa * (100/speed) %}
{% set dummy = pa_map.__setitem__(speed, pa) %}
# Update the map with the new dictionary value.
SET_GCODE_VARIABLE MACRO=G1 VARIABLE=pa_map_dict VALUE="{pa_map}"
{% endif %}
SET_PRESSURE_ADVANCE ADVANCE={pa}
{% else %}
SET_PRESSURE_ADVANCE ADVANCE={original_pa}
{% endif %}
{% endif %}
G99999 { p|join(" ") }