working on footprint for LCD selected for TirePyro
[hw/altusmetrum] / packages / NHD-C0216CZ.py
1 #!/usr/bin/python2
2 # Copyright 2021 by Bdale Garbee <bdale@gag.com>.  GPLv3
3 #
4 # Program to emit PCB footprint for NHD-C0216CZ-FSW-FBW-3V3 2x16 text LCD
5 #
6
7 # dimensions in mm from NHD-C0216CZ-FSW-FBW-3V3.pdf datasheet
8 BodyWidth = 41.4
9 BodyHeight = 24.3
10 BodyHeightOffset = -0.75        # pin row to body edge distance
11 PinDiam = 0.7
12 PinSpacing = 1.50
13 Pins = 10
14 ViewWidth = 34.22
15 ViewHeight = 8.76
16 ViewHCtr = 15.8 / 2 + 7.6 - BodyHeight / 2
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 print '# author: Bdale Garbee'
25 print '# email: bdale@gag.com'
26 print '# dist-license: GPL 3'
27 print '# use-license: unlimited'
28
29 print 'Element[0x0 "NHD-C0216CZ" "" "" 0 0 0 0 0 100 0x0]'
30 print "("
31
32 # pins
33         # pin( x y thickness clearance mask drillhole name number flags)
34 for pin in range (1,Pins+1):
35     if pin == 1:
36         Flags = '0x0101'
37     else:
38         Flags = '0x0001'
39
40     print '   Pin[',\
41         mm2mils100((pin - 5.5)*PinSpacing), \
42         mm2mils100(-BodyHeight/2), \
43         mm2mils100(PinDiam * 1.75), \
44         1200, \
45         mm2mils100(PinDiam * 1.75) + 600, \
46         mm2mils100(PinDiam), \
47         '"pin%i"' % (pin), '"%i"' % (pin), Flags, ']'
48
49 print '   ElementLine[',\
50         -mm2mils100(BodyWidth/2), \
51         -mm2mils100(BodyHeight/2-BodyHeightOffset), \
52         mm2mils100(BodyWidth/2), \
53         -mm2mils100(BodyHeight/2-BodyHeightOffset), \
54         500, \
55         ']'
56 print '   ElementLine[',\
57         -mm2mils100(BodyWidth/2), \
58         -mm2mils100(BodyHeight/2-BodyHeightOffset), \
59         -mm2mils100(BodyWidth/2), \
60         mm2mils100(BodyHeight/2-BodyHeightOffset), \
61         500, \
62         ']'
63 print '   ElementLine[',\
64         -mm2mils100(BodyWidth/2), \
65         mm2mils100(BodyHeight/2-BodyHeightOffset), \
66         mm2mils100(BodyWidth/2), \
67         mm2mils100(BodyHeight/2-BodyHeightOffset), \
68         500, \
69         ']'
70 print '   ElementLine[',\
71         mm2mils100(BodyWidth/2), \
72         mm2mils100(BodyHeight/2-BodyHeightOffset), \
73         mm2mils100(BodyWidth/2), \
74         -mm2mils100(BodyHeight/2-BodyHeightOffset), \
75         500, \
76         ']'
77
78 # mark viewable area
79
80 print '   ElementLine[',\
81         mm2mils100(-ViewWidth/2), \
82         mm2mils100(ViewHCtr + ViewHeight/2-BodyHeightOffset), \
83         mm2mils100(ViewWidth/2), \
84         mm2mils100(ViewHCtr + ViewHeight/2-BodyHeightOffset), \
85         500, \
86         ']'
87
88 print '   ElementLine[',\
89         mm2mils100(-ViewWidth/2), \
90         mm2mils100(ViewHCtr - ViewHeight/2-BodyHeightOffset), \
91         mm2mils100(ViewWidth/2), \
92         mm2mils100(ViewHCtr - ViewHeight/2-BodyHeightOffset), \
93         500, \
94         ']'
95
96 print '   ElementLine[',\
97         mm2mils100(-ViewWidth/2), \
98         mm2mils100(ViewHCtr - ViewHeight/2-BodyHeightOffset), \
99         mm2mils100(-ViewWidth/2), \
100         mm2mils100(ViewHCtr + ViewHeight/2-BodyHeightOffset), \
101         500, \
102         ']'
103
104 print '   ElementLine[',\
105         mm2mils100(ViewWidth/2), \
106         mm2mils100(ViewHCtr - ViewHeight/2-BodyHeightOffset), \
107         mm2mils100(ViewWidth/2), \
108         mm2mils100(ViewHCtr + ViewHeight/2-BodyHeightOffset), \
109         500, \
110         ']'
111
112 print '   ElementLine[',\
113         mm2mils100(ViewWidth/2), \
114         mm2mils100(ViewHCtr - ViewHeight/2-BodyHeightOffset), \
115         mm2mils100(-ViewWidth/2), \
116         mm2mils100(ViewHCtr + ViewHeight/2-BodyHeightOffset), \
117         500, \
118         ']'
119
120 print '   ElementLine[',\
121         mm2mils100(-ViewWidth/2), \
122         mm2mils100(ViewHCtr - ViewHeight/2-BodyHeightOffset), \
123         mm2mils100(ViewWidth/2), \
124         mm2mils100(ViewHCtr + ViewHeight/2-BodyHeightOffset), \
125         500, \
126         ']'
127
128 print ")"