-
Notifications
You must be signed in to change notification settings - Fork 9
/
M702.cfg
41 lines (38 loc) · 1.72 KB
/
M702.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
# See: https://reprap.org/wiki/G-code#M702:_Unload_filament
[gcode_macro M702]
description: Unload filament compatible command
gcode:
# Setup fallback defaults
{% set default_u = 100 %} # set defualt extrude length
# Try load bowden tube length from saved variables
{% if 'save_variables' in printer %} # check if save variables is defined
{% set svv = printer.save_variables.variables %} # get variables object
{% if 'bowden_length' in svv %} # check if bowden length is defind
{% set default_u = svv.bowden_length %} # and load it if it exist
{% endif %}
{% endif %}
# Get command parameters
{% set p = params.P|default(8)|float %}
{% set p_f = params.PF|default(180)|float %}
{% set i = params.I|default(30)|float %}
{% set i_f = params.IF|default(180)|float %}
{% set u = params.U|default(default_u)|float %}
{% set u_f = params.UF|default(360)|float %}
{% if printer.idle_timeout.state == "Printing" and not printer.pause_resume.is_paused %}
{action_respond_info("This command cannot be used while printing")}
{% elif printer.extruder.temperature < 170 %}
{action_respond_info("Extruder temperature too low")}
{% else %}
SAVE_GCODE_STATE NAME=M702_state
M83 # relative positioning
{% if p > 0.0 %}
G1 E{p} F{p_f}
{% endif %}
{% if i > 0.0 %}
G1 E-{i} F{i_f}
{% endif %}
{% if u > 0.0 %}
G1 E-{u} F{u_f}
{% endif %}
RESTORE_GCODE_STATE NAME=M702_state MOVE=0
{% endif %}