Fix pwson-n6 package pin clearance
[hw/altusmetrum] / packages / servo.5c
1 /*
2  * Copyright © 2016 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 dpi = 4800;
22
23 real pixtomm(real pix) = pix / dpi * 25.4;
24
25 typedef struct {
26         real    x;
27         real    y;
28 } pos_t;
29
30 real    origin_x = 423;
31 real    origin_y = 213;
32
33 real xmm(real xpix) = pixtomm(xpix - origin_x);
34 real ymm(real ypix) = pixtomm(ypix - origin_y);
35
36 pos_t pos(real xpix, real ypix) = (pos_t) { .x = xmm(xpix), .y = ymm(ypix) };
37
38 pos_t ul = pos(543, 213);
39 pos_t ur = pos(2912, 213);
40 pos_t mll = pos(423, 1036);
41 pos_t mlr = pos(543, 1036);
42 pos_t mrl = pos(2912, 1036);
43 pos_t mrr = pos(3980, 1036);
44 pos_t ll = pos(423, 1955);
45 pos_t lr = pos(3980, 1955);
46
47 pos_t mount_ul = pos(781, 208);
48 pos_t mount_ur = pos(2102, 208);
49
50 pos_t mount_ll = pos(652, 1999);
51 pos_t mount_lr = pos(3561, 1999);
52
53 real mounting_hole = pixtomm(142);
54
55 void linepos(pos_t a, pos_t b) { line(a.x, a.y, b.x, b.y); }
56
57 void outline() {
58         linepos(ul, ur);
59         linepos(ur, mrl);
60         linepos(mrl, mrr);
61         linepos(mrr, lr);
62         linepos(lr, ll);
63         linepos(ll, mll);
64         linepos(mll, mlr);
65         linepos(mlr, ul);
66 }
67
68 void drill(pos_t a) {
69         pin_mm_clear(a.x, a.y, mounting_hole, 0.22, 0.32, "mount", "mount");
70 }
71
72 void mount() {
73         drill(mount_ul);
74         drill(mount_ur);
75         drill(mount_ll);
76         drill(mount_lr);
77 }
78
79 real ysplit = ymm(1500);
80 real ygap = pixtomm(1536 - 1442);
81
82 void contact(pos_t ul, pos_t lr, string name, string num) {
83         pad_mm((ul.x + lr.x) / 2,
84                (ul.y + lr.y) / 2,
85                (lr.x - ul.x),
86                (lr.y - ul.y),
87                name, num);
88 }
89
90 void top_contact(real x, real width, string name, string num) {
91         contact((pos_t) { .x = x, .y = mll.y },
92                 (pos_t) { .x = x + width, .y = ysplit - ygap / 2 },
93                 name, num);
94 }
95
96 real contact_left = xmm(563 + 2909 - 2667);
97 real contact_right = xmm(2922);
98 real contact_width = pixtomm(3267 - 2901);
99
100 void bottom_contact(real x, real width, string name, string num) {
101         contact((pos_t) { .x = x, .y = ysplit + ygap / 2 },
102                 (pos_t) { .x = x + width, .y = ll.y },
103                 name, num);
104 }
105
106 element_start("servo");
107
108 outline();
109 mount();
110
111 bottom_contact(contact_left, contact_width, "1", "1");
112 bottom_contact(contact_right, contact_width, "2", "2");
113
114 top_contact(contact_left, contact_width, "3", "3");
115 top_contact(contact_right, contact_width, "4", "4");
116
117 element_end();