Skip to content

Commit 18178a7

Browse files
add ground
1 parent 3aec23e commit 18178a7

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

schemascii/components_render.py

+36
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,42 @@ def transistor(
415415
make_text_point(ap, sp, **options), **options)
416416
+ bunch_o_lines(out_lines, **options))
417417

418+
419+
@component("G", "GND")
420+
@n_terminal(1)
421+
@no_ambiguous
422+
def ground(
423+
box: Cbox,
424+
terminals: list[Terminal],
425+
bom_data: BOMData,
426+
**options):
427+
"""Draw a ground symbol.
428+
bom:[{earth/chassis/signal/common}]"""
429+
icon_type = bom_data.data or "earth"
430+
points = [(0, 1j), (-.5+1j, .5+1j)]
431+
match icon_type:
432+
case "earth":
433+
points += [
434+
(-.33+1.25j, .33+1.25j),
435+
(-.16+1.5j, .16+1.5j)]
436+
case "chassis":
437+
points += [
438+
(-.5+1j, -.25+1.5j),
439+
(1j, .25+1.5j),
440+
(.5+1j, .75+1.5j)]
441+
case "signal":
442+
points += [
443+
(-.5+1j, 1.5j),
444+
(.5+1j, 1.5j)]
445+
case "common":
446+
pass
447+
case _:
448+
raise BOMError(
449+
f"Unknown ground symbol type: {icon_type}")
450+
points = deep_transform(points, terminals[0].pt, pi / 2)
451+
return bunch_o_lines(points, **options)
452+
453+
418454
# code for drawing stuff
419455
# https://github.com/pfalstad/circuitjs1/tree/master/src/com/lushprojects/circuitjs1/client
420456
# https://github.com/KenKundert/svg_schematic/blob/0abb5dc/svg_schematic.py

test_data/test1.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
!padding=30!
2-
----------L1------
2+
G3----------L1------G4
33

4-
------L2###########-------
4+
G2------L2###########-------G1
55
L1:220u
6-
L2:330u
6+
L2:330u
7+
G1:earth
8+
G2:chassis
9+
G3:signal
10+
G4:common

0 commit comments

Comments
 (0)