chiark / gitweb /
quacks-ingredients: gcode manipulation
[reprap-play.git] / quacks-ingredients-make-copy-gcodes
1 #!/bin/sh
2 #
3 # usage:
4 #    ./quacks-ingredients-make-copy-gcodes Tests_L
5 # Uses
6 #    quacks-ingredients-L$l,Tests_L.auto.stl
7 # to make
8 #    quacks-ingredients-L$l,Tests_L.auto.gcode
9 # and then edits them and copies them to the SD card as
10 #    PREPARED/Q$l.G
11
12 set -e
13
14 f=$1
15 shift
16
17 lhs=quacks-ingredients-L
18
19 gh () {
20         g=$lhs$l.auto.gcode
21         h=/media/sd/PREPARED/Q$l.G
22 }
23
24 for l in 1 2 3 4 5; do
25         gh
26         cura -s $lhs$l,$f.auto.stl -o $g
27         case $l in
28         1|2|3|4)
29                 perl -i~ -pe 's/^/;/ if m/^M140 S0\b.*\n/' $g
30                 ;;
31         esac
32
33         perl -i~ -ne '
34                 $l =~ s/^/;/ if m/^M400/;
35                 $l .= "G91\nG1 Z5\nG90\n" if m/^M84/;
36                 print $l or die $!;
37                 $l = $_;
38                 END { print $l or die $!; }
39         ' $g
40 done
41
42 exec 3>${lhs}234.auto.gcode
43 for l in 2 3; do
44         gh
45         perl -pe 's/^/;/ if m/^M104 S0\b/ || (m/^M84/..0)' $g >&3
46 done
47 for l in 4; do
48         gh
49         cat $g >&3
50 done
51
52 umount /media/sd >/dev/null 2>&1 ||:
53 mount /media/sd
54
55 for l in 1 2 3 4 5 234; do
56         cp $g $h
57 done
58
59 umount /media/sd
60 mount /media/sd
61
62 for l in 1 2 3 4 5 234; do
63         gh
64         cmp $g $h
65         ls -l $h
66 done
67
68 umount /media/sd