Fix node_label() function to work with self-intersection
[geda-pcb/gde.git] / lib / misc.inc
blob45def935da63125e81a3eeedcf86417669dea794
1 .#
2 #                             COPYRIGHT
3
4 #   PCB, interactive printed circuit board design
5 #   Copyright (C) 1994,1995,1996 Thomas Nau
6
7 #   This program is free software; you can redistribute it and/or modify
8 #   it under the terms of the GNU General Public License as published by
9 #   the Free Software Foundation; either version 2 of the License, or
10 #   (at your option) any later version.
11
12 #   This program is distributed in the hope that it will be useful,
13 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #   GNU General Public License for more details.
16
17 #   You should have received a copy of the GNU General Public License
18 #   along with this program; if not, write to the Free Software
19 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 #   Contact addresses for paper mail and Email:
22 #   Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 #   Thomas.Nau@rz.uni-ulm.de
24
25 #   RCS: $Id$
27 # misc packages
30 # -------------------------------------------------------------------
31 # the definition of a SD (ZIP) package
32 # based on 'old style format' by Olaf Kaluza (olaf@criseis.ruhr.de)
34 # For example, see http://focus.ti.com/lit/ml/mczi002/mczi002.pdf
35 # for the Texas Instruments SDZ (R-PZIP-T16) Ceramic Zig Zag package
36 # That drawing shows the pin width varying from 0.45mm to 0.65mm 
37 # (18 to 26 mils) and the width in the other dimension from .23mm
38 # to .35mm.  The cross section is rectangular.  This gives a diagonal
39 # from 0.505mm (19.9 mil) to 0.738mm (29 mil).
41 # $1: canonical name
42 # $2: name on PCB
43 # $3: value
44 # $4: number of pins
46 define(`PKG_SD',
47         `define(`MAXY', `eval(`$4' / 2 * 100 + 50)')
48 Element(0x00 "$1" "`$2'" "$3" 275 50 3 100 0x00)
50         forloop(`i', 1, eval($4 / 2),
51                 `PIN(50,  eval(100*(i-1)+50), 60, 35, eval(2*i-1))
52                 PIN(150, eval(100*(i-1)+100), 60, 35, eval(2*i))
53         ')
55         ElementLine(0 0 0 MAXY 20)
56         ElementLine(0 MAXY 200 MAXY 20)
57         ElementLine(200 MAXY 200 0 20)
58         ElementLine(200 0 0 0 20)
59         ElementLine(100 0 100 100 10)
60         ElementLine(100 100 0 100 10)
62         Mark(50 50)
63 )')
65 # -------------------------------------------------------------------
66 # the definition of a plastic power package vertical
67 # for TO220 (2-7pins), TO251, TOP3, MULTIWATT(8-15pins)
68 # based on 'old style format' by Olaf Kaluza (olaf@criseis.ruhr.de)
69 # $1: canonical name
70 # $2: name on PCB
71 # $3: value
72 # $4: pin count
73 # $5: pin spacing
74 # $6: body length (dimension parallel to rows of pins)
75 # $7: body width  (dimension perpendicular to rows of pins)
76 # $8: pin/tab spacing
77 # $9: pad size
78 # $10: drill size
79 # $11: pin row spacing
81 define(`GENERIC_PL_POWER',
82     `define(`pin1X', `eval((`$6' - (`$4' - 1) * `$5')/2)')
83 Element(0x00 "$1" "`$2'" "$3" eval(`$6'+60) 50 3 100 0x00)
85        forloop(`i', 1, `$4',
86                `PIN(eval(pin1X + (i-1)*`$5'), ifelse(eval(i % 2 == 0), 0, eval(`$8'+`$11'), `$8'), `$9', `$10', i)
87        ')
88        ElementLine(0 0 0 `$7' 20)
89        ElementLine(0 `$7' `$6' `$7' 20)
90        ElementLine(`$6' `$7' `$6' 0 20)
91        ElementLine(`$6' 0 0 0 20)
92        ElementLine(0 50 `$6' 50 10)
93        ElementLine(eval(`$6'/2 - 75) 0 eval(`$6'/2 - 75) 50 10)
94        ElementLine(eval(`$6'/2 + 75) 0 eval(`$6'/2 + 75) 50 10)
95        Mark(pin1X eval(`$7'+`$10'))
96  )')
98 # -------------------------------------------------------------------
99 # the definition of a resistor (0.25W) package
100 # $1: canonical name
101 # $2: name on PCB
102 # $3: value
103 define(`PKG_R025',
104 `Element(0x00 "$1" "`$2'" "$3" 120 30 0 100 0x00)
106         PIN(0, 50, 68, 38, 1)
107         PIN(400, 50, 68, 38, 2)
108         ElementLine(100 0 300 0 20)
109         ElementLine(300 0 300 100 20)
110         ElementLine(300 100 100 100 20)
111         ElementLine(100 100 100 0 20)
112         ElementLine(0 50 100 50 20)
113         ElementLine(300 50 400 50 20)
114         Mark(0 50)
117 # -------------------------------------------------------------------
118 # the definition of a SIL package without a common pin
119 # $1: canonical name
120 # $2: name on PCB
121 # $3: value
122 # $4: number of pins
123 define(`PKG_SIL',
124         `define(`MAXY', `eval(`$4' * 100 -50)')
125 Element(0x00 "$1" "`$2'" "$3" 160 10 3 100 0x00)
127         forloop(`i', 1, $4,
128                 `PIN(50, eval(i * 100 -50), 60, 28, i)
129         ')
130         ElementLine(  0 50   0 MAXY 20)
131         ElementLine(100 50 100 MAXY 20)
132         ElementArc(50  50 50 50 180 180 20)
133         ElementArc(50 MAXY 50 50   0 180 20)
134         forloop(`i', 1, eval($4 /2 -1),
135                 `ElementLine(0 eval(i * 200) 100 eval(i * 200) 10)
136         ')
137         Mark(50 50)
140 # -------------------------------------------------------------------
141 # the definition of a SIL package with a common pin
142 # $1: canonical name
143 # $2: name on PCB
144 # $3: value
145 # $4: number of pins
146 define(`PKG_CSIL',
147         `define(`MAXY', `eval(`$4' * 100 -50)')
148 Element(0x00 "$1" "`$2'" "$3" 160 10 3 100 0x00)
150         forloop(`i', 1, $4,
151                 `PIN(50, eval(i * 100 -50), 60, 28, i)
152         ')
153         ElementLine(  0 50   0 MAXY 20)
154         ElementLine(100 50 100 MAXY 20)
155         ElementLine(  0 100 100 100 10)
156         ElementArc(50  50 50 50 180 180 20)
157         ElementArc(50 MAXY 50 50   0 180 20)
158         Mark(50 50)
161 # -------------------------------------------------------------------
162 # a QFP-132 pin flat pack
164 # $1: canonical name
165 # $2: name on PCB
166 # $3: value
168 # based on mail by Volker Bosch (bosch@iema.e-technik.uni-stuttgart.de)
169 define(`PKG_QFP132',
170 `Element(0x00 "$1" "`$2'" "$3" 250 200 0 150 0x00)
172         forloop(`i', 1, 17,
173                 `define(`XPOS', eval(625 -i*25))'
174                 `PAD(XPOS, 40, XPOS, 90, 15, i)
175         ')
176         forloop(`i', 1, 16,
177                 `define(`XPOS', eval(1025 -i*25))'
178                 `PAD(XPOS, 40, XPOS, 90, 15, eval(i+116))
179         ')
180         forloop(`i', 1, 33,
181                 `define(`YPOS', eval(175 +i*25))'
182                 `PAD(30, YPOS, 80, YPOS, 15, i)
183         ')
184         forloop(`i', 1, 33,
185                 `define(`XPOS', eval(175 +i*25))'
186                 `PAD(XPOS, 1160, XPOS, 1110, 15, eval(i+50))
187         ')
188         forloop(`i', 1, 33,
189                 `define(`YPOS', eval(1025 -i*25))'
190                 `PAD(1120, YPOS, 1170, YPOS, 15, i)
191         ')
193         # Markierung pin 1
194         ElementArc(600 150 10 10 0 360 5)
196         # Nase links oben (PIN 17/18)
197         ElementLine( 125 175  75 150 20)
198         ElementLine(  75 150  75 125 20)
199         ElementLine(  75 125 125  75 20)
200         ElementLine( 125  75 150  75 20)
201         ElementLine( 150  75 175 125 20)
203         # Verbindungsline zur Ecke rechts oben
204         ElementLine( 175  125 1025 125 20)
206         # Nase rechts oben (PIN 116/117)
207         ElementLine(1025 125 1050  75 20)
208         ElementLine(1050  75 1075  75 20)
209         ElementLine(1075  75 1125 125 20) 
210         ElementLine(1125 125 1125 150 20)
211         ElementLine(1125 150 1075 175 20)
213         # Verbindungsline zur Ecke rechts unten
214         ElementLine(1075 175  1075 1025 20)
216         # Nase rechts unten (PIN 83/84)
217         ElementLine(1075 1025 1125 1050 20)
218         ElementLine(1125 1050 1125 1075 20)
219         ElementLine(1125 1075 1075 1125 20)
220         ElementLine(1075 1125 1050 1125 20)
221         ElementLine(1050 1125 1025 1075 20)
223         # Verbindungsline zur Ecke links unten 
224         ElementLine(1025 1075  175 1075 20)
226         # Nase links unten (PIN 50/51)
227         ElementLine( 175 1075 150 1125 20)
228         ElementLine( 150 1125 125 1125 20)
229         ElementLine( 125 1125  75 1075 20)
230         ElementLine(  75 1075  75 1050 20)
231         ElementLine(  75 1050 125 1025 20)
233         # Verbindungsline zur Ecke links oben
234         ElementLine( 125 1025 125 175 20)
236         # Markierung so anordnen, dass Pinanchse im 25-MIL-Raster zu liegen kommt
237         Mark(200 200)
240 # -------------------------------------------------------------------
241 # LED
242 # Pin 1 is -, 2 is +
244 # $1: canonical name
245 # $2: name on PCB
246 # $3: value
247 # $4: diameter
249 # based on mail by Volker Bosch (bosch@iema.e-technik.uni-stuttgart.de)
250 define(`PKG_LED',
251         `define(`RADIUS1', `eval(`$4' /2)')
252         define(`RADIUS2', `eval(`$4' /2 +20)')
253 Element(0x00 "$1" "`$2'" "$3" 100 70 0 100 0x00)
255 # typical LED is 0.5 mm or 0.020" square pin.  See for example
256 # http://www.lumex.com and part number SSL-LX3054LGD.
257 # 0.020" square is 0.0288" diagonal.  A number 57 drill is 
258 # 0.043" which should be enough.  a 65 mil pad gives 11 mils
259 # of annular ring.
261         PIN(-50, 0, 65, 43, 1)
262         PIN(50, 0, 65, 43, 2)
263    ifelse( eval(RADIUS1 - 10 > 85), 1, 
264         ElementArc(0 0 RADIUS1 RADIUS1     0 360 10)
266         ElementArc(0 0 RADIUS1 RADIUS1    45  90 10)
267         ElementArc(0 0 RADIUS1 RADIUS1   225  90 10)
269    ifelse( eval(RADIUS2 - 10 > 85), 1, 
270         ElementArc(0 0 RADIUS2 RADIUS2     0 360 10)
272         ElementArc(0 0 RADIUS2 RADIUS2    45  90 10)
273         ElementArc(0 0 RADIUS2 RADIUS2   225  90 10)
275         Mark(0 0)
278 # -------------------------------------------------------------------
279 # diodes
280 # Pin 1 is K, 2 is A
282 # $1: canonical name
283 # $2: name on PCB
284 # $3: value
285 # $4: distance in mil
287 define(`PKG_DIODE_LAY',
288         `define(`X1', `eval(`$4' /3)')
289         define(`X2', `eval(`$4' -X1)')
290         define(`Y', `eval(`$4' /2)')
291         define(`DELTA', `eval(X1 /2)')
292         define(`PINSIZE', `ifelse(eval($4 >= 500), 1, 80, 50)')
293 Element(0x00 "$1" "`$2'" "$3" eval(X2+20) eval(Y-DELTA) 0 100 0x00)
295         PIN(0, Y, PINSIZE, 20, 1)
296         PIN($4, Y, PINSIZE, 20, 2)
298         ElementLine(0 Y X1 Y 10)
299         ElementLine(X2 Y $4 Y 10)
301         ElementLine(X1 Y X2 eval(Y-DELTA) 10)
302         ElementLine(X2 eval(Y-DELTA) X2 eval(Y+DELTA) 10)
303         ElementLine(X2 eval(Y+DELTA) X1 Y 10)
304         ElementLine(X1 eval(Y-DELTA) X1 eval(Y+DELTA) 10)
305         Mark(0 Y)
308 # -------------------------------------------------------------------
309 # the definition of a general axial package
310 # $1: canonical name
311 # $2: name on PCB
312 # $3: value
313 # $4: distance in mil
314 # $5: 1 for polarized, 0 for non polarized
315 define(`PKG_AXIAL_LAY',
316         `define(`X1', `eval(`$4' /4)')
317         define(`X2', `eval(`$4' -X1)')
318         define(`Y1', `eval(X1 /3)')
319         define(`Y2', `eval(Y1 *2)')
320         define(`PINSIZE', `ifelse(eval($4 >= 600), 1, 80, 55)')
321         define(`DRILLSIZE', `ifelse(eval($4 >= 600), 1, 50, 30)')
322         define(`YPT', `eval(Y1 - PINSIZE/2 - 10)')
323         define(`YPC', `eval(YPT - 20)')
324         define(`YPB', `eval(YPT - 40)')
325 Element(0x00 "$1" "`$2'" "$3" eval(X2+20) eval(Y2+20) 0 100 0x00)
327         PIN(0, Y1, PINSIZE, DRILLSIZE, 1)
328         PIN($4, Y1, PINSIZE, DRILLSIZE, 2)
330         ElementLine(0 Y1 X1 Y1 10)
331         ElementLine(X2 Y1 $4 Y1 10)
333         ElementLine(X1 0 X2 0 10)
334         ElementLine(X2 0 X2 Y2 10)
335         ElementLine(X2 Y2 X1 Y2 10)
336         ElementLine(X1 Y2 X1 0 10)
338         ifelse(1, $5,
339         ElementLine(0 YPB 0 YPT 10)
340         ElementLine(-20 YPC 20 YPC 10)
341         ElementLine(`eval($4 - 20)' YPC `eval($4 + 20)' YPC 10)
342         )
344 #       ElementArc(X1 Y 50 50 270 180 10)
345 #       ElementArc(X2 Y 50 50 90 180 10)
347         Mark(0 Y1)
350 # -------------------------------------------------------------------
351 # an crystal package
352 # Pin 1 is K, 2 is A
354 # $1: canonical name
355 # $2: name on PCB
356 # $3: value
357 # $4: package width in MIL
359 define(`PKG_CRYSTAL',
360         `define(`X1', `100')
361         define(`X2', `$4')
362         define(`Y', `100')
363         define(`Y1', `eval(Y -50)')
364         define(`Y2', `eval(Y +50)')
365 Element(0x00 "$1" "`$2'" "$3" X1 eval(Y2+20) 0 100 0x00)
367         PIN(X1, Y, 60, 28, 1)
368         PIN(X2, Y, 60, 28, 2)
369         ElementLine(X1 Y1 X2 Y1 10)
370         ElementLine(X1 Y2 X2 Y2 10)
371         ElementArc(X1 Y 50 50 270 180 10)
372         ElementArc(X2 Y 50 50 90 180 10)
373         Mark (X1 Y)
376 # -------------------------------------------------------------------
377 # a can oscillator package
379 # $1: canonical name
380 # $2: name on PCB
381 # $3: value
383 define(`PKG_OSC',
384 `Element(0x00 "$1" "`$2'" "$3" 270 300 3 100 0x00)
386         Pin(100 100 50 28 "NC" 0x01)
387         Pin(100 700 50 28 "GND" 0x01)
388         Pin(400 700 50 28 "CLK" 0x01)
389         Pin(400 100 50 28 "VCC" 0x01)
391         ElementLine(5 5 400 5 10)
392         ElementArc(400 100 95 95 180 90 10)
393         ElementLine(495 100 495 700 10)
394         ElementArc(400 700 95 95 90 90 10)
395         ElementLine(400 795 100 795 10)
396         ElementArc(100 700 95 95 0 90 10)
397         ElementLine(5 700 5 5 10)
399         ElementLine(100 60 400 60 10)
400         ElementArc(400 100 40 40 180 90 10)
401         ElementLine(440 100 440 700 10)
402         ElementArc(400 700 40 40 90 90 10)
403         ElementLine(400 740 100 740 10)
404         ElementArc(100 700 40 40 0 90 10)
405         ElementLine(60 700 60 100 10)
406         ElementArc(100 100 40 40 270 90 10)
408         Mark(100 100)
411 # -------------------------------------------------------------------
412 # 8 bit ISA Slot card
414 # Volker Bosch (bosch@iema.e-technik.uni-stuttgart.de), 12/95
416 # $1: canonical name
417 # $2: name on PCB
418 # $3: value
420 define(`PKG_ISA8',
421 `Element(0x00 "$1" "`$2'" "$3" 4000 0 0 100 0x00)
423     # Pins, entspr. Anschl. auf Loetseite (b31..b1)
424         Pin( 200 3850 60 35 "Gnd (b31)" 0x01)
425         Pin( 300 3850 60 35 "Osc" 0x01)
426         Pin( 400 3850 60 35 "+5V" 0x01)
427         Pin( 500 3850 60 35 "BALE" 0x01)
428         Pin( 600 3850 60 35 "TC" 0x01)
429         Pin( 700 3850 60 35 "/DAck2" 0x01)
430         Pin( 800 3850 60 35 "IRq3" 0x01)
431         Pin( 900 3850 60 35 "IRq4" 0x01)
432         Pin(1000 3850 60 35 "IRq5" 0x01)
433         Pin(1100 3850 60 35 "IRq6" 0x01)
434         Pin(1200 3850 60 35 "IRq7" 0x01)
435         Pin(1300 3850 60 35 "Clock" 0x01)
436         Pin(1400 3850 60 35 "/Ref" 0x01)
437         Pin(1500 3850 60 35 "DRq1" 0x01)
438         Pin(1600 3850 60 35 "/DAck1" 0x01)
439         Pin(1700 3850 60 35 "DRq3" 0x01)
440         Pin(1800 3850 60 35 "/DAck3" 0x01)
441         Pin(1900 3850 60 35 "/IOR" 0x01)
442         Pin(2000 3850 60 35 "/IOW" 0x01)
443         Pin(2100 3850 60 35 "/SMEMR" 0x01)
444         Pin(2200 3850 60 35 "/SMEMW" 0x01)
445         Pin(2300 3850 60 35 "Gnd" 0x01)
446         Pin(2400 3850 60 35 "+12V" 0x01)
447         Pin(2500 3850 60 35 "/0WS" 0x01)
448         Pin(2600 3850 60 35 "-12V" 0x01)
449         Pin(2700 3850 60 35 "DRq2" 0x01)
450         Pin(2800 3850 60 35 "-5V" 0x01)
451         Pin(2900 3850 60 35 "IEQ2" 0x01)
452         Pin(3000 3850 60 35 "+5V" 0x01)
453         Pin(3100 3850 60 35 "ResDrv" 0x01)
454         Pin(3200 3850 60 35 "Gnd (b1)" 0x01)
456       # Pins, entspr. Anschl. auf Bestueckseite
457         Pin( 200 3950 60 35 "SA0 (a31)" 0x01)
458         Pin( 300 3950 60 35 "SA1" 0x01)
459         Pin( 400 3950 60 35 "SA2" 0x01)
460         Pin( 500 3950 60 35 "SA3" 0x01)
461         Pin( 600 3950 60 35 "SA4" 0x01)
462         Pin( 700 3950 60 35 "SA5" 0x01)
463         Pin( 800 3950 60 35 "SA6" 0x01)
464         Pin( 900 3950 60 35 "SA7" 0x01)
465         Pin(1000 3950 60 35 "SA8" 0x01)
466         Pin(1100 3950 60 35 "SA9" 0x01)
467         Pin(1200 3950 60 35 "SA10" 0x01)
468         Pin(1300 3950 60 35 "SA11" 0x01)
469         Pin(1400 3950 60 35 "SA12" 0x01)
470         Pin(1500 3950 60 35 "SA13" 0x01)
471         Pin(1600 3950 60 35 "SA14" 0x01)
472         Pin(1700 3950 60 35 "SA15" 0x01)
473         Pin(1800 3950 60 35 "SA16" 0x01)
474         Pin(1900 3950 60 35 "SA17" 0x01)
475         Pin(2000 3950 60 35 "SA18" 0x01)
476         Pin(2100 3950 60 35 "SA19" 0x01)
477         Pin(2200 3950 60 35 "AEN" 0x01)
478         Pin(2300 3950 60 35 "IOChRdy" 0x01)
479         Pin(2400 3950 60 35 "SD0" 0x01)
480         Pin(2500 3950 60 35 "SD1" 0x01)
481         Pin(2600 3950 60 35 "SD2" 0x01)
482         Pin(2700 3950 60 35 "SD3" 0x01)
483         Pin(2800 3950 60 35 "SD4" 0x01)
484         Pin(2900 3950 60 35 "SD5" 0x01)
485         Pin(3000 3950 60 35 "SD6" 0x01)
486         Pin(3100 3950 60 35 "SD7" 0x01)
487         Pin(3200 3950 60 35 "/IOChCk (a1)" 0x01)
489       # Umrahmung
490         ElementLine(   0  100  100  100 2)
491         ElementLine( 100    0  100  100 2)
492         ElementLine( 100  100 4250  100 5)
493         ElementLine(4250  100 4250 3810 5)
494         ElementLine(4250 3810 3620 3810 5)
495         ElementLine(3620 3810 3620 3510 5)
496         ElementLine(3620 3510 3300 3510 5)
497         ElementLine(3300 3510 3300 3810 5)
498         ElementLine(3300 3810  100 3810 5)
499         ElementLine( 100 3810  100 3510 5)
500         ElementLine( 100 3510    0 3510 2)
502       # Markierung == Pin B1
503         Mark(3200 3850)
506 # -------------------------------------------------------------------
507 # an ovenized-oscillator package
509 # $1: canonical name
510 # $2: name on PCB
511 # $3: value
512 # Text(620 320 0 100 "GROUND" 0x0001)
513 # Text(620 520 0 100 "VECTRON LABORATORIES, INC." 0x0001)
514 # Text(620 720 0 100 "CO711 SERIES OSC" 0x0001)
515 # Text(620 920 0 100 "711-04-006" 0x0001)
516 # Text(620 1680 0 100 "+12 -> 15 VOLTS DC" 0x0001) 
517 define(`PKG_OVEN_OSC',
518 `Element(0x00 "$1" "`$2'" "$3" 580 280 0 100 0x00)
520         Pin(320 320 150 35 "NC" 0x01)
521         Pin(320 1000 150 35 "VCC" 0x01)
522         Pin(320 1680 150 35 "CLK" 0x01)
523         Pin(1680 320 150 35 "+12V" 0x01)
524         Pin(1680 1680 150 35 "GND" 0x01)
526         ElementLine(2020 1125 2020 875 10)
527         ElementLine(2100 875 2020 875 10)
528         ElementLine(2100 975 2100 875 10)
529         ElementLine(2075 975 2100 975 10)
530         ElementLine(2075 1025 2075 975 10)
531         ElementLine(2100 1025 2075 1025 10)
532         ElementLine(2100 1125 2100 1025 10)
533         ElementLine(2100 1125 2020 1125 10)
535         ElementLine(2000 320 2000 1680 10)
536         ElementLine(320 0 1680 0 10)
537         ElementLine(0 1680 0 320 10)
538         ElementLine(1680 2000 320 2000 10)
540         ElementArc(320 320 320 320 270 90 10)
541         ElementArc(320 1680 320 320 0 90 10)
542         ElementArc(1680 320 320 320 180 90 10)
543         ElementArc(1680 1680 320 320 90 90 10)
545         Mark(320 320)
548 # a radial capacitor package
550 # $1: canonical name
551 # $2: name on PCB
552 # $3: value
553 # $4: package width in MIL
554 # $5: set to 1 if a polarized part
555 define(`PKG_RADIAL_CAN',
556         `define(`X1', `eval(`$4' /4)')
557         define(`X2', `eval(`$4' -X1)')
558         define(`X3', `eval(`$4' /2)')
559         define(`Y', `eval(`$4' /2)')
560         define(`R', `eval(`$4' /2)')
561         define(`PINSIZE', `ifelse(eval($4 >= 600), 1, 80, 55)')
562         define(`DRILLSIZE', `ifelse(eval($4 >= 600), 1, 50, 30)')
563 Element(0x00 "$1" "`$2'" "$3" eval(`$4') 0 0 100 0x00)
565         PIN(X1, Y, 60, DRILLSIZE, 1)
566         PIN(X2, Y, 60, DRILLSIZE, 2)
567         ElementArc(X3 Y R R 0 360 10)
569         ifelse( 1, $5,
570         ElementLine(-60 Y            -20 Y 10)
571         ElementLine(-40 `eval(Y-20)' -40 `eval(Y+20)' 10)
572         ElementLine(`eval($4 + 20)' Y `eval($4 + 60)'  Y 10)
573         )
575         Mark (X1 Y)
578 # a core surface mount package
579 # 12/99 Larry Doolittle <LRDoolittle@lbl.gov>
581 # $1: canonical name
582 # $2: name on PCB
583 # $3: value
584 # $4: device length in MIL
585 # $5: device width in MIL
587 # Note that the pad width, length, and separation are derived from
588 # the given device dimensions.  I <LRDoolittle@lbl.gov> don't
589 # claim to have followed any industry standards here, these sizes
590 # are based on someone else's measurements:
591 #  0603 is 30x40 mil pads on 60 mil pad ctr
592 #  0805 is 44x60 mil pads on 80 mil pad ctr
593 # on a PC motherboard.  If you know the "real" values, please educate
594 # me and/or adjust this code.
596 define(`PKG_SMD_BASE',
597         `define(`T', `eval(`$4'/4+`$5'/2)')
598         define(`W', `eval(T/2+15)')
599         define(`X1', `0')
600         define(`X2',  ``$4'')
601         define(`Y',  `0')
602         define(`Y1',  `eval(Y-(`$5'-T)/2-5)')
603         define(`Y2',  `eval(Y+(`$5'-T)/2+5)')
604         # Silkscreen box coordinates
605         define(`X1L', `eval(X1-W)')
606         define(`X2L', `eval(X2+W)')
607         define(`Y1L', `eval(Y1-W)')
608         define(`Y2L', `eval(Y2+W)')
609 Element(0x00 "$1" "`$2'" "$3" eval(10+T/2) eval(Y2L+15) 0 100 0x00)
611         # PAD(X1, Y1, X1, Y2, T, 1)
612         # PAD(X2, Y1, X2, Y2, T, 2)
613         # Use Pad instead of PAD so both pads come out square
614         Pad(X1 Y1 X1 Y2 T "1" 0x100)
615         Pad(X2 Y1 X2 Y2 T "2" 0x100)
616         ElementLine(X1L Y1L X1L Y2L 8)
617         ElementLine(X1L Y2L X2L Y2L 8)
618         ElementLine(X2L Y2L X2L Y1L 8)
619         ElementLine(X2L Y1L X1L Y1L 8)
620         SMD_OUTLINE_EXTRA
623 define(`PKG_SMD_SIMPLE',
624         `define(`SMD_OUTLINE_EXTRA', `')
625         PKG_SMD_BASE(`$1', `$2', `$3', `$4', `$5')
628 define(`PKG_SMD_DIODE',
629         `define(`SMD_OUTLINE_EXTRA',
630                 `
631                 define(`XBAR', `eval(X1L+10)')
632                 ElementLine( XBAR Y1L XBAR Y2L 8 )
633         ')
634         PKG_SMD_BASE(`$1', `$2', `$3', `$4', `$5')
637 define(`PKG_SMD_POLAR',
638         `define(`SMD_OUTLINE_EXTRA',
639                 `
640                 # crude plus sign
641                 # ElementLine(      X1     eval(Y2L+20)       X1    eval(Y2L+70) 8)
642                 # ElementLine( eval(X1-25) eval(Y2L+45) eval(X1+25) eval(Y2L+45) 8)
643                 define(`XBAR', `eval(X1L+10)')
644                 ElementLine( XBAR Y1L XBAR Y2L 8 )
646         ')
647         PKG_SMD_BASE(`$1', `$2', `$3', `$4', `$5')
650 # a smd chip package, capacitor or resistor
652 # $1: canonical name
653 # $2: name on PCB
654 # $3: value
655 # $4: package designator length in MIL *100 + width in MIL /10
656 #     ie 402 == 40 X 20; 603 == 60 X 30 
658 define(`PKG_SMD_CHIP',
659         `define(`X1', `eval(eval(`$4' /100)*10)')
660         define(`Y1', `eval(eval(`$4'- X1 *10) *10)')
661 # line radius (LR) depicts offset to pads lines and pad "band width"
662         define(`LR', `ifelse(eval(Y1 < 40), 1, eval(Y1/4), 10)')
663 Element(0x00 "$1" "`$2'" "$3" 0 0 0 25 0x00)
665         PAD(LR LR LR eval(Y1-LR) eval(LR*2) )
666         PAD(eval(X1-LR) LR eval(X1-LR) eval(Y1-LR) eval(LR*2) )
668         ElementLine( 0  0 X1  0 5)
669         ElementLine(X1  0 X1 Y1 5)
670         ElementLine(X1 Y1  0 Y1 5)
671         ElementLine( 0 Y1  0  0 5)
673         Mark(eval(X1/2) eval(Y1/2))