Add parts for snekboard
[hw/altusmetrum] / packages / pinheader / 100mil.5c
1 /*
2  * Copyright © 2013 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 load "../footprint.5c";
19 import Footprint;
20
21 real pin_spacing = 0.1 * 25.4;
22 real pin_hole = 0.038 * 25.4;
23 real pin_copper = 0.4;
24
25 element_args();
26
27 int rows = atoi(argv[1]);
28 int cols = 1;
29 if (dim(argv) > 2)
30         cols = atoi(argv[2]);
31
32 if (rows < 2) {
33         File::fprintf (stderr, "must have at least two rows\n");
34         exit(1);
35 }
36
37 int pins = rows * cols;
38
39 element_start(sprintf ("100mil%dx%d", rows, cols));
40
41 real col_off = (cols-1) * pin_spacing / 2.0;
42 real row_off = (rows-1) * pin_spacing / 2.0;
43
44 rect(-rows * pin_spacing / 2.0, -cols * pin_spacing / 2.0, rows * pin_spacing, cols * pin_spacing);
45
46 for (int row = 0; row < rows; row++)
47         for (int col = 0; col < cols; col++) {
48                 int pin = row * cols + col;
49                 pin_mm_options(row * pin_spacing - row_off, col_off - col * pin_spacing, pin_hole, pin_copper,
50                        sprintf ("%d", pin + 1),
51                        sprintf ("%d", pin + 1),
52                        pin == 0 ? "square" : "");
53         }
54
55
56
57 element_end();
58
59
60