circuitscript 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/annotate/ComponentAnnotater.js +6 -12
- package/dist/cjs/antlr/CircuitScriptParser.js +372 -342
- package/dist/cjs/errors.js +6 -3
- package/dist/cjs/execute.js +4 -3
- package/dist/cjs/objects/ClassComponent.js +3 -3
- package/dist/cjs/regenerate-tests.js +4 -1
- package/dist/cjs/render/draw_symbols.js +33 -0
- package/dist/cjs/visitor.js +41 -14
- package/dist/esm/annotate/ComponentAnnotater.js +6 -12
- package/dist/esm/antlr/CircuitScriptParser.js +372 -342
- package/dist/esm/errors.js +6 -3
- package/dist/esm/execute.js +4 -3
- package/dist/esm/objects/ClassComponent.js +3 -3
- package/dist/esm/regenerate-tests.js +4 -1
- package/dist/esm/render/draw_symbols.js +33 -0
- package/dist/esm/visitor.js +42 -15
- package/dist/libs/std.cst +515 -14
- package/dist/types/antlr/CircuitScriptParser.d.ts +3 -1
- package/dist/types/execute.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +1 -1
- package/dist/types/render/draw_symbols.d.ts +2 -0
- package/libs/std.cst +515 -14
- package/package.json +1 -1
package/libs/std.cst
CHANGED
|
@@ -57,7 +57,7 @@ def res(value):
|
|
|
57
57
|
crect: 0, 0, width, height
|
|
58
58
|
hpin: 1, -width/2 - 30, 0, 30, display_id=false
|
|
59
59
|
hpin: 2, width/2 + 30, 0, -30, display_id=false
|
|
60
|
-
label: params.refdes, -width/2, -height/2 - 20, fontSize=50, anchor="left"
|
|
60
|
+
label: params.refdes, -width/2 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="left"
|
|
61
61
|
label: params.value, 0, 0, fontSize=30, anchor="center", vanchor="center"
|
|
62
62
|
type: "res"
|
|
63
63
|
params:
|
|
@@ -65,6 +65,8 @@ def res(value):
|
|
|
65
65
|
size: "0402"
|
|
66
66
|
footprint: "Resistor_SMD:R_0402_1005Metric"
|
|
67
67
|
description: "RES {value} OHM {size}"
|
|
68
|
+
refdes_offsetx: 0
|
|
69
|
+
refdes_offsety: 0
|
|
68
70
|
|
|
69
71
|
def cap(value):
|
|
70
72
|
width = 120
|
|
@@ -78,13 +80,15 @@ def cap(value):
|
|
|
78
80
|
hline: -width/2, -20, width
|
|
79
81
|
vpin: 1, 0, -100, 80, display_id=false
|
|
80
82
|
vpin: 2, 0, 100, -80, display_id=false
|
|
81
|
-
label: params.refdes, 80, -30, fontSize=50, anchor="left", vanchor="center"
|
|
83
|
+
label: params.refdes, 80 + params.refdes_offsetx, -30 + params.refdes_offsety, fontSize=50, anchor="left", vanchor="center"
|
|
82
84
|
label: params.value, 80, 30, fontSize=50, anchor = "left", vanchor="center"
|
|
83
85
|
type: "cap"
|
|
84
86
|
params:
|
|
85
87
|
value: value
|
|
86
88
|
size: "0402"
|
|
87
89
|
footprint: "Capacitor_SMD:C_0402_1005Metric"
|
|
90
|
+
refdes_offsetx: 0
|
|
91
|
+
refdes_offsety: 0
|
|
88
92
|
|
|
89
93
|
def ind(value):
|
|
90
94
|
width = 200
|
|
@@ -100,10 +104,12 @@ def ind(value):
|
|
|
100
104
|
arc: 75, 0, 25, 180, 360
|
|
101
105
|
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
102
106
|
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
103
|
-
label: (params.refdes, -width/2, -height/2 - 25 , fontSize=50, anchor="left")
|
|
107
|
+
label: (params.refdes, -width/2 + params.refdes_offsetx, -height/2 - 25 + params.refdes_offsety, fontSize=50, anchor="left")
|
|
104
108
|
label: (params.value, 0, 50, fontSize=50, anchor="center", vanchor="center")
|
|
105
109
|
params:
|
|
106
110
|
value: value
|
|
111
|
+
refdes_offsetx: 0
|
|
112
|
+
refdes_offsety: 0
|
|
107
113
|
|
|
108
114
|
def diode():
|
|
109
115
|
width = 100
|
|
@@ -119,7 +125,10 @@ def diode():
|
|
|
119
125
|
vline: width/2, -height/2, height
|
|
120
126
|
hpin: 1, -width/2-100, 0, 100 # cathode
|
|
121
127
|
hpin: 2, width/2 + 100, 0, -100 # anode
|
|
122
|
-
label: params.refdes, 0, -100, fontSize=50, anchor="center", vanchor="top"
|
|
128
|
+
label: params.refdes, 0 + params.refdes_offsetx, -100 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="top"
|
|
129
|
+
params:
|
|
130
|
+
refdes_offsetx: 0
|
|
131
|
+
refdes_offsety: 0
|
|
123
132
|
|
|
124
133
|
def led(color):
|
|
125
134
|
width = 100
|
|
@@ -127,20 +136,16 @@ def led(color):
|
|
|
127
136
|
|
|
128
137
|
# anode and cathode pin numbers follow KiCad
|
|
129
138
|
return create component:
|
|
130
|
-
pins:
|
|
131
|
-
1: "cathode"
|
|
132
|
-
2: "anode"
|
|
133
139
|
type: "diode"
|
|
134
140
|
display: create graphic (params):
|
|
135
141
|
triangle: -width/2, 0, width/2, 0, height
|
|
136
142
|
vline: width/2, -height/2, height
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
hpin:
|
|
142
|
-
|
|
143
|
-
label: params.refdes, 0, -100, fontSize=50, anchor="center", vanchor="top"
|
|
143
|
+
arrow: 70, 30, 130, 90, 25, 25
|
|
144
|
+
arrow: 120, 30, 180, 90, 25, 25
|
|
145
|
+
|
|
146
|
+
hpin: 1, "C", width/2 + 100, 0, -100, display_name=false # cathode
|
|
147
|
+
hpin: 2, "A", -width/2-100, 0, 100, display_name=false # anode
|
|
148
|
+
label: params.refdes, 0 + params.refdes_offsetx, -100 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="top"
|
|
144
149
|
label: params.color, 0, 100, fontSize=40, anchor="center", vanchor="bottom"
|
|
145
150
|
params:
|
|
146
151
|
size: "0603"
|
|
@@ -148,6 +153,8 @@ def led(color):
|
|
|
148
153
|
value: color
|
|
149
154
|
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
150
155
|
description: "LED {color} {size}"
|
|
156
|
+
refdes_offsetx: 0
|
|
157
|
+
refdes_offsety: 0
|
|
151
158
|
|
|
152
159
|
def cgnd():
|
|
153
160
|
net_name = "gnd"
|
|
@@ -229,6 +236,500 @@ def no_connect(size=20):
|
|
|
229
236
|
def dnc(size=20):
|
|
230
237
|
return no_connect(size)
|
|
231
238
|
|
|
239
|
+
# ============================================================
|
|
240
|
+
# Passive Components
|
|
241
|
+
# ============================================================
|
|
242
|
+
|
|
243
|
+
def pot(value):
|
|
244
|
+
# Potentiometer — 3 pins: pin1 (end1), pin2 (end2), pin3 (wiper)
|
|
245
|
+
width = 140
|
|
246
|
+
height = 60
|
|
247
|
+
|
|
248
|
+
return create component:
|
|
249
|
+
pins: 3
|
|
250
|
+
type: "res"
|
|
251
|
+
display: create graphic (params):
|
|
252
|
+
crect: 0, 0, width, height
|
|
253
|
+
hpin: 1, -width/2 - 30, 0, 30, display_id=false
|
|
254
|
+
hpin: 2, width/2 + 30, 0, -30, display_id=false
|
|
255
|
+
vpin: 3, 0, height/2 + 80, -80, display_id=false
|
|
256
|
+
# Arrowhead pointing up toward body (wiper indicator)
|
|
257
|
+
path: ("M", -12, height/2 + 14, "L", 0, height/2, "L", 12, height/2 + 14)
|
|
258
|
+
label: params.refdes, -width/2 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="left"
|
|
259
|
+
label: params.value, 0, 0, fontSize=30, anchor="center", vanchor="center"
|
|
260
|
+
params:
|
|
261
|
+
value: value
|
|
262
|
+
refdes_offsetx: 0
|
|
263
|
+
refdes_offsety: 0
|
|
264
|
+
|
|
265
|
+
def cap_pol(value):
|
|
266
|
+
# Polarized capacitor (electrolytic) — pin1 (+anode), pin2 (-cathode)
|
|
267
|
+
width = 120
|
|
268
|
+
height = 40
|
|
269
|
+
|
|
270
|
+
return create component:
|
|
271
|
+
pins: 2
|
|
272
|
+
type: "cap"
|
|
273
|
+
display: create graphic (params):
|
|
274
|
+
line_width: 13
|
|
275
|
+
hline: -width/2, 20, width
|
|
276
|
+
hline: -width/2, -20, width
|
|
277
|
+
vpin: 1, 0, -100, 80, display_id=false
|
|
278
|
+
vpin: 2, 0, 100, -80, display_id=false
|
|
279
|
+
# Plus sign near positive (top) plate
|
|
280
|
+
line_width: 8
|
|
281
|
+
hline: -50, -50, 30
|
|
282
|
+
vline: -35, -65, 30
|
|
283
|
+
label: params.refdes, 80 + params.refdes_offsetx, -30 + params.refdes_offsety, fontSize=50, anchor="left", vanchor="center"
|
|
284
|
+
label: params.value, 80, 30, fontSize=50, anchor="left", vanchor="center"
|
|
285
|
+
params:
|
|
286
|
+
value: value
|
|
287
|
+
size: "0402"
|
|
288
|
+
footprint: "Capacitor_SMD:CP_Elec_3x5.3"
|
|
289
|
+
refdes_offsetx: 0
|
|
290
|
+
refdes_offsety: 0
|
|
291
|
+
|
|
292
|
+
def ferrite(value):
|
|
293
|
+
# Ferrite bead — filled rectangle body
|
|
294
|
+
width = 140
|
|
295
|
+
height = 60
|
|
296
|
+
|
|
297
|
+
return create component:
|
|
298
|
+
pins: 2
|
|
299
|
+
type: "ind"
|
|
300
|
+
display: create graphic (params):
|
|
301
|
+
fill: "#333"
|
|
302
|
+
crect: 0, 0, width, height
|
|
303
|
+
fill: "none"
|
|
304
|
+
hpin: 1, -width/2 - 30, 0, 30, display_id=false
|
|
305
|
+
hpin: 2, width/2 + 30, 0, -30, display_id=false
|
|
306
|
+
label: params.refdes, -width/2 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="left"
|
|
307
|
+
params:
|
|
308
|
+
value: value
|
|
309
|
+
refdes_offsetx: 0
|
|
310
|
+
refdes_offsety: 0
|
|
311
|
+
|
|
312
|
+
def xtal(frequency):
|
|
313
|
+
# Crystal oscillator — 2-pin
|
|
314
|
+
width = 80
|
|
315
|
+
height = 160
|
|
316
|
+
|
|
317
|
+
return create component:
|
|
318
|
+
type: "X"
|
|
319
|
+
pins: 2
|
|
320
|
+
display: create graphic (params):
|
|
321
|
+
# Piezoelectric plates (thick vertical lines)
|
|
322
|
+
line_width: 14
|
|
323
|
+
vline: -12, -height/2, height
|
|
324
|
+
vline: 12, -height/2, height
|
|
325
|
+
# Outer case
|
|
326
|
+
line_width: 5
|
|
327
|
+
crect: 0, 0, width, height
|
|
328
|
+
hpin: 1, -width/2 - 120, 0, 120, display_id=false
|
|
329
|
+
hpin: 2, width/2 + 120, 0, -120, display_id=false
|
|
330
|
+
label: params.refdes, 0 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="bottom"
|
|
331
|
+
label: params.frequency, 0, height/2 + 20, fontSize=50, anchor="center", vanchor="top"
|
|
332
|
+
params:
|
|
333
|
+
frequency: frequency
|
|
334
|
+
refdes_offsetx: 0
|
|
335
|
+
refdes_offsety: 0
|
|
336
|
+
|
|
337
|
+
def fuse(value):
|
|
338
|
+
# Fuse — rectangle with center line
|
|
339
|
+
width = 140
|
|
340
|
+
height = 60
|
|
341
|
+
|
|
342
|
+
return create component:
|
|
343
|
+
pins: 2
|
|
344
|
+
type: "F"
|
|
345
|
+
display: create graphic (params):
|
|
346
|
+
crect: 0, 0, width, height
|
|
347
|
+
hline: -width/2, 0, width
|
|
348
|
+
hpin: 1, -width/2 - 30, 0, 30, display_id=false
|
|
349
|
+
hpin: 2, width/2 + 30, 0, -30, display_id=false
|
|
350
|
+
label: params.refdes, -width/2 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="left"
|
|
351
|
+
label: params.value, 0, 0, fontSize=30, anchor="center", vanchor="center"
|
|
352
|
+
params:
|
|
353
|
+
value: value
|
|
354
|
+
refdes_offsetx: 0
|
|
355
|
+
refdes_offsety: 0
|
|
356
|
+
|
|
357
|
+
def jumper():
|
|
358
|
+
# Jumper / solder bridge — 2 pads with arc
|
|
359
|
+
return create component:
|
|
360
|
+
pins: 2
|
|
361
|
+
type: "jp"
|
|
362
|
+
display: create graphic (params):
|
|
363
|
+
circle: -50, 0, 20
|
|
364
|
+
circle: 50, 0, 20
|
|
365
|
+
arc: 0, 0, 50, 180, 360
|
|
366
|
+
hpin: 1, -150, 0, 100, display_id=false
|
|
367
|
+
hpin: 2, 150, 0, -100, display_id=false
|
|
368
|
+
label: params.refdes, 0 + params.refdes_offsetx, -80 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="bottom"
|
|
369
|
+
params:
|
|
370
|
+
refdes_prefix: "JP"
|
|
371
|
+
refdes_offsetx: 0
|
|
372
|
+
refdes_offsety: 0
|
|
373
|
+
|
|
374
|
+
# ============================================================
|
|
375
|
+
# Diodes
|
|
376
|
+
# ============================================================
|
|
377
|
+
|
|
378
|
+
def zener():
|
|
379
|
+
# Zener diode — pin1 (cathode), pin2 (anode)
|
|
380
|
+
width = 100
|
|
381
|
+
height = 100
|
|
382
|
+
|
|
383
|
+
return create component:
|
|
384
|
+
pins: 2
|
|
385
|
+
type: "diode"
|
|
386
|
+
display: create graphic (params):
|
|
387
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
388
|
+
vline: width/2, -height/2, height
|
|
389
|
+
# Zener wings (bent ends on cathode bar)
|
|
390
|
+
line: width/2, -height/2, width/2-20, -height/2-20
|
|
391
|
+
line: width/2, height/2, width/2 + 20, height/2 + 20
|
|
392
|
+
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
393
|
+
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
394
|
+
label: params.refdes, -20- params.refdes_offsetx, -110 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="top"
|
|
395
|
+
params:
|
|
396
|
+
refdes_offsetx: 0
|
|
397
|
+
refdes_offsety: 0
|
|
398
|
+
|
|
399
|
+
def schottky():
|
|
400
|
+
# Schottky diode — pin1 (cathode), pin2 (anode)
|
|
401
|
+
width = 100
|
|
402
|
+
height = 100
|
|
403
|
+
|
|
404
|
+
return create component:
|
|
405
|
+
pins: 2
|
|
406
|
+
type: "diode"
|
|
407
|
+
display: create graphic (params):
|
|
408
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
409
|
+
vline: width/2, -height/2, height
|
|
410
|
+
# Schottky S-curve marks on cathode bar
|
|
411
|
+
path: ("M", width/2, -height/2, "L", width/2 - 20, -height/2, "L", width/2 - 20, -height/2 + 20)
|
|
412
|
+
path: ("M", width/2, height/2, "L", width/2 + 20, height/2, "L", width/2 + 20, height/2 - 20)
|
|
413
|
+
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
414
|
+
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
415
|
+
label: params.refdes, 0 + params.refdes_offsetx, -100 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="top"
|
|
416
|
+
params:
|
|
417
|
+
refdes_offsetx: 0
|
|
418
|
+
refdes_offsety: 0
|
|
419
|
+
|
|
420
|
+
def tvs():
|
|
421
|
+
# TVS (transient voltage suppressor) — bidirectional zener
|
|
422
|
+
# pin1 (A1), pin2 (A2)
|
|
423
|
+
width = 100
|
|
424
|
+
height = 100
|
|
425
|
+
|
|
426
|
+
return create component:
|
|
427
|
+
pins: 2
|
|
428
|
+
type: "diode"
|
|
429
|
+
display: create graphic (params):
|
|
430
|
+
# Two back-to-back diode triangles
|
|
431
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
432
|
+
vline: width/2, -height/2, height
|
|
433
|
+
hline: width/2, -height/2, 20
|
|
434
|
+
hline: width/2 - 20, height/2, 20
|
|
435
|
+
#triangle: width/2, 0, -width/2, 0, height
|
|
436
|
+
#vline: -width/2, -height/2, height
|
|
437
|
+
#hline: -width/2, -height/2, -20
|
|
438
|
+
#hline: -width/2 + 20, height/2, -20
|
|
439
|
+
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
440
|
+
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
441
|
+
label: params.refdes, 0 + params.refdes_offsetx, -100 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="top"
|
|
442
|
+
params:
|
|
443
|
+
refdes_offsetx: 0
|
|
444
|
+
refdes_offsety: 0
|
|
445
|
+
|
|
446
|
+
def photodiode():
|
|
447
|
+
# Photodiode — arrows pointing inward (light detecting)
|
|
448
|
+
# pin1 (cathode), pin2 (anode)
|
|
449
|
+
width = 100
|
|
450
|
+
height = 100
|
|
451
|
+
|
|
452
|
+
return create component:
|
|
453
|
+
pins: 2
|
|
454
|
+
type: "diode"
|
|
455
|
+
display: create graphic (params):
|
|
456
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
457
|
+
vline: width/2, -height/2, height
|
|
458
|
+
# Light arrows pointing toward junction
|
|
459
|
+
|
|
460
|
+
arrow: -25, 95, 25, 45, 25, 25
|
|
461
|
+
arrow: -25, 145, 25, 95, 25, 25
|
|
462
|
+
|
|
463
|
+
#path: ("M", -25, 125, "L", 25, 75, "M", 25, 100, "L", 25, 75, "L", 0, 75)
|
|
464
|
+
#path: ("M", -75, 125, "L", -25, 75, "M", -25, 100, "L", -25, 75, "L", -50, 75)
|
|
465
|
+
|
|
466
|
+
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
467
|
+
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
468
|
+
label: params.refdes, 0 + params.refdes_offsetx, -100 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="top"
|
|
469
|
+
params:
|
|
470
|
+
refdes_offsetx: 0
|
|
471
|
+
refdes_offsety: 0
|
|
472
|
+
|
|
473
|
+
# ============================================================
|
|
474
|
+
# Transistors
|
|
475
|
+
# ============================================================
|
|
476
|
+
|
|
477
|
+
def npn():
|
|
478
|
+
# NPN BJT — pin1 (B), pin2 (C), pin3 (E)
|
|
479
|
+
return create component:
|
|
480
|
+
pins:
|
|
481
|
+
1: "B"
|
|
482
|
+
2: "C"
|
|
483
|
+
3: "E"
|
|
484
|
+
type: "transistor"
|
|
485
|
+
display: create graphic (params):
|
|
486
|
+
# Base bar
|
|
487
|
+
line_width: 15
|
|
488
|
+
vline: -25, -80, 160
|
|
489
|
+
line_width: 5
|
|
490
|
+
# Collector diagonal (upper)
|
|
491
|
+
line: -20, -40, 60, -100
|
|
492
|
+
# Emitter diagonal (lower)
|
|
493
|
+
arrow: -20, 40, 60, 100, 25, 25
|
|
494
|
+
|
|
495
|
+
# Emitter arrow — NPN: outward (away from base)
|
|
496
|
+
|
|
497
|
+
hpin: 1, -120, 0, 100, display_id=false # base
|
|
498
|
+
vpin: 2, 60, -200, 100, display_id=false # collector
|
|
499
|
+
vpin: 3, 60, 200, -100, display_id=false # emitter
|
|
500
|
+
label: params.refdes, 70 + params.refdes_offsetx, 0 + params.refdes_offsety, fontSize=50, anchor="left", vanchor="center"
|
|
501
|
+
params:
|
|
502
|
+
refdes_offsetx: 0
|
|
503
|
+
refdes_offsety: 0
|
|
504
|
+
|
|
505
|
+
def pnp():
|
|
506
|
+
# PNP BJT — pin1 (B), pin2 (C), pin3 (E)
|
|
507
|
+
return create component:
|
|
508
|
+
pins:
|
|
509
|
+
1: "B"
|
|
510
|
+
2: "C"
|
|
511
|
+
3: "E"
|
|
512
|
+
type: "transistor"
|
|
513
|
+
display: create graphic (params):
|
|
514
|
+
# Base bar
|
|
515
|
+
line_width: 15
|
|
516
|
+
vline: -25, -80, 160
|
|
517
|
+
line_width:5
|
|
518
|
+
|
|
519
|
+
# Collector diagonal (upper)
|
|
520
|
+
line: -20, -40, 60, -100
|
|
521
|
+
# Emitter diagonal (lower)
|
|
522
|
+
#line: -20, 40, 60, 100
|
|
523
|
+
# Emitter arrow — PNP: inward (toward base bar)
|
|
524
|
+
arrow:60, 100, -20, 40
|
|
525
|
+
hpin: 1, -120, 0, 100, display_id=false
|
|
526
|
+
vpin: 2, 60, -200, 100, display_id=false
|
|
527
|
+
vpin: 3, 60, 200, -100, display_id=false
|
|
528
|
+
label: params.refdes, 70 + params.refdes_offsetx, 0 + params.refdes_offsety, fontSize=50, anchor="left", vanchor="center"
|
|
529
|
+
params:
|
|
530
|
+
refdes_offsetx: 0
|
|
531
|
+
refdes_offsety: 0
|
|
532
|
+
|
|
533
|
+
def pmos():
|
|
534
|
+
return create component:
|
|
535
|
+
pins: 3
|
|
536
|
+
type: "Q"
|
|
537
|
+
display: create graphic (params):
|
|
538
|
+
hline: -75, -25, 175
|
|
539
|
+
fill: "#333"
|
|
540
|
+
crect: 0, 0, 50, 15
|
|
541
|
+
crect: 75, 0, 50, 15
|
|
542
|
+
crect: -75, 0, 50, 15
|
|
543
|
+
vline: 75, 0, 100
|
|
544
|
+
vline: -75, 0, 100
|
|
545
|
+
|
|
546
|
+
arrow: 0, 0, 0, 90
|
|
547
|
+
vline: 0, 0, 100
|
|
548
|
+
|
|
549
|
+
hline: 0, 100, -100
|
|
550
|
+
hline: 100, 100, -25
|
|
551
|
+
|
|
552
|
+
path: "M", -100, 100, "L", -100, 150, "L", 100, 150, "L", 100, 100
|
|
553
|
+
arrow: 100, 150, -12.5,150
|
|
554
|
+
vline: -12.5, 150-20, 40
|
|
555
|
+
|
|
556
|
+
label: params.refdes, 70, -60, anchor="center"
|
|
557
|
+
label: params.mpn, 0, 250, anchor="center"
|
|
558
|
+
|
|
559
|
+
hpin: 1, "D", 200, 100, -100, display_id=false, display_name=false
|
|
560
|
+
vpin: 2, "G", 0, -100, 75, display_id=false, display_name=false
|
|
561
|
+
hpin: 3, "S", -200, 100, 100, display_id=false, display_name=false
|
|
562
|
+
|
|
563
|
+
label: "S", -200, 70
|
|
564
|
+
label: "D", 200, 70, anchor="right"
|
|
565
|
+
label: "G", -70, -50
|
|
566
|
+
params:
|
|
567
|
+
mpn: "?"
|
|
568
|
+
|
|
569
|
+
def nmos():
|
|
570
|
+
return create component:
|
|
571
|
+
pins: 3
|
|
572
|
+
type: "Q"
|
|
573
|
+
display: create graphic (params):
|
|
574
|
+
hline: -75, -25, 175
|
|
575
|
+
fill: "#333"
|
|
576
|
+
crect: 0, 0, 50, 15
|
|
577
|
+
crect: 75, 0, 50, 15
|
|
578
|
+
crect: -75, 0, 50, 15
|
|
579
|
+
vline: 75, 0, 100
|
|
580
|
+
vline: -75, 0, 100
|
|
581
|
+
|
|
582
|
+
arrow: 0, 100, 0, 20
|
|
583
|
+
vline: 0, 0, 100
|
|
584
|
+
|
|
585
|
+
hline: 0, 100, -100
|
|
586
|
+
hline: 100, 100, -25
|
|
587
|
+
|
|
588
|
+
path: "M", -100, 100, "L", -100, 150, "L", 100, 150, "L", 100, 100
|
|
589
|
+
arrow: -100, 150, 12.5,150
|
|
590
|
+
vline: 12.5, 150-20, 40
|
|
591
|
+
|
|
592
|
+
label: params.refdes, 70, -60, anchor="center"
|
|
593
|
+
label: params.mpn, 0, 250, anchor="center"
|
|
594
|
+
|
|
595
|
+
hpin: 1, "D", 200, 100, -100, display_id=false, display_name=false
|
|
596
|
+
vpin: 2, "G", 0, -100, 75, display_id=false, display_name=false
|
|
597
|
+
hpin: 3, "S", -200, 100, 100, display_id=false, display_name=false
|
|
598
|
+
|
|
599
|
+
label: "S", -200, 70
|
|
600
|
+
label: "D", 200, 70, anchor="right"
|
|
601
|
+
label: "G", -70, -50
|
|
602
|
+
params:
|
|
603
|
+
mpn: "?"
|
|
604
|
+
|
|
605
|
+
# ============================================================
|
|
606
|
+
# Integrated Circuits
|
|
607
|
+
# ============================================================
|
|
608
|
+
|
|
609
|
+
def opamp():
|
|
610
|
+
# Op-amp — pin1 (OUT), pin2 (-), pin3 (+)
|
|
611
|
+
width = 200
|
|
612
|
+
height = 200
|
|
613
|
+
|
|
614
|
+
return create component:
|
|
615
|
+
type: "ic"
|
|
616
|
+
pins:
|
|
617
|
+
1: "OUT"
|
|
618
|
+
2: "-"
|
|
619
|
+
3: "+"
|
|
620
|
+
display: create graphic (params):
|
|
621
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
622
|
+
hpin: 1, width/2 + 100, 0, -100, display_id=false
|
|
623
|
+
hpin: 2, -width/2 - 100, 50, 100, display_id=false
|
|
624
|
+
hpin: 3, -width/2 - 100, -50, 100, display_id=false
|
|
625
|
+
label: params.refdes, 0 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="bottom"
|
|
626
|
+
params:
|
|
627
|
+
refdes_offsetx: 0
|
|
628
|
+
refdes_offsety: 0
|
|
629
|
+
|
|
630
|
+
def comparator():
|
|
631
|
+
# Comparator — pin1 (OUT), pin2 (-), pin3 (+)
|
|
632
|
+
# Same triangle symbol as opamp; open-collector output indication
|
|
633
|
+
width = 200
|
|
634
|
+
height = 200
|
|
635
|
+
|
|
636
|
+
return create component:
|
|
637
|
+
type: "ic"
|
|
638
|
+
pins:
|
|
639
|
+
1: "OUT"
|
|
640
|
+
2: "-"
|
|
641
|
+
3: "+"
|
|
642
|
+
display: create graphic (params):
|
|
643
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
644
|
+
hpin: 1, width/2 + 100, 0, -100, display_id=false
|
|
645
|
+
hpin: 2, -width/2 - 100, 50, 100, display_id=false
|
|
646
|
+
hpin: 3, -width/2 - 100, -50, 100, display_id=false
|
|
647
|
+
# Open-collector circle at output
|
|
648
|
+
circle: width/2 + 15, 0, 15
|
|
649
|
+
label: params.refdes, 0 + params.refdes_offsetx, -height/2 - 20 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="bottom"
|
|
650
|
+
params:
|
|
651
|
+
refdes_offsetx: 0
|
|
652
|
+
refdes_offsety: 0
|
|
653
|
+
|
|
654
|
+
# ============================================================
|
|
655
|
+
# Switches and Connectors
|
|
656
|
+
# ============================================================
|
|
657
|
+
|
|
658
|
+
def switch_spst():
|
|
659
|
+
# Single-pole single-throw switch (normally open)
|
|
660
|
+
return create component:
|
|
661
|
+
pins: 2
|
|
662
|
+
type: "sw"
|
|
663
|
+
display: create graphic (params):
|
|
664
|
+
circle: -60, 0, 12
|
|
665
|
+
circle: 60, 0, 12
|
|
666
|
+
# Open switch line (diagonal)
|
|
667
|
+
line: -48, 0, 45, -60
|
|
668
|
+
hpin: 1, -160, 0, 100, display_id=false
|
|
669
|
+
hpin: 2, 160, 0, -100, display_id=false
|
|
670
|
+
label: params.refdes, 0 + params.refdes_offsetx, -80 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="bottom"
|
|
671
|
+
params:
|
|
672
|
+
refdes_offsetx: 0
|
|
673
|
+
refdes_offsety: 0
|
|
674
|
+
|
|
675
|
+
def switch_pb():
|
|
676
|
+
# Normally-open push button
|
|
677
|
+
return create component:
|
|
678
|
+
pins: 2
|
|
679
|
+
type: "sw"
|
|
680
|
+
display: create graphic (params):
|
|
681
|
+
# Contact circles
|
|
682
|
+
circle: -60, 20, 12
|
|
683
|
+
circle: 60, 20, 12
|
|
684
|
+
# Actuator bar (above)
|
|
685
|
+
hline: -50, -30, 100
|
|
686
|
+
# Push shaft
|
|
687
|
+
vline: 0, -80, 50
|
|
688
|
+
# Arrowhead pointing down (push direction)
|
|
689
|
+
path: ("M", -12, -32, "L", 0, -12, "L", 12, -32)
|
|
690
|
+
hpin: 1, -160, 20, 100, display_id=false
|
|
691
|
+
hpin: 2, 160, 20, -100, display_id=false
|
|
692
|
+
label: params.refdes, 0 + params.refdes_offsetx, -100 + params.refdes_offsety, fontSize=50, anchor="center", vanchor="bottom"
|
|
693
|
+
params:
|
|
694
|
+
refdes_offsetx: 0
|
|
695
|
+
refdes_offsety: 0
|
|
696
|
+
|
|
697
|
+
def conn(n):
|
|
698
|
+
# Generic N-pin connector — all pins on left side
|
|
699
|
+
pin_spacing = 100
|
|
700
|
+
body_height = n * pin_spacing
|
|
701
|
+
body_width = 200
|
|
702
|
+
|
|
703
|
+
return create component:
|
|
704
|
+
type: "conn"
|
|
705
|
+
pins: n
|
|
706
|
+
display: create graphic (params):
|
|
707
|
+
crect: 0, 0, body_width, body_height
|
|
708
|
+
for i in range(1, n + 1):
|
|
709
|
+
circle: 0, -body_height/2 + (i - 0.5) * pin_spacing, 35
|
|
710
|
+
hpin: i, -body_width/2 - 100, -body_height/2 + (i - 0.5) * pin_spacing, 100, display_id=false
|
|
711
|
+
label: params.refdes, body_width/2 + 20 + params.refdes_offsetx, 0 + params.refdes_offsety, fontSize=50, anchor="left", vanchor="center"
|
|
712
|
+
params:
|
|
713
|
+
refdes_offsetx: 0
|
|
714
|
+
refdes_offsety: 0
|
|
715
|
+
|
|
716
|
+
# ============================================================
|
|
717
|
+
# Test / Annotation
|
|
718
|
+
# ============================================================
|
|
719
|
+
|
|
720
|
+
def test_point():
|
|
721
|
+
# Test point — single-pin circle marker
|
|
722
|
+
return create component:
|
|
723
|
+
pins: 1
|
|
724
|
+
type: "tp"
|
|
725
|
+
display: create graphic (params):
|
|
726
|
+
circle: 0, 0, 30
|
|
727
|
+
vpin: 1, 0, 80, -50, display_id=false
|
|
728
|
+
label: params.refdes, 40 + params.refdes_offsetx, 0 + params.refdes_offsety, fontSize=50, anchor="left", vanchor="center"
|
|
729
|
+
params:
|
|
730
|
+
refdes_offsetx: 0
|
|
731
|
+
refdes_offsety: 0
|
|
732
|
+
|
|
232
733
|
def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin_y,
|
|
233
734
|
col_display_value, row_display_value, inner_frame_margin = 50):
|
|
234
735
|
|