forked from jschuh/klipper-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pause_resume_cancel.cfg
144 lines (132 loc) · 4.7 KB
/
pause_resume_cancel.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright (C) 2022 Justin Schuh <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
# Enables pause/resume functionality
[gcode_macro pause]
description: Pauses the current print.
Usage: PAUSE [X=<pos>] [Y=<pos>] [Z=<pos>] [E=<retract_length>] [B=<beeps>]
rename_existing: _KM_PAUSE_BASE
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
# Retract length (negative)
{% set E = (params.E|default(5))|float %}
{% if printer.pause_resume.is_paused %}
{ action_respond_info("Print already paused") }
{% elif printer.idle_timeout.state | string == "Printing" or
(printer.virtual_sdcard|default({})).is_active|default(False) %}
_KM_PRINT_STATUS ACTION=CHANGE STATUS=pausing RESET_STACK=1
{% set position = printer.gcode_move.gcode_position %}
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_x VALUE="{position.x}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_y VALUE="{position.y}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_z VALUE="{position.z}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_e VALUE="{E}"
SAVE_GCODE_STATE NAME=_KM_PAUSE_OVERRIDE_STATE
_KM_PAUSE_BASE
M83
{% if printer.extruder.can_extrude %}
G1 E{'%.4f' % -E} F{km.load_speed}
{% endif %}
PARK P=2{% for k in params|select("in", "XYZ") %}{
' '~k~'="'~params[k]~'"'}{% endfor %}
_KM_BEEP_IF_AVAILABLE BEEPS={params.B|default(10)}
{% else %}
{ action_respond_info("Print not in progress") }
{% endif %}
[gcode_macro m600]
description: Pauses the current print.
Usage: M600 [B<beeps>] [E<pos>] [L<pos>] [R<temp>] [U<pos>] [X<pos>] [Y<pos>]
[Z<pos>]
gcode:
PAUSE B="{0}" P=2{% for k in params|select("in", "EXYZ") %}{
' '~k~'="'~params[k]~'"'}{% endfor %}
UNLOAD_FILAMENT{% if 'U' in params %} LENGTH={params.U}{% endif
%} BEEPS="{params.B|default(10)|int}"
{% if 'R' in params %}M109 S{params.R}{% endif %}
[gcode_macro m601]
description: Pauses the current print.
Usage: M601
gcode:
PAUSE
[gcode_macro m602]
description: Resumes the currently paused print.
Usage: M602
gcode:
RESUME
[gcode_macro m24]
rename_existing: M24.6245197
gcode:
{% if printer.pause_resume.is_paused %}
RESUME
{% else %}
M24.6245197
{% endif %}
[gcode_macro m25]
rename_existing: M25.6245197
gcode:
PAUSE
[gcode_macro resume]
description: Resumes the currently paused print.
Usage: RESUME [E<pos>]
rename_existing: _KM_RESUME_BASE
variable_saved_extruder_temp: 0
variable_saved_x: 0.0
variable_saved_y: 0.0
variable_saved_z: 0.0
variable_saved_e: 0.0
gcode:
{% if printer.pause_resume.is_paused %}
{% set km = printer["gcode_macro _km_globals"] %}
# Warm the extruder back up if needed.
{% set extruder = printer[printer.toolhead.extruder] %}
{% if extruder.target <= printer.configfile.settings[
printer.toolhead.extruder].min_temp
| float + 0.5 %}
M109 S{saved_extruder_temp}
{% endif %}
# If there's no saved_e assume we're completing a filament change and
# retract enough to avoid drooling on the model.
{% if 'E' not in params and not saved_e %}
{% set saved_e = 5.0 %}
G1 E{'%.4f' % -saved_e } F{km.load_speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_extruder_temp VALUE="{0}"
G90
# Move back to last position before unretracting.
G0 X{saved_x} Y{saved_y} F{km.travel_speed_xy}
G0 Z{saved_z} F{km.travel_speed_z}
G91
# Unretract
G1 E{'%.4f' % (params.E|default(saved_e))} F{km.load_speed}
RESTORE_GCODE_STATE NAME=_KM_PAUSE_OVERRIDE_STATE MOVE=1
_KM_RESUME_BASE
{% else %}
{ action_respond_info("Printer is not paused.") }
{% endif %}
_KM_PRINT_STATUS ACTION=CHANGE STATUS=printing RESET_STACK=1
# TODO: Fix casing after front-ends get fixed
[gcode_macro CANCEL_PRINT]
description: Cancels the current print.
Usage: CANCEL_PRINT
rename_existing: _KM_CANCEL_PRINT_BASE
gcode:
_KM_CHECK_IS_PRINTING
_KM_PRINT_STATUS ACTION=CHANGE STATUS=cancelling RESET_STACK=1
SET_GCODE_VARIABLE MACRO=_print_end_inner VARIABLE=cancelled VALUE="{True}"
PRINT_END
_KM_CANCEL_PRINT_BASE
{% if printer.pause_resume.is_paused %}
RESTORE_GCODE_STATE NAME=_KM_PAUSE_OVERRIDE_STATE MOVE=0
{% endif %}
CLEAR_PAUSE
_KM_APPLY_PRINT_OFFSET RESET=1
{% if 'virtual_sdcard' in printer and not printer.virtual_sdcard.is_active %}
SDCARD_RESET_FILE
{% endif %}
[gcode_macro clear_pause]
description: Clears the current pause state.
Usage: CLEAR_PAUSE
rename_existing: _KM_CLEAR_PAUSE
gcode:
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_e VALUE="{0.0}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_extruder_temp VALUE="{0}"
_KM_CLEAR_PAUSE