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 clearance_mm = 0.6;
22 public real clearance_mil = 25;
24 public int mm2mils100(real mm) = floor (mm / 25.4 * 1000 * 100 + 0.5);
26 public int mils2mils100(real mils) = floor (mils * 100 + 0.5);
28 public void element_start(string name) {
29 printf ("# author: Keith Packard\n");
30 printf ("# email: keithp@keithp.com\n");
31 printf ("# dist-license: GPL 2\n");
32 printf ("# use-license: unlimited\n");
33 printf ("Element [\"\" \"%s\" \"\" \"\" 0 0 0 0 0 100 \"\"]\n",
39 public void element_end() {
43 public void pad_mm(real center_x,
59 x1 = center_x - (width - height) / 2;
61 x2 = center_x + (width - height) / 2;
65 y1 = center_y - (height - width) / 2;
67 y2 = center_y + (height - width) / 2;
70 real mask = thickness + clearance_mm / 2;
73 printf (" %6d %6d %6d %6d",
78 printf (" %6d %6d %6d",
79 mm2mils100(thickness),
80 mm2mils100(clearance_mm),
82 printf (" \"%s\" \"%s\" \"square\"]\n",
86 public void pin_mm(real x, real y, real drill, real copper,
90 real thickness = drill + copper * 2;
91 real mask = thickness + clearance_mm / 2;
96 printf(" %6d %6d %6d %6d",
97 mm2mils100(thickness),
98 mm2mils100(clearance_mm),
101 printf (" \"%s\" \"%s\"",
107 public void pin_mil(real x, real y, real drill, real copper,
111 real thickness = drill + copper * 2;
112 real mask = thickness + clearance_mil / 2;
117 printf(" %6d %6d %6d %6d",
118 mils2mils100(thickness),
119 mils2mils100(clearance_mil),
121 mils2mils100(drill));
122 printf (" \"%s\" \"%s\"",
128 public void line_mm (real x1, real y1, real x2, real y2)
130 printf (" ElementLine[");
131 printf (" %6d %6d %6d %6d",
139 public void line_mil (real x1, real y1, real x2, real y2)
141 printf (" ElementLine[");
142 printf (" %6d %6d %6d %6d",
150 public void rect_mm (real x, real y, real w, real h)
153 line_mm(x+w,y,x+w,y+h);
154 line_mm(x+w,y+h,x,y+h);
158 public void rect_mil (real x, real y, real w, real h)
161 line_mil(x+w,y,x+w,y+h);
162 line_mil(x+w,y+h,x,y+h);