chiark / gitweb /
quacks-ingredients: gcode manipulation wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 19 Feb 2020 23:15:56 +0000 (23:15 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 19 Feb 2020 23:15:56 +0000 (23:15 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
quacks-ingredients-make-copy-gcodes [new file with mode: 0755]

diff --git a/quacks-ingredients-make-copy-gcodes b/quacks-ingredients-make-copy-gcodes
new file mode 100755 (executable)
index 0000000..c2c0849
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# usage:
+#    ./quacks-ingredients-make-copy-gcodes Tests_L
+# Uses
+#    quacks-ingredients-L$l,Tests_L.auto.stl
+# to make
+#    quacks-ingredients-L$l,Tests_L.auto.gcode
+# and then edits them and copies them to the SD card as
+#    PREPARED/Q$l.G
+
+set -e
+
+f=$1
+shift
+
+umount /media/sd >/dev/null 2>&1 ||:
+mount /media/sd
+
+lhs=quacks-ingredients-L
+
+gh () {
+       g=$lhs$l.auto.gcode
+       h=/media/sd/PREPARED/Q$l.G
+}
+
+for l in 1 2 3 4 5; do
+       gh
+       cura -s $lhs$l,$f.auto.stl -o $g
+       case $l in
+       1|2|3|4)
+               perl -i~ -pe 's/^/;/ if m/^M140 S0\b.*\n/' $g
+               ;;
+       5)      ;;
+       *)      echo >&2 "??? $l"; exit 1 ;;
+       esac
+
+       perl -i~ -ne '
+               $l =~ s/^/;/ if m/^M400/;
+               print $l or die $!;
+               $l = $_;
+               END { print $l or die $!; }
+       ' $g
+
+       cp $g $h
+done
+
+umount /media/sd
+mount /media/sd
+
+for l in 1 2 3 4 5; do
+       gh
+       cmp $g $h
+       ls -l $h
+done
+
+umount /media/sd