KiCad Libraries
Sign in or create your account | Project List | Help
KiCad Libraries Git Source Tree
Root/
Source at commit 7f3f9267cb007e13eca0af273f9eedad0c6c5659 created 5 years 11 months ago. By Werner Almesberger, components/stm32.lib: add STM32L052x6/8 in QFN32 (KxU) package | |
---|---|
1 | #!/usr/bin/perl |
2 | # |
3 | # gencon.pl - Generate generic connectors |
4 | # |
5 | # Copyright 2012, 2016 by Werner Almesberger |
6 | # |
7 | # This program is free software; you can redistribute it and/or modify |
8 | # it under the terms of the GNU General Public License as published by |
9 | # the Free Software Foundation; either version 2 of the License, or |
10 | # (at your option) any later version. |
11 | # |
12 | |
13 | |
14 | sub intro |
15 | { |
16 | local ($name, $h, $s) = @_; |
17 | my $b = $s ? $h + 150 : $h; |
18 | |
19 | $name .= "_S$s" if $s; |
20 | |
21 | print "#\n# $name\n#\n"; |
22 | print "DEF $name CON 0 40 Y N 1 F N\n"; |
23 | print "F0 \"CON\" 0 " . ($h + 50) . " 60 H V C CNN\n"; |
24 | print "F1 \"$name\" 0 " . (-$b - 50) . " 60 H V C CNN\n"; |
25 | } |
26 | |
27 | |
28 | sub box |
29 | { |
30 | local ($h, $s) = @_; |
31 | my $b = $s ? $h + 150 : $h; |
32 | |
33 | print "S -100 -$b 100 $h 0 1 0 N\n"; |
34 | for (my $i = 0; $i != $s; $i++) { |
35 | my $n = sprintf("S%d", $i+1); |
36 | |
37 | print "X $n $n " . (400 * ($i - 0.5) * 2) . " " . |
38 | (-$h - 100) . " 300 " . |
39 | ("R", "L")[$i] . " 50 50 1 1 P\n"; |
40 | } |
41 | } |
42 | |
43 | |
44 | # Single and dual row, with the same number of pins in each row |
45 | |
46 | sub even |
47 | { |
48 | local ($x, $s) = @_; |
49 | |
50 | for (my $y = 1; $y <= 2; $y++) { |
51 | my $name = "CONN_$x"; |
52 | my $h = $x / 2 * 100; |
53 | |
54 | $name .= "X$y" if $y > 1; |
55 | &intro($name, $h, $s); |
56 | |
57 | print "DRAW\n"; |
58 | &box($h, $s); |
59 | |
60 | my $n = 1; |
61 | |
62 | for (my $px = 1; $px <= $x; $px++) { |
63 | for (my $py = 1; $py <= $y; $py++) { |
64 | print "X $n $n " . (400 * ($py - 1.5) * 2) . |
65 | " " . ($h - $px * 100 + 50) . " 300 " . |
66 | ("?", "R", "L")[$py] . " 50 50 1 1 P\n"; |
67 | $n++; |
68 | } |
69 | } |
70 | print "ENDDRAW\n"; |
71 | print "ENDDEF\n"; |
72 | } |
73 | } |
74 | |
75 | |
76 | # Dual row, with rows differing by one pin (D-Sub and similar) |
77 | |
78 | sub odd |
79 | { |
80 | local ($x, $s) = @_; |
81 | my $h = $x / 2 * 100; |
82 | |
83 | &intro("CONN_$x" . "_" . ($x - 1), $h, $s); |
84 | print "DRAW\n"; |
85 | &box($h, $s); |
86 | for (my $px = 1; $px <= $x; $px++) { |
87 | print "X $px $px -400 " . |
88 | ($h - $px * 100 + 50) . " 300 R 50 50 1 1 P\n"; |
89 | next if $px == $x; |
90 | $n = $px + $x; |
91 | print "X $n $n 400 " . |
92 | ($h - $px * 100) . " 300 L 50 50 1 1 P\n"; |
93 | } |
94 | print "ENDDRAW\n"; |
95 | print "ENDDEF\n"; |
96 | } |
97 | |
98 | |
99 | print "EESchema-LIBRARY Version 2.3 Date: `date`\n"; |
100 | print "#encoding utf-8\n"; |
101 | for ($x = 1; $x <= 40; $x++) { |
102 | for ($s = 0; $s <= 2; $s++) { |
103 | &even($x, $s); |
104 | &odd($x, $s) if $x > 1; |
105 | } |
106 | } |
107 | print "#\n#End Library\n"; |
108 |
Branches:
master