Date:2016-09-18 06:04:49 (3 years 10 months ago)
Author:Werner Almesberger
Commit:723c6fdb43e40b74db56116b0e9ca85cc0655b47
Message:components/gencon.pl: add variants with one or two shield/mounting pads

Files: components/gencon.pl (3 diffs)

Change Details

components/gencon.pl
1111#
1212
1313
14sub 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
28sub 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
1444# Single and dual row, with the same number of pins in each row
1545
1646sub even
1747{
18    local ($x) = @_;
48    local ($x, $s) = @_;
1949
2050    for (my $y = 1; $y <= 2; $y++) {
2151        my $name = "CONN_$x";
22        $name .= "X$y" if $y > 1;
23        print "#\n# $name\n#\n";
24        print "DEF $name CON 0 40 Y N 1 F N\n";
2552        my $h = $x / 2 * 100;
26        print "F0 \"CON\" 0 " . ($h + 50) . " 60 H V C CNN\n";
27        print "F1 \"$name\" 0 " . (-$h - 50) . " 60 H V C CNN\n";
53
54        $name .= "X$y" if $y > 1;
55        &intro($name, $h, $s);
56
2857        print "DRAW\n";
29        print "S -100 -$h 100 $h 0 1 0 N\n";
58        &box($h, $s);
59
3060        my $n = 1;
61
3162        for (my $px = 1; $px <= $x; $px++) {
3263            for (my $py = 1; $py <= $y; $py++) {
3364                print "X $n $n " . (400 * ($py - 1.5) * 2) .
...... 
4677
4778sub odd
4879{
49    local ($x) = @_;
50
51    my $name = "CONN_$x" . "_" . ($x - 1);
52    print "#\n# $name\n#\n";
53    print "DEF $name CON 0 40 Y N 1 F N\n";
80    local ($x, $s) = @_;
5481    my $h = $x / 2 * 100;
55    print "F0 \"CON\" 0 " . ($h + 50) . " 60 H V C CNN\n";
56    print "F1 \"$name\" 0 " . (-$h - 50) . " 60 H V C CNN\n";
82
83    &intro("CONN_$x" . "_" . ($x - 1), $h, $s);
5784    print "DRAW\n";
58    print "S -100 -$h 100 $h 0 1 0 N\n";
85    &box($h, $s);
5986    for (my $px = 1; $px <= $x; $px++) {
6087        print "X $px $px -400 " .
6188            ($h - $px * 100 + 50) . " 300 R 50 50 1 1 P\n";
...... 
7299print "EESchema-LIBRARY Version 2.3 Date: `date`\n";
73100print "#encoding utf-8\n";
74101for ($x = 1; $x <= 40; $x++) {
75    &even($x);
76    &odd($x) if $x > 1;
102    for ($s = 0; $s <= 2; $s++) {
103        &even($x, $s);
104        &odd($x, $s) if $x > 1;
105    }
77106}
78107print "#\n#End Library\n";

Archive Download the corresponding diff file

Branches:
master



interactive