BlinkenArea - GitList
Repositories
Blog
Wiki
bulb
Code
Commits
Branches
Tags
Search
Tree:
51e0191
Branches
Tags
master
petaflot
1.0.0
1.1.0
1.1.1
bulb
electrics
bulb.pcb.pl
version 1.0.0
Stefan Schuermans
commited
51e0191
at 2012-06-06 19:34:07
bulb.pcb.pl
Blame
History
Raw
#! /usr/bin/perl use strict; use warnings; my $pi = 3.1415; sub mm2pcb { my $mm = shift; my $pcb = $mm * 1.0e5 / 25.4; return int($pcb >= 0.0 ? $pcb + 0.5 : $pcb - 0.5) } sub line { my $sx = shift; my $sy = shift; my $ex = shift; my $ey = shift; printf "\tElementLine[%d %d %d %d 1000]\n", mm2pcb($sx), mm2pcb($sy), mm2pcb($ex), mm2pcb($ey); } sub pad { my $sx = shift; my $sy = shift; my $ex = shift; my $ey = shift; my $w = shift; my $name = shift; my $no = shift; printf "\tPad[%d %d %d %d %d 3000 %d \"%s\" \"%d\" \"square\"]\n", mm2pcb($sx), mm2pcb($sy), mm2pcb($ex), mm2pcb($ey), mm2pcb($w), mm2pcb($w) + 600, $name, $no; } sub element { my $idx = shift; my $cx = shift; my $cy = shift; my $angle = shift; my $ov_tx = shift; my $ov_ty = shift; my $rx = cos($angle); my $ry = sin($angle); my $bx = cos($angle + $pi / 2); my $by = sin($angle + $pi / 2); my $angle_i = int($angle * 4 / $pi + 0.5); my $tx = -2.0; my $ty = 1.5; my $ta = 0; if ($angle_i == 1) { $tx = -5.0; $ty = 0.5; $ta = 0; } elsif ($angle_i == 2) { $tx = -3.0; $ty = 2.0; $ta = 1; } elsif ($angle_i == 3) { $tx = -5.0; $ty = -2.5; $ta = 0; } elsif ($angle_i == 4) { $tx = -2.0; $ty = -3.0; $ta = 0; } elsif ($angle_i == 5) { $tx = 1.5; $ty = -2.0; $ta = 0; } elsif ($angle_i == 6) { $tx = 1.5; $ty = 2.0; $ta = 1; } elsif ($angle_i == 7) { $tx = 1.0; $ty = 1.0; $ta = 0; } if ($ov_tx && $ov_ty) { $tx = $ov_tx; $ty = $ov_ty; } printf "Element[\"\" \"APL3015\" \"LED%d\" \"APL3015\" %d %d %d %d %d 100 \"\"]\n(\n", $idx, mm2pcb($cx), mm2pcb($cy), mm2pcb($tx), mm2pcb($ty), $ta; pad( - 1.5 * $rx - 0.1 * $bx, - 1.5 * $ry - 0.1 * $by, - 1.5 * $rx + 0.1 * $bx, - 1.5 * $ry + 0.1 * $by, 1.4, "A", 1); pad( 1.5 * $rx - 0.1 * $bx, 1.5 * $ry - 0.1 * $by, 1.5 * $rx + 0.1 * $bx, 1.5 * $ry + 0.1 * $by, 1.4, "C", 2); line(- 2.2 * $rx - 1.0 * $bx, - 2.2 * $ry - 1.0 * $by, 2.2 * $rx - 1.0 * $bx, 2.2 * $ry - 1.0 * $by); line(- 2.2 * $rx + 1.0 * $bx, - 2.2 * $ry + 1.0 * $by, 2.2 * $rx + 1.0 * $bx, 2.2 * $ry + 1.0 * $by); line(- 2.4 * $rx - 0.8 * $bx, - 2.4 * $ry - 0.8 * $by, - 2.4 * $rx + 0.8 * $bx, - 2.4 * $ry + 0.8 * $by); line( 2.4 * $rx - 0.8 * $bx, 2.4 * $ry - 0.8 * $by, 2.4 * $rx + 0.8 * $bx, 2.4 * $ry + 0.8 * $by); line( 1.3 * $rx - 1.2 * $bx, 1.3 * $ry - 1.2 * $by, 1.5 * $rx - 1.2 * $bx, 1.5 * $ry - 1.2 * $by); line( 1.3 * $rx + 1.2 * $bx, 1.3 * $ry + 1.2 * $by, 1.5 * $rx + 1.2 * $bx, 1.5 * $ry + 1.2 * $by); print "\t)\n\n"; } my $size = mm2pcb(50.0); my $grid = mm2pcb(1.0); print <<EOF; FileVersion[20070407] PCB["" $size $size] Grid[$grid.0 0 0 1] Cursor[0 0 0.000000] PolyArea[200000000.000000] Thermal[0.500000] DRC[600 600 600 600 1200 600] Flags("rubberband,nameonpcb,snappin") Groups("1,c:2,s:3:4:5:6:7:8") Styles["Signal,1200,2400,1200,3000:Power,2400,4800,2400,3000:Fat,3600,7200,3600,3000:Skinny,600,1200,600,3000"] EOF element(1, 17.5, 43.0, 0); element(2, 12.5, 43.0, 0); element(3, 7.8, 42.2, $pi / 4); for (my $i = 0; $i < 6; ++$i) { element(4 + $i, 7.0, 37.5 - 5.0 * $i, $pi / 2); } element(10, 7.8, 7.8, $pi * 3 / 4); for (my $i = 0; $i < 6; ++$i) { element(11 + $i, 12.5 + 5.0 * $i, 7.0, $pi); } element(17, 42.2, 7.8, $pi * 5 / 4); for (my $i = 0; $i < 6; ++$i) { element(18 + $i, 43.0, 12.5 + 5.0 * $i, $pi * 3 / 2); } element(24, 42.2, 42.2, $pi * 7 / 4); for (my $i = 0; $i < 3; ++$i) { element(25 + $i, 37.5 - 5.0 * $i, 43.0, 0); } element(28, 22.8, 42.5, $pi / 4, -2.0, 2.5); element(29, 22.0, 37.5, $pi / 2); element(30, 20.3, 32.2, $pi / 4); element(31, 16.0, 27.9, $pi / 4); for (my $i = 0; $i < 7; ++$i) { element(32 + $i, 25.0 - 11.0 * cos($pi * $i / 6), 22.5 - 11.0 * sin($pi * $i / 6), $pi * ($i + 3) / 6); } element(39, 34.0, 27.9, $pi * 7 / 4); element(40, 29.7, 32.2, $pi * 7 / 4); element(41, 28.0, 37.5, $pi * 3 / 2); element(42, 20.7, 18.0, $pi * 7 / 4); my @layers = qw/component solder GND power signal1 signal2 signal3 signal4 silk silk/; for (my $i = 0; $i < @layers; ++$i) { my $no = $i + 1; my $layer = $layers[$i]; print <<EOF; Layer($no "$layer") ( ) EOF }