update to python3
[hw/altusmetrum] / packages / ufqfpn20.5c
1 /*
2  * Copyright © 2020 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 Footprint::process_soldermask = 0.05;
22
23 real pad_outside = 0.15;
24 real pad_width = 0.70;
25 real corner_pad_width = 0.50;
26 real corner_pad_height = 0.30;
27 real pad_height = 0.30;
28
29 /* Required clearance between corner pads on the diagonal */
30 real corner_diag_clearance = 0.40;
31
32 /* horizontal/vertical size of corner cut out */
33 #real corner_pad_notch = corner_diag_clearance / sqrt(2);
34 real corner_pad_notch = 0.125;
35
36 real corner_pad_minimum_height = pad_height - corner_pad_notch;
37 real corner_pad_minimum_width = corner_pad_width - corner_pad_notch;
38
39 real pad_spacing = 0.50;
40
41 real package_width = 3;
42 real package_height = 3;
43
44 /* outer location of pad */
45
46 real pad_x_off = (package_width/2 + pad_outside);
47 real pad_y_off = (package_height/2 + pad_outside);
48
49 real num_pad = 5;       /* per side */
50
51 element_start("ufqfpn-20");
52
53 real pad_off(int n) {
54         return pad_spacing * (n - (num_pad - 1) / 2);
55 }
56
57 real corner(int dx, int dy) {
58         real    x = dx * package_width / 2;
59         real    y = dy * package_height / 2;
60         real    len = 0.4;
61
62         line(x, y, x - dx * len, y);
63         line(x, y, x, y - dy * len);
64 }
65
66 /*
67 corner(-1, -1);
68 corner(1, -1);
69 corner(-1, 1);
70 corner(1, 1);
71 */
72
73 real dot_off = .3;
74
75 line(-package_width/2 - dot_off, -package_height/2 - dot_off,
76      -package_width/2 - dot_off, -package_height/2 - dot_off);
77
78 /* rect(-package_width/2, -package_width/2, package_width, package_width); */
79
80 for (int pad = 0; pad < num_pad; pad++) {
81         real pw = pad_width;
82         real ph = pad_height;
83         real pwa = 0;
84         real pha = 0;
85
86         int     nstep = 0;
87
88         if (pad == 0 || pad == num_pad-1)
89                 nstep = 3;
90
91         for (int s = 0; s <= nstep; s++) {
92
93                 real    pad_x, pad_y, pad_w, pad_h;
94
95                 if (nstep != 0) {
96                         real    ratio_a = s / nstep;
97                         real    ratio_b = 1 - ratio_a;
98
99                         pad_x = 0;
100                         if (pad == 0) {
101                                 pad_y = -pad_height / 2 * ratio_b + ((-pad_height / 2) + corner_pad_notch) * ratio_a;
102                         } else {
103                                 pad_y = -pad_height / 2;
104                         }
105                         pad_w = corner_pad_minimum_width * ratio_b + corner_pad_width * ratio_a;
106
107                         pad_h = pad_height * ratio_b + corner_pad_minimum_height * ratio_a;
108
109                         /* Make sure we don't violate the process minimums */
110                         if (pad_h < process_trace)
111                                 pad_h = process_trace;
112
113                 } else {
114                         pad_x = 0;
115                         pad_y = -pad_height / 2;
116                         pad_w = pad_width;
117                         pad_h = pad_height;
118                 }
119
120                 /* left (1-6) */
121                 pad_mm(-pad_x_off + pad_x + pad_w / 2,
122                        pad_off(pad) + pad_y + pad_h / 2,
123                        pad_w,
124                        pad_h,
125                        sprintf("%d", pad + 1),
126                        sprintf("%d", pad + 1));
127
128                 /* bottom (7-12) */
129
130                 pad_mm(pad_off(pad) + pad_y + pad_h / 2,
131                        pad_y_off + pad_x - pad_w / 2,
132                        pad_h,
133                        pad_w,
134                        sprintf("%d", pad + num_pad + 1),
135                        sprintf("%d", pad + num_pad + 1));
136
137                 /* right side (13-18) */
138
139                 pad_mm(pad_x_off - pad_x - pad_w / 2,
140                        -pad_off(pad) - pad_y - pad_h / 2,
141                        pad_w,
142                        pad_h,
143                        sprintf("%d", pad + num_pad * 2 + 1),
144                        sprintf("%d", pad + num_pad * 2 + 1));
145
146                 /* top (19-24) */
147
148                 pad_mm(-pad_off(pad) - pad_y - pad_h / 2,
149                        -pad_y_off - pad_x + pad_w / 2,
150                        pad_h,
151                        pad_w,
152                        sprintf("%d", pad + num_pad * 3 + 1),
153                        sprintf("%d", pad + num_pad * 3 + 1));
154         }
155
156 }
157
158 element_end();