-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgcode_pause
executable file
·37 lines (33 loc) · 1.01 KB
/
gcode_pause
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
#!/usr/bin/env sh
#---------------------------------------------------------#
# gcode_pause
# Donald L. Merand
# ----------------
# Given (1) a file, (2) a layer number, and an optional
# (3) regular expression matching layer change, add a
# pause command (defaults to "M226" but changeable) to
# the GCODE.
#---------------------------------------------------------#
# if your printer firmware does something different to pause, eg M0,
# vvvvvv change this
PAUSE_CMD="M226"
# "parse" input params
FILENAME="$1"
shift
LAYER="$1"
shift
if [ "$1" ]; then
REGEX="$1"
else
# if you don't use Simplify3D, you might want to change...
# vvvvvvvvvvvvvvvvv default layer change code in Simplify3D.
REGEX="; layer ${LAYER},"
fi
# test for legit params
if [ -z "${FILENAME}" -o -z "${LAYER}" ]; then
echo "USAGE: gcode_pause <<FILENAME>> <<LAYER_NUMBER_TO_PAUSE>> {LAYER_REGEX}"
exit 1
fi
# otherwise insert layer pause code
cat "${FILENAME}" |
awk "/${REGEX}/{print \"; USER-ADDED PAUSE\n${PAUSE_CMD}\"}{print \$0}"