lw35-upgrade/printer/scripts/print.sh

40 lines
973 B
Bash
Raw Normal View History

2020-05-16 16:29:32 +02:00
#!/bin/bash
source shared.sh
ML=$(( (110-$LL) / 2))
MT=$(( (64 - $PL) / 2 ))
echo "Margin left: $ML"
echo "Margin top : $MT"
echo "Page width : $LL"
echo "Page length: $PL"
if [ $MT -gt 127 ]; then
echo "Margin top > 127 not supported because I am lazy. Is $MT."
exit
fi
MT=$(( $MT + 128 )) # Set "move by n line bit"
#exit
echo -ne $(printf "\\\\x%02x\\\\x%02x" 224 $ML) > /dev/lw35
MR=$((ML + $LL + 2)); # Plus 2 because bug in FW in conjunction with manual newlines
echo -ne $(printf "\\\\x%02x\\\\x%02x" 225 $MR) > /dev/lw35
for file in ./out/out*; do
foo=""
while [ true ]; do
echo "Insert a piece of paper and press enter. When you're done, enter y."
read foo
if [ "$foo" == "y" ]; then
break;
fi
echo -ne "\xE3\x8C" > /dev/lw35 # Draw in until at top of paper
echo -ne $(printf "\\\\x%02x\\\\x%02x" 0xE3 $MT) > /dev/lw35 # Move over margin top
done
echo "Printing part $file..."
cat $file > /dev/lw35
echo "Part done."
done
echo "Done."