2011-03-22 15:10:08 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# prettygerbv - Use gerbv to generate "pretty" views of a PCB
|
|
|
|
#
|
|
|
|
# Written 2011 by Werner Almesberger
|
|
|
|
# Copyright 2011 Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
COPPER="(cons 'color #(65535 50401 10000))"
|
|
|
|
PASTE="(cons 'color #(39083 39083 50000))"
|
|
|
|
MASK="(cons 'inverted #t) (cons 'color #(8839 53994 8178))"
|
|
|
|
SILK="(cons 'color #(65535 65535 65535))"
|
2011-03-25 01:02:23 +02:00
|
|
|
EDGE="(cons 'color #(65535 65535 0))"
|
|
|
|
DRILL="(cons 'color #(0 0 0))"
|
2011-03-22 15:10:08 +02:00
|
|
|
|
|
|
|
FRONT="(cons 'color #(65535 10000 10000))"
|
|
|
|
BACK="(cons 'color #(30000 65535 30000))"
|
|
|
|
EDGE2="(cons 'color #(30000 40000 65535))"
|
|
|
|
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF 1>&2
|
2011-03-25 01:02:23 +02:00
|
|
|
usage: $0 [-d file] project-name view png-file
|
2011-03-22 15:10:08 +02:00
|
|
|
|
|
|
|
view "front", "back", "conn", "all"
|
2011-03-25 01:02:23 +02:00
|
|
|
|
|
|
|
-d file also use drill file (converted to Gerber)
|
2011-03-22 15:10:08 +02:00
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 15:25:53 +02:00
|
|
|
layers_begin()
|
|
|
|
{
|
|
|
|
curr_layer=$1
|
|
|
|
echo '(gerbv-file-version! "2.0A")' >_gvp
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
layer()
|
|
|
|
{
|
|
|
|
file=$1
|
|
|
|
shift
|
|
|
|
[ -e "$file" ] || return
|
|
|
|
cat <<EOF >>_gvp
|
|
|
|
(define-layer! $curr_layer (cons 'filename "$file") $*)
|
|
|
|
EOF
|
|
|
|
curr_layer=`expr $curr_layer - 1`
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
layers_end()
|
|
|
|
{
|
|
|
|
echo '(set-render-type! 2)' >>_gvp
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 15:10:08 +02:00
|
|
|
run_gerbv()
|
|
|
|
{
|
2011-03-25 01:02:23 +02:00
|
|
|
gerbv -p _gvp --dpi=600 -b '#202020' -x png -o "$1"
|
2011-03-22 15:10:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
front()
|
|
|
|
{
|
2011-03-25 01:02:23 +02:00
|
|
|
layers_begin 5
|
2011-03-22 15:25:53 +02:00
|
|
|
layer $NAME-Front.gtl $COPPER
|
2011-03-25 01:02:23 +02:00
|
|
|
[ "$drill" ] && layer $drill $DRILL
|
2011-03-22 15:25:53 +02:00
|
|
|
layer $NAME-SoldP_Front.gtp $PASTE
|
|
|
|
layer $NAME-Mask_Front.gts $INV $MASK
|
|
|
|
layer $NAME-SilkS_Front.gto $SILK
|
|
|
|
layer $NAME-PCB_Edges.gbr $EDGE
|
|
|
|
layers_end
|
|
|
|
|
2011-03-22 15:10:08 +02:00
|
|
|
run_gerbv "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
back()
|
|
|
|
{
|
2011-03-25 01:02:23 +02:00
|
|
|
layers_begin 5
|
2011-03-22 15:25:53 +02:00
|
|
|
layer $NAME-Back.gbl $COPPER
|
2011-03-25 01:02:23 +02:00
|
|
|
[ "$drill" ] && layer $drill $DRILL
|
2011-03-22 15:25:53 +02:00
|
|
|
layer $NAME-SoldP_Back.gbp $PASTE
|
|
|
|
layer $NAME-Mask_Back.gbs $INV $MASK
|
|
|
|
layer $NAME-SilkS_Back.gbo $SILK
|
|
|
|
layer $NAME-PCB_Edges.gbr $EDGE
|
|
|
|
layers_end
|
|
|
|
|
2011-03-22 15:10:08 +02:00
|
|
|
run_gerbv _tmp.png
|
|
|
|
convert -flop _tmp.png "$1"
|
|
|
|
rm -f _tmp.png
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
conn()
|
|
|
|
{
|
2011-03-25 01:02:23 +02:00
|
|
|
layers_begin 3
|
2011-03-22 15:25:53 +02:00
|
|
|
layer $NAME-Back.gbl $BACK
|
|
|
|
layer $NAME-Front.gtl $FRONT
|
|
|
|
layer $NAME-PCB_Edges.gbr $EDGE2
|
|
|
|
layers_end
|
|
|
|
|
2011-03-22 15:10:08 +02:00
|
|
|
run_gerbv "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
all()
|
|
|
|
{
|
|
|
|
front _front.png
|
|
|
|
back _back.png
|
|
|
|
conn _conn.png
|
|
|
|
montage -geometry +4+4 _front.png _back.png _conn.png "$1"
|
|
|
|
rm -f _front.png _back.png _conn.png
|
|
|
|
}
|
|
|
|
|
2011-03-25 01:02:23 +02:00
|
|
|
drill=
|
|
|
|
if [ "$1" = -d ]; then
|
|
|
|
drill=$2
|
|
|
|
shift 2
|
|
|
|
fi
|
|
|
|
|
2011-03-22 15:10:08 +02:00
|
|
|
[ "$4" ] && usage
|
|
|
|
[ ! "$3" ] && usage
|
|
|
|
|
|
|
|
NAME=$1
|
|
|
|
OUT=$3
|
|
|
|
|
|
|
|
case "$2" in
|
|
|
|
front|back|conn) ;;
|
|
|
|
all) ;;
|
|
|
|
*) usage;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
$2 "$OUT"
|
|
|
|
|
|
|
|
rm -f _gvp
|