Date:2016-09-18 05:35:30 (3 years 10 months ago)
Author:Werner Almesberger
Commit:e640742621f0940fa42c3b8c2e7fb5b805010cbf
Message:components/gencon.pl: structure code a little more clearly

Files: components/gencon.pl (4 diffs)

Change Details

components/gencon.pl
22#
33# gencon.pl - Generate generic connectors
44#
5# Copyright 2012 by Werner Almesberger
5# Copyright 2012, 2016 by Werner Almesberger
66#
77# This program is free software; you can redistribute it and/or modify
88# it under the terms of the GNU General Public License as published by
...... 
1010# (at your option) any later version.
1111#
1212
13print "EESchema-LIBRARY Version 2.3 Date: `date`\n";
14print "#encoding utf-8\n";
15for ($x = 1; $x <= 40; $x++) {
16    for ($y = 1; $y <= 2; $y++) {
17        $name = "CONN_$x";
13
14# Single and dual row, with the same number of pins in each row
15
16sub even
17{
18    local ($x) = @_;
19
20    for (my $y = 1; $y <= 2; $y++) {
21        my $name = "CONN_$x";
1822        $name .= "X$y" if $y > 1;
1923        print "#\n# $name\n#\n";
2024        print "DEF $name CON 0 40 Y N 1 F N\n";
21        $h = $x / 2 * 100;
25        my $h = $x / 2 * 100;
2226        print "F0 \"CON\" 0 " . ($h + 50) . " 60 H V C CNN\n";
2327        print "F1 \"$name\" 0 " . (-$h - 50) . " 60 H V C CNN\n";
2428        print "DRAW\n";
2529        print "S -100 -$h 100 $h 0 1 0 N\n";
26        $n = 1;
27        for ($px = 1; $px <= $x; $px++) {
28            for ($py = 1; $py <= $y; $py++) {
30        my $n = 1;
31        for (my $px = 1; $px <= $x; $px++) {
32            for (my $py = 1; $py <= $y; $py++) {
2933                print "X $n $n " . (400 * ($py - 1.5) * 2) .
3034                    " " . ($h - $px * 100 + 50) . " 300 " .
3135                    ("?", "R", "L")[$py] . " 50 50 1 1 P\n";
...... 
3539        print "ENDDRAW\n";
3640        print "ENDDEF\n";
3741    }
42}
43
3844
39    next if $x == 1;
45# Dual row, with rows differing by one pin (D-Sub and similar)
4046
41    $name = "CONN_$x" . "_" . ($x - 1);
47sub odd
48{
49    local ($x) = @_;
50
51    my $name = "CONN_$x" . "_" . ($x - 1);
4252    print "#\n# $name\n#\n";
4353    print "DEF $name CON 0 40 Y N 1 F N\n";
44    $h = $x / 2 * 100;
54    my $h = $x / 2 * 100;
4555    print "F0 \"CON\" 0 " . ($h + 50) . " 60 H V C CNN\n";
4656    print "F1 \"$name\" 0 " . (-$h - 50) . " 60 H V C CNN\n";
4757    print "DRAW\n";
4858    print "S -100 -$h 100 $h 0 1 0 N\n";
49    for ($px = 1; $px <= $x; $px++) {
59    for (my $px = 1; $px <= $x; $px++) {
5060        print "X $px $px -400 " .
5161            ($h - $px * 100 + 50) . " 300 R 50 50 1 1 P\n";
5262        next if $px == $x;
...... 
5767    print "ENDDRAW\n";
5868    print "ENDDEF\n";
5969}
70
71
72print "EESchema-LIBRARY Version 2.3 Date: `date`\n";
73print "#encoding utf-8\n";
74for ($x = 1; $x <= 40; $x++) {
75    &even($x);
76    &odd($x) if $x > 1;
77}
6078print "#\n#End Library\n";

Archive Download the corresponding diff file

Branches:
master



interactive