1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

renamed gerber/ to fab/

This commit is contained in:
Werner Almesberger
2011-03-22 21:20:27 -03:00
parent e95548df82
commit 0f20739519
2 changed files with 0 additions and 0 deletions

78
fab/gmerge Executable file
View File

@@ -0,0 +1,78 @@
#!/usr/bin/perl
#
# gmerge - Merge multiple KiCAD Gerber files into one
#
# 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.
#
$state = "HDR";
LINE: while (<>) {
if ($state eq "HDR") {
if (/^G04 APERTURE LIST/) {
$state = "APT";
next;
}
$hdr .= $_;
$phdr .= $_ unless /^G04/;
next;
}
if ($state eq "APT") {
if (/^G04 APERTURE END LIST/) {
$state = "CMD";
next;
}
die "unrecognized aperture" unless /^%ADD(\d+)C,((\d|\.)+)\*%/;
for (keys %apt) {
if ($apt{$_} == $2) {
$map{$1} = $_;
next LINE;
}
}
for ($t = $1; defined $apt{$t}; $t++) {}
$apt{$t} = $2;
$map{$1} = $t;
next;
}
die "internal error" unless $state eq "CMD";
if (/^M02\*/) {
$state = "HDR";
if (defined $ghdr) {
if ($gphdr ne $phdr) {
print STDERR "--- first header ---\n", $gphdr;
print STDERR "--- current header ---\n", $phdr;
die "incompatible headers";
}
} else {
$ghdr = $hdr;
$gphdr = $phdr;
}
undef $hdr;
undef $phdr;
next;
}
if (/^G54D(\d+)\*/) {
die "undeclared aperture" unless defined $map{$1};
$c .= "G54D".$map{$1}."*\n";
next;
}
die "unexpected command \"$_\"" unless /^X-?\d+Y-?\d+D0*[12]\*/;
$c .= $_;
}
print $ghdr || die $!;
print "G04 APERTURE LIST*\n" || die $!;
for (sort keys %apt) {
print "\%ADD".$_."C,".$apt{$_}."*%\n" || die $!;
}
print "G04 APERTURE END LIST*\n" || die $!;
print $c || die $!;
print "M02*\n" || die $!;

133
fab/prettygerbv Executable file
View File

@@ -0,0 +1,133 @@
#!/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))"
EDGE="(cons 'color #(0 0 0))"
FRONT="(cons 'color #(65535 10000 10000))"
BACK="(cons 'color #(30000 65535 30000))"
EDGE2="(cons 'color #(30000 40000 65535))"
usage()
{
cat <<EOF 1>&2
usage: $0 project-name view png-file
view "front", "back", "conn", "all"
EOF
exit 1
}
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
}
run_gerbv()
{
gerbv -p _gvp --dpi=600 -x png -o "$1"
}
front()
{
layers_begin 4
layer $NAME-Front.gtl $COPPER
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
run_gerbv "$1"
}
back()
{
layers_begin 4
layer $NAME-Back.gbl $COPPER
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
run_gerbv _tmp.png
convert -flop _tmp.png "$1"
rm -f _tmp.png
}
conn()
{
layers_begin 2
layer $NAME-Back.gbl $BACK
layer $NAME-Front.gtl $FRONT
layer $NAME-PCB_Edges.gbr $EDGE2
layers_end
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
}
[ "$4" ] && usage
[ ! "$3" ] && usage
NAME=$1
OUT=$3
case "$2" in
front|back|conn) ;;
all) ;;
*) usage;;
esac
$2 "$OUT"
rm -f _gvp