update to python3
[hw/altusmetrum] / packages / molex / picoblade-th-v.py
1 #!/usr/bin/python3
2 # Copyright 2008 by Bdale Garbee <bdale@gag.com>.  GPLv2
3 #
4 # Program to emit PCB footprint for
5 #   Molex 1.25mm PicoBlade, vertical through-hole header 53047-XX10, 2-15 pins 
6 #
7 # Needs pin count on command line, in range of 2..15
8 #
9
10 # dimensions in mm from 530470410_sd.pdf datasheet
11 PinDiam = 0.52
12 PinSpacing = 1.25
13 BoxOffset = 1.15
14 BoxHeight = 3.2
15 BoxEnd = 1.5
16 LineWidth = 600
17
18 import sys
19
20 # we're going to use the 1/100 of a mil fundamental unit form
21 def mm2mils100( mm ):
22         return int( mm / 25.4 * 1000.0 * 100.0 + 0.5 )
23
24 pins = int(sys.argv[1])
25 if pins < 2:
26         sys.stderr.write('Must be at least 2 pins\n')
27         sys.exit(1)
28 if pins > 15:
29         sys.stderr.write('Must be no more than 15 pins\n')
30         sys.exit(1)
31
32 print('# author: Bdale Garbee')
33 print('# email: bdale@gag.com')
34 print('# dist-license: GPL 2')
35 print('# use-license: unlimited')
36
37 print('Element[0x0 "PicoBlade%i"' % pins,'"" "" 0 0 0 0 0 100 0x0]')
38 print("(")
39 for pin in range (1,pins+1):
40     pinnum = pins + 1 - pin
41     if pinnum == 1:
42         Flags = '0x0101'
43     else:
44         Flags = '0x0001'
45     print('   Pin[', \
46         mm2mils100((pins-1)*PinSpacing - (pin-1)*PinSpacing), \
47         0, \
48         3500, \
49         1200, \
50         4100, \
51         mm2mils100(PinDiam), \
52         '"pin%i"' % pinnum, '"%i"' % pinnum, Flags, ']')
53
54 BoxWidth = (BoxEnd * 2) + ((pins - 1) * PinSpacing);
55
56 print('   ElementLine[', \
57         mm2mils100(-BoxEnd), \
58         mm2mils100(-BoxOffset), \
59         mm2mils100(-BoxEnd), \
60         mm2mils100(BoxHeight-BoxOffset), \
61         LineWidth, ']')
62
63 print('   ElementLine[', \
64         mm2mils100(-BoxEnd), \
65         mm2mils100(BoxHeight-BoxOffset), \
66         mm2mils100(BoxWidth-BoxEnd), \
67         mm2mils100(BoxHeight-BoxOffset), \
68         LineWidth, ']')
69
70 print('   ElementLine[', \
71         mm2mils100(BoxWidth-BoxEnd), \
72         mm2mils100(BoxHeight-BoxOffset), \
73         mm2mils100(BoxWidth-BoxEnd), \
74         mm2mils100(-BoxOffset), \
75         LineWidth, ']')
76
77 print('   ElementLine[', \
78         mm2mils100(BoxWidth-BoxEnd), \
79         mm2mils100(-BoxOffset), \
80         mm2mils100(-BoxEnd), \
81         mm2mils100(-BoxOffset), \
82         LineWidth, ']')
83   
84 print(")")