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,
168 public void pad_mm_arbitrary( real x1,
177 real clearance = process_clearance;
179 real mask = thickness + clearance / 2;
182 printf (" %6d %6d %6d %6d",
187 printf (" %6d %6d %6d",
188 mm2mils100(thickness),
189 mm2mils100(clearance),
191 printf (" \"%s\" \"%s\" \"%s\"]\n",
195 public void pin_mm_clear(real x, real y, real drill, real copper, real clearance,
199 real thickness = drill + copper * 2;
200 real mask = thickness + clearance / 2;
205 printf(" %6d %6d %6d %6d",
206 mm2mils100(thickness),
207 mm2mils100(clearance),
210 printf (" \"%s\" \"%s\"",
216 public void pin_mm_clear_options(real x, real y, real drill, real copper, real clearance,
221 real thickness = drill + copper * 2;
222 real mask = thickness + clearance / 2;
227 printf(" %6d %6d %6d %6d",
228 mm2mils100(thickness),
229 mm2mils100(clearance),
232 printf (" \"%s\" \"%s\"",
234 printf (" \"%s\"]\n", options);
238 public void pin_mm_clear_mask_options(real x, real y,
239 real drill, real copper, real clearance, real mask,
240 string name, string number, string options)
242 real thickness = drill + copper * 2;
247 printf(" %6d %6d %6d %6d",
248 mm2mils100(thickness),
249 mm2mils100(clearance),
252 printf (" \"%s\" \"%s\"",
254 printf (" \"%s\"]\n", options);
257 public void pin_mm_clear_mask(real x, real y,
258 real drill, real copper, real clearance, real mask,
259 string name, string number)
261 real thickness = copper;
266 printf(" %6d %6d %6d %6d",
267 mm2mils100(thickness),
268 mm2mils100(clearance),
271 printf (" \"%s\" \"%s\"",
277 public void pin_mm(real x, real y, real drill, real copper,
281 pin_mm_clear(x, y, drill, copper, process_clearance,
285 public void pin_mm_options(real x, real y, real drill, real copper,
290 pin_mm_clear_options(x, y, drill, copper, process_clearance,
291 name, number, options);
294 public void line (real x1, real y1, real x2, real y2)
296 printf (" ElementLine[");
297 printf (" %6d %6d %6d %6d",
302 printf (" %d]\n", line_thickness);
305 public void rect (real x, real y, real w, real h)
313 public void arc (real center_x, real center_y,
314 real radius_x, real radius_y,
315 real start_angle, real delta_angle)
317 printf (" ElementArc[ %6d %6d %6d %6d %3d %3d %d]\n",
318 mm2mils100(center_x), mm2mils100(center_y),
319 mm2mils100(radius_x), mm2mils100(radius_y),
320 start_angle, delta_angle, line_thickness);