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\" \"square%s%s\"]\n",
86 name, num, options == "" ? "" : ",", options);
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\" \"square%s%s\"]\n",
131 name, num, options == "" ? "" : ",", options);
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 pin_mm_clear(real x, real y, real drill, real copper, real clearance,
172 real thickness = drill + copper * 2;
173 real mask = thickness + clearance / 2;
178 printf(" %6d %6d %6d %6d",
179 mm2mils100(thickness),
180 mm2mils100(clearance),
183 printf (" \"%s\" \"%s\"",
189 public void pin_mm_clear_mask(real x, real y,
190 real drill, real copper, real clearance, real mask,
191 string name, string number)
193 real thickness = drill + copper * 2;
198 printf(" %6d %6d %6d %6d",
199 mm2mils100(thickness),
200 mm2mils100(clearance),
203 printf (" \"%s\" \"%s\"",
209 public void pin_mm(real x, real y, real drill, real copper,
213 pin_mm_clear(x, y, drill, copper, process_clearance,
217 public void line (real x1, real y1, real x2, real y2)
219 printf (" ElementLine[");
220 printf (" %6d %6d %6d %6d",
225 printf (" %d]\n", line_thickness);
228 public void rect (real x, real y, real w, real h)