5
5
from .utils import (Cbox , Terminal , BOMData , XML , Side , arrow_points ,
6
6
polylinegon , id_text , make_text_point ,
7
7
bunch_o_lines , deep_transform , make_plus , make_variable ,
8
- sort_counterclockwise , light_arrows , sort_for_flags , is_clockwise )
8
+ sort_counterclockwise , light_arrows , sort_for_flags ,
9
+ is_clockwise )
9
10
from .errors import TerminalsError , BOMError , UnsupportedComponentError
10
11
11
12
# pylint: disable=unbalanced-tuple-unpacking
@@ -309,26 +310,35 @@ def jack(
309
310
bom_data : BOMData ,
310
311
** options ):
311
312
"""Draw a jack connector or plug.
312
- bom:label"""
313
+ bom:label[,{circle/input/output}] """
313
314
scale = options ["scale" ]
314
- sc_t1 = terminals [0 ].pt * scale
315
- sc_t2 = sc_t1 + rect (scale , SIDE_TO_ANGLE_MAP [terminals [0 ].side ])
316
- sc_text_pt = sc_t2 + rect (scale * 2 , SIDE_TO_ANGLE_MAP [terminals [0 ].side ])
315
+ t1 = terminals [0 ].pt
316
+ t2 = t1 + rect (1 , SIDE_TO_ANGLE_MAP [terminals [0 ].side ])
317
+ sc_t2 = t2 * scale
318
+ sc_text_pt = sc_t2 + rect (scale , SIDE_TO_ANGLE_MAP [terminals [0 ].side ])
319
+ style = "input" if terminals [0 ].side in (
320
+ Side .LEFT , Side .TOP ) else "output"
321
+ if any (bom_data .data .endswith (x )
322
+ for x in (",circle" , ",input" , ",output" )):
323
+ style = bom_data .data .split ("," )[- 1 ]
324
+ bom_data = BOMData (bom_data .type , bom_data .id ,
325
+ bom_data .data .rstrip ("cirlenputo" )
326
+ .removesuffix ("," ))
327
+ if style == "circle" :
328
+ return (
329
+ bunch_o_lines ([(t1 , t2 )], ** options )
330
+ + XML .circle (
331
+ cx = sc_t2 .real ,
332
+ cy = sc_t2 .imag ,
333
+ r = scale / 4 ,
334
+ stroke__width = options ["stroke_width" ],
335
+ stroke = options ["stroke" ],
336
+ fill = "transparent" )
337
+ + id_text (box , bom_data , terminals , None , sc_text_pt , ** options ))
338
+ if style == "output" :
339
+ t1 , t2 = t2 , t1
317
340
return (
318
- XML .line (
319
- x1 = sc_t1 .real ,
320
- x2 = sc_t2 .real ,
321
- y1 = sc_t1 .imag ,
322
- y2 = sc_t2 .imag ,
323
- stroke__width = options ["stroke_width" ],
324
- stroke = options ["stroke" ])
325
- + XML .circle (
326
- cx = sc_t2 .real ,
327
- cy = sc_t2 .imag ,
328
- r = scale / 4 ,
329
- stroke__width = options ["stroke_width" ],
330
- stroke = options ["stroke" ],
331
- fill = "transparent" )
341
+ bunch_o_lines (arrow_points (t1 , t2 ), ** options )
332
342
+ id_text (box , bom_data , terminals , None , sc_text_pt , ** options ))
333
343
334
344
@@ -343,7 +353,8 @@ def transistor(
343
353
"""Draw a bipolar transistor (PNP/NPN) or FET (NFET/PFET).
344
354
bom:{npn/pnp/nfet/pfet}:part-number
345
355
flags:s=source,d=drain,g=gate,e=emitter,c=collector,b=base"""
346
- if not any (bom_data .data .lower ().startswith (x ) for x in ("pnp:" , "npn:" , "nfet:" , "pfet:" )):
356
+ if not any (bom_data .data .lower ().startswith (x ) for x in (
357
+ "pnp:" , "npn:" , "nfet:" , "pfet:" )):
347
358
raise BOMError (
348
359
f"Need type of transistor for { box .type } { box .id } " )
349
360
silicon_type , part_num = bom_data .data .split (":" )
@@ -380,7 +391,8 @@ def transistor(
380
391
arr = arr [1 ], arr [0 ]
381
392
out_lines .extend ([
382
393
* arrow_points (* arr ),
383
- (mid - rect (.8 , theta ), mid - rect (.8 , theta ) + rect (.7 , thetaquarter )),
394
+ (mid - rect (.8 , theta ), mid - rect (.8 , theta )
395
+ + rect (.7 , thetaquarter )),
384
396
(mid + rect (1 , theta ) + rect (.7 , thetaquarter ),
385
397
mid - rect (1 , theta ) + rect (.7 , thetaquarter )),
386
398
(mid + rect (.5 , theta ) + rect (1 , thetaquarter ),
@@ -393,7 +405,8 @@ def transistor(
393
405
arr = arr [1 ], arr [0 ]
394
406
out_lines .extend ([
395
407
* arrow_points (* arr ),
396
- (mid - rect (.8 , theta ), mid - rect (.4 , theta ) + rect (1 , thetaquarter )),
408
+ (mid - rect (.8 , theta ), mid - rect (.4 , theta )
409
+ + rect (1 , thetaquarter )),
397
410
(mid + rect (1 , theta ) + rect (1 , thetaquarter ),
398
411
mid - rect (1 , theta ) + rect (1 , thetaquarter )),
399
412
])
@@ -412,7 +425,7 @@ def transistor(
412
425
# + is on the top unless otherwise noted
413
426
# terminals will be connected at (0, -1) and (0, 1) relative to the paths here
414
427
# if they aren't the path will be transformed
415
- twoterminals = {
428
+ {
416
429
# fuse
417
430
'F' : 'M0-.9A.1.1 0 000-1.1.1.1 0 000-.9ZM0-1Q.5-.5 0 0T0 1Q-.5.5 0 0T0-1ZM0 1.1A.1.1 0 000 .9.1.1 0 000 1.1Z' ,
418
431
# jumper pads
0 commit comments