2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
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.
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.
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.
20 /* process clearance requirement */
21 public real process_clearance = 0.6;
23 public int mm2mils100(real mm) = floor (mm / 25.4 * 1000 * 100 + 0.5);
25 public real mils1002mm(real mils100) = mils100 * 25.4 / 100 / 1000;
27 public int line_thickness = 1000;
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",
40 public void element_end() {
44 public void pad_mm_clear_mask_options(real center_x,
63 x1 = center_x - (width - height) / 2;
65 x2 = center_x + (width - height) / 2;
69 y1 = center_y - (height - width) / 2;
71 y2 = center_y + (height - width) / 2;
76 printf (" %6d %6d %6d %6d",
81 printf (" %6d %6d %6d",
82 mm2mils100(thickness),
83 mm2mils100(clearance),
85 printf (" \"%s\" \"%s\" \"%s\"]\n",
89 public void pad_mm_clear_options(real center_x,
104 if (width > height) {
107 x1 = center_x - (width - height) / 2;
109 x2 = center_x + (width - height) / 2;
113 y1 = center_y - (height - width) / 2;
115 y2 = center_y + (height - width) / 2;
118 real mask = thickness + clearance / 2;
121 printf (" %6d %6d %6d %6d",
126 printf (" %6d %6d %6d",
127 mm2mils100(thickness),
128 mm2mils100(clearance),
130 printf (" \"%s\" \"%s\" \"%s\"]\n",
134 public void pad_mm_clear(real center_x,
142 pad_mm_clear_options(center_x,
152 public void pad_mm(real center_x,
159 pad_mm_clear(center_x,
167 public void pad_mm_options(real center_x,
175 pad_mm_clear_options(center_x,
185 public void pad_mm_arbitrary( real x1,
194 real clearance = process_clearance;
196 real mask = thickness + clearance / 2;
199 printf (" %6d %6d %6d %6d",
204 printf (" %6d %6d %6d",
205 mm2mils100(thickness),
206 mm2mils100(clearance),
208 printf (" \"%s\" \"%s\" \"%s\"]\n",
212 public void pin_mm_clear(real x, real y, real drill, real copper, real clearance,
216 real thickness = drill + copper * 2;
217 real mask = thickness + clearance / 2;
222 printf(" %6d %6d %6d %6d",
223 mm2mils100(thickness),
224 mm2mils100(clearance),
227 printf (" \"%s\" \"%s\"",
233 public void pin_mm_clear_options(real x, real y, real drill, real copper, real clearance,
238 real thickness = drill + copper * 2;
239 real mask = thickness + clearance / 2;
244 printf(" %6d %6d %6d %6d",
245 mm2mils100(thickness),
246 mm2mils100(clearance),
249 printf (" \"%s\" \"%s\"",
251 printf (" \"%s\"]\n", options);
255 public void pin_mm_clear_mask_options(real x, real y,
256 real drill, real copper, real clearance, real mask,
257 string name, string number, string options)
259 real thickness = drill + copper * 2;
264 printf(" %6d %6d %6d %6d",
265 mm2mils100(thickness),
266 mm2mils100(clearance),
269 printf (" \"%s\" \"%s\"",
271 printf (" \"%s\"]\n", options);
274 public void pin_mm_clear_mask(real x, real y,
275 real drill, real copper, real clearance, real mask,
276 string name, string number)
278 real thickness = copper;
283 printf(" %6d %6d %6d %6d",
284 mm2mils100(thickness),
285 mm2mils100(clearance),
288 printf (" \"%s\" \"%s\"",
294 public void pin_mm(real x, real y, real drill, real copper,
298 pin_mm_clear(x, y, drill, copper, process_clearance,
302 public void pin_mm_options(real x, real y, real drill, real copper,
307 pin_mm_clear_options(x, y, drill, copper, process_clearance,
308 name, number, options);
311 public void line (real x1, real y1, real x2, real y2)
313 printf (" ElementLine[");
314 printf (" %6d %6d %6d %6d",
319 printf (" %d]\n", line_thickness);
322 public void rect (real x, real y, real w, real h)
330 public void arc (real center_x, real center_y,
331 real radius_x, real radius_y,
332 real start_angle, real delta_angle)
334 printf (" ElementArc[ %6d %6d %6d %6d %3d %3d %d]\n",
335 mm2mils100(center_x), mm2mils100(center_y),
336 mm2mils100(radius_x), mm2mils100(radius_y),
337 start_angle, delta_angle, line_thickness);