Add RF components. Hook up microSD card.
[hw/telegps] / packages / footprint.5c
1 /*
2  * Copyright © 2012 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 namespace Footprint {
19
20         /* process clearance requirement */
21         public real process_clearance = 0.6;
22
23         public int mm2mils100(real mm) = floor (mm / 25.4 * 1000 * 100 + 0.5);
24
25         public real mils1002mm(real mils100) = mils100 * 25.4 / 100 / 1000;
26
27         public int line_thickness = 1000;
28
29         public void element_start(string name) {
30                 printf ("# author: Keith Packard\n");
31                 printf ("# email: keithp@keithp.com\n");
32                 printf ("# dist-license: GPL 2\n");
33                 printf ("# use-license: unlimited\n");
34                 printf ("Element [\"\" \"%s\" \"\" \"\" 0 0 0 0 0 100 \"\"]\n",
35                         name);
36                 printf ("(\n");
37                 
38         }
39
40         public void element_end() {
41                 printf (")\n");
42         }
43         
44         public void pad_mm_clear(real center_x,
45                                  real center_y,
46                                  real width,
47                                  real height,
48                                  real clearance,
49                                  string name,
50                                  string num)
51         {
52                 real    x1 = 0;
53                 real    y1 = 0;
54                 real    x2 = 0;
55                 real    y2 = 0;
56                 real    thickness = 0;
57
58                 if (width > height) {
59                         thickness = height;
60                         y1 = center_y;
61                         x1 = center_x - (width - height) / 2;
62                         y2 = center_y;
63                         x2 = center_x + (width - height) / 2;
64                 } else {
65                         thickness = width;
66                         x1 = center_x;
67                         y1 = center_y - (height - width) / 2;
68                         x2 = center_x;
69                         y2 = center_y + (height - width) / 2;
70                 }
71
72                 real mask = thickness + clearance / 2;
73
74                 printf ("    Pad[");
75                 printf (" %6d %6d %6d %6d",
76                         mm2mils100(x1),
77                         mm2mils100(y1),
78                         mm2mils100(x2),
79                         mm2mils100(y2));
80                 printf (" %6d %6d %6d",
81                         mm2mils100(thickness),
82                         mm2mils100(clearance),
83                         mm2mils100(mask));
84                 printf (" \"%s\" \"%s\" \"square\"]\n",
85                         name, num);
86         }
87
88         public void pad_mm(real center_x,
89                            real center_y,
90                            real width,
91                            real height,
92                            string name,
93                            string num)
94         {
95                 pad_mm_clear(center_x,
96                              center_y,
97                              width,
98                              height,
99                              process_clearance,
100                              name,
101                              num);
102         }
103
104         public void pin_mm_clear(real x, real y, real drill, real copper, real clearance,
105                         string name,
106                         string number)
107         {
108                 real thickness = drill + copper * 2;
109                 real mask = thickness + clearance / 2;
110                 printf("    Pin[");
111                 printf(" %6d %6d",
112                        mm2mils100(x),
113                        mm2mils100(y));
114                 printf(" %6d %6d %6d %6d",
115                        mm2mils100(thickness),
116                        mm2mils100(clearance),
117                        mm2mils100(mask),
118                        mm2mils100(drill));
119                 printf (" \"%s\" \"%s\"",
120                         name, number);
121                 printf (" \"\"]\n");
122                        
123         }
124
125         public void pin_mm(real x, real y, real drill, real copper,
126                         string name,
127                         string number)
128         {
129                 pin_mm_clear(x, y, drill, copper, process_clearance,
130                              name, number);
131         }
132
133         public void line (real x1, real y1, real x2, real y2)
134         {
135                 printf ("    ElementLine[");
136                 printf (" %6d %6d %6d %6d",
137                         mm2mils100(x1),
138                         mm2mils100(y1),
139                         mm2mils100(x2),
140                         mm2mils100(y2));
141                 printf (" %d]\n", line_thickness);
142         }
143
144         public void rect (real x, real y, real w, real h)
145         {
146                 line(x,y,x+w,y);
147                 line(x+w,y,x+w,y+h);
148                 line(x+w,y+h,x,y+h);
149                 line(x,y+h,x,y);
150         }
151 }