mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-16 18:51:53 +02:00
fab/m1/: quick and dirty adaptation of prettygerbv and drl2gerber to M1
This commit is contained in:
parent
0de3b96170
commit
2a6496d3ed
18
fab/m1/Makefile
Normal file
18
fab/m1/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
D=rc3_gerber
|
||||
|
||||
all: front.png back.png
|
||||
|
||||
drill.pho:
|
||||
tr -d '\015' <$(D)/drl00.drl | ./drl2gerber >$@
|
||||
|
||||
front.png: drill.pho
|
||||
cd $(D) && ../prettygerbv -d ../drill.pho foo front ../$@
|
||||
|
||||
back.png: drill.pho
|
||||
cd $(D) && ../prettygerbv -d ../drill.pho foo back ../$@
|
||||
|
||||
conn.png: drill.pho
|
||||
cd $(D) && ../prettygerbv -d ../drill.pho foo conn ../$@
|
||||
|
||||
clean:
|
||||
rm -f drill.pho front.png back.png conn.png
|
3
fab/m1/README
Normal file
3
fab/m1/README
Normal file
@ -0,0 +1,3 @@
|
||||
wget http://downloads.qi-hardware.com/hardware/milkymist_one/gerber/rc3/rc3_gerber.tar.bz2
|
||||
tar xfj rc3_gerber.tar.bz2
|
||||
make
|
74
fab/m1/drl2gerber
Executable file
74
fab/m1/drl2gerber
Executable file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# drl2gerber - Convert a KiCAD-generated Excellon drill file to Gerber
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
|
||||
print "G04 MACHINE-GENERATED FROM DRILL FILE*\n" || die;
|
||||
print "G01*\n" || die; # linear Interpolation
|
||||
print "G70*\n" || die; # inch units
|
||||
print "G90*\n" || die; # absolute Mode
|
||||
print "%MOIN*%*\n" || die; # inches, RS274X-style
|
||||
print "%FSLAX34Y34*%\n" || die; # format
|
||||
|
||||
$x0 = 7300;
|
||||
$y0 = 268910;
|
||||
|
||||
|
||||
sub u()
|
||||
{
|
||||
my $f = 1000000;
|
||||
|
||||
$_[0] =~ /^(-?)(\d+)$/;
|
||||
my $s = 0;
|
||||
for (split("", $2)) {
|
||||
$s += $_*$f;
|
||||
$f /= 10;
|
||||
}
|
||||
return $1 eq "-" ? -$s : $s;
|
||||
}
|
||||
|
||||
|
||||
while (<>) {
|
||||
chop;
|
||||
if (/^T(\d+)C/) {
|
||||
print "%ADD", $1+10, "C,$'*%\n" || die;
|
||||
print "G54D", $1+10, "*\n" || die;
|
||||
$faux_g85 = 0;
|
||||
# we dont' seem to have easily machine-readable
|
||||
# information in Altium's Excellon to tell what should
|
||||
# be a hole and what should be a slot
|
||||
undef $last;
|
||||
next;
|
||||
}
|
||||
if (/^T(\d+)$/) {
|
||||
print "G54D", $1+10, "*\n" || die;
|
||||
next;
|
||||
}
|
||||
if (/^X([-0-9.]+)Y([-0-9.]+)$/) {
|
||||
my $c = sprintf("X%dY%d", &u($1)+$x0, &u($2)+$y0);
|
||||
|
||||
if ($faux_g85) {
|
||||
print "${last}D02*\n${c}D01*\n" if defined $last;
|
||||
$last = $c;
|
||||
} else {
|
||||
print "${c}D03*\n" || die;
|
||||
}
|
||||
next;
|
||||
}
|
||||
if (/^X([-0-9.]+)Y([-0-9.]+)G85X([-0-9.]+)Y([-0-9.]+)$/) {
|
||||
printf("X%dY%dD02*\nX%dY%dD01*\n",
|
||||
&u($1)+$x0, &u($2)+$y0, &u($3)+$x0, &u($4)+$y0) || die;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
print "M02*\n" || die;
|
152
fab/m1/prettygerbv
Executable file
152
fab/m1/prettygerbv
Executable file
@ -0,0 +1,152 @@
|
||||
#!/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 #(65535 65535 0))"
|
||||
DRILL="(cons 'color #(0 0 40000))"
|
||||
|
||||
FRONT="(cons 'color #(65535 10000 10000))"
|
||||
BACK="(cons 'color #(30000 65535 30000))"
|
||||
EDGE2="(cons 'color #(30000 40000 65535))"
|
||||
L2="(cons 'color #(1000 1000 1000))"
|
||||
L3="(cons 'color #(1000 1000 1000))"
|
||||
L4="(cons 'color #(1000 1000 1000))"
|
||||
L5="(cons 'color #(1000 1000 1000))"
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF 1>&2
|
||||
usage: $0 [-d file] project-name view png-file
|
||||
|
||||
view "front", "back", "conn", "all"
|
||||
|
||||
-d file also use drill file (converted to Gerber)
|
||||
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 5
|
||||
layer art01.pho $COPPER
|
||||
[ "$drill" ] && layer $drill $DRILL
|
||||
layer smd0129.pho $PASTE
|
||||
layer sm0125.pho $INV $MASK
|
||||
layer sst0127.pho $SILK
|
||||
# layer $NAME-PCB_Edges.gbr $EDGE
|
||||
layers_end
|
||||
|
||||
run_gerbv "$1"
|
||||
}
|
||||
|
||||
|
||||
back()
|
||||
{
|
||||
layers_begin 5
|
||||
layer art06.pho $COPPER
|
||||
[ "$drill" ] && layer $drill $DRILL
|
||||
layer smd0630.pho $PASTE
|
||||
layer sm0626.pho $INV $MASK
|
||||
layer ssb0628.pho $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 6
|
||||
layer art06.pho $BACK
|
||||
layer art05.pho $L5
|
||||
layer art04.pho $L4
|
||||
layer art03.pho $L3
|
||||
layer art02.pho $L2
|
||||
layer art01.pho $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
|
||||
}
|
||||
|
||||
drill=
|
||||
if [ "$1" = -d ]; then
|
||||
drill=$2
|
||||
shift 2
|
||||
fi
|
||||
|
||||
[ "$4" ] && usage
|
||||
[ ! "$3" ] && usage
|
||||
|
||||
NAME=$1
|
||||
OUT=$3
|
||||
|
||||
case "$2" in
|
||||
front|back|conn) ;;
|
||||
all) ;;
|
||||
*) usage;;
|
||||
esac
|
||||
|
||||
$2 "$OUT"
|
||||
|
||||
#rm -f _gvp
|
Loading…
Reference in New Issue
Block a user