@tscircuit/schematic-viewer 1.2.14 → 1.4.0
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/.github/workflows/chromatic.yml +30 -0
- package/.github/workflows/npm-build.yml +26 -0
- package/.github/workflows/npm-typecheck.yml +26 -0
- package/README.md +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +690 -664
- package/dist/index.js.map +1 -1
- package/package.json +21 -12
- package/renovate.json +12 -1
- package/src/Schematic.tsx +148 -77
- package/src/lib/types/core.ts +14 -49
- package/src/lib/types/source-component.ts +6 -0
- package/src/lib/utils/collect-element-refs.ts +4 -3
- package/src/lib/utils/colors.ts +236 -0
- package/src/schematic-components/SVGPathComponent.tsx +84 -144
- package/src/schematic-components/SchematicChip.tsx +183 -0
- package/src/schematic-components/SchematicComponent.tsx +18 -24
- package/src/schematic-components/SchematicComponentFromSymbol.tsx +44 -0
- package/src/schematic-components/SchematicElement.tsx +4 -38
- package/src/schematic-components/SchematicTrace.tsx +4 -3
- package/src/schematic-components/index.tsx +7 -14
- package/src/stories/basics/schematic-net-label.stories.tsx +112 -166
- package/src/stories/basics/schematic-net-labels-2.stories.tsx +22 -20
- package/src/stories/bug-connections.stories.tsx +9 -6
- package/src/stories/bug-high-port-numbers.stories.tsx +99 -82
- package/src/stories/bug-pin-spacing.stories.tsx +1 -0
- package/src/stories/bugs/bug1-y-flip.stories.tsx +3 -2
- package/src/stories/bugs/bug3-scaling-trace.stories.tsx +11 -5
- package/src/stories/bugs/bug4-schematic-line.stories.tsx +0 -1
- package/src/stories/bugs/bug5-diode.stories.tsx +0 -1
- package/src/stories/bugs/bug8-autolayout.stories.tsx +22 -31
- package/src/stories/circuit-components/diode.stories.tsx +3 -1
- package/src/stories/circuit-components/resistor.stories.tsx +3 -1
- package/src/stories/component-drawing-example.stories.tsx +2 -2
- package/src/stories/led-circuit-react.stories.tsx +40 -45
- package/src/stories/net-alias.stories.tsx +1 -1
- package/src/stories/off-center-render.stories.tsx +6 -6
- package/src/stories/rotated-resistor.stories.tsx +1 -1
- package/src/stories/schematic-path.stories.tsx +1 -1
- package/src/stories/three-sided-bug.stories.tsx +8 -8
- package/src/pages/led-circuit.tsx +0 -96
- package/src/schematic-components/ProjectComponent.tsx +0 -70
- package/src/schematic-components/SchematicBox.tsx +0 -29
- package/src/schematic-components/SchematicBug.tsx +0 -90
- package/src/schematic-components/SchematicLine.tsx +0 -48
- package/src/schematic-components/SchematicPath.tsx +0 -51
- package/src/schematic-components/SchematicPort.tsx +0 -63
- package/src/schematic-components/SimpleCapacitor.tsx +0 -29
- package/src/schematic-components/SimpleDiode.tsx +0 -42
- package/src/schematic-components/SimpleGround.tsx +0 -30
- package/src/schematic-components/SimpleInductor.tsx +0 -29
- package/src/schematic-components/SimplePowerSource.tsx +0 -43
- package/src/schematic-components/SimpleResistor.tsx +0 -28
- package/src/stories/led-circuit-builder.stories.tsx +0 -104
|
@@ -1,79 +1,99 @@
|
|
|
1
|
+
import { Circuit } from "@tscircuit/core"
|
|
1
2
|
import { Schematic } from "Schematic"
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
4
|
+
export const BugHighPortNumbers = () => {
|
|
5
|
+
const circuit = new Circuit()
|
|
6
|
+
|
|
7
|
+
circuit.add(
|
|
8
|
+
<group>
|
|
9
|
+
<chip
|
|
10
|
+
name="U1"
|
|
11
|
+
manufacturerPartNumber="part-number"
|
|
12
|
+
schPortArrangement={{
|
|
13
|
+
leftSide: {
|
|
14
|
+
pins: [16, 15, 20, 17, 4, 27, 28, 19, 26, 25, 7, 18, 21],
|
|
15
|
+
direction: "top-to-bottom",
|
|
16
|
+
},
|
|
17
|
+
rightSide: {
|
|
18
|
+
pins: [1, 5, 11, 3, 2, 9, 10, 6, 23, 22, 14, 13, 12],
|
|
19
|
+
direction: "top-to-bottom",
|
|
20
|
+
},
|
|
21
|
+
}}
|
|
22
|
+
schWidth={1}
|
|
23
|
+
footprint="ssop28Db"
|
|
24
|
+
pinLabels={{
|
|
25
|
+
"1": "TXD",
|
|
26
|
+
"5": "RXD",
|
|
27
|
+
"11": "CTS",
|
|
28
|
+
"3": "RTS",
|
|
29
|
+
"2": "DTR",
|
|
30
|
+
"9": "DSR",
|
|
31
|
+
"10": "DCD",
|
|
32
|
+
"6": "RI",
|
|
33
|
+
"23": "TXLED",
|
|
34
|
+
"22": "RXLED",
|
|
35
|
+
"14": "PWRUN",
|
|
36
|
+
"13": "TXDEN",
|
|
37
|
+
"12": "SLEEP",
|
|
38
|
+
"16": "USBDM",
|
|
39
|
+
"15": "USBDP",
|
|
40
|
+
"20": "VCC",
|
|
41
|
+
"17": "3V3OUT",
|
|
42
|
+
"4": "VCCIO",
|
|
43
|
+
"27": "OSCI",
|
|
44
|
+
"28": "OSCO",
|
|
45
|
+
"19": "RESET",
|
|
46
|
+
"26": "TEST",
|
|
47
|
+
"25": "AGND",
|
|
48
|
+
"7": "GND7",
|
|
49
|
+
"18": "GND18",
|
|
50
|
+
"21": "GND21",
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
<resistor
|
|
54
|
+
resistance="1kohm"
|
|
55
|
+
name="R1"
|
|
56
|
+
footprint="0805"
|
|
57
|
+
schX={3}
|
|
58
|
+
schY={0}
|
|
59
|
+
symbolName="boxresistor_vert"
|
|
60
|
+
/>
|
|
61
|
+
<resistor
|
|
62
|
+
resistance="1kohm"
|
|
63
|
+
name="R2"
|
|
64
|
+
footprint="0805"
|
|
65
|
+
schX={4.5}
|
|
66
|
+
schY={0}
|
|
67
|
+
symbolName="boxresistor_vert"
|
|
68
|
+
/>
|
|
69
|
+
<diode
|
|
70
|
+
name="LED1"
|
|
71
|
+
footprint="0805"
|
|
72
|
+
symbolName="diode_vert"
|
|
73
|
+
schX={3}
|
|
74
|
+
schY={3}
|
|
75
|
+
/>
|
|
76
|
+
<diode
|
|
77
|
+
name="LED2"
|
|
78
|
+
footprint="0805"
|
|
79
|
+
symbolName="diode_vert"
|
|
80
|
+
schX={4.5}
|
|
81
|
+
schY={3}
|
|
82
|
+
/>
|
|
83
|
+
<netalias net="5V" schX={3} schY={-2} />
|
|
84
|
+
<netalias net="5V" schX={4.5} schY={-2} />
|
|
85
|
+
{/* <trace path={[".5V", ".R2 > port.left"]} />
|
|
86
|
+
<trace path={[".5V", ".R1 > port.left"]} /> */}
|
|
87
|
+
<trace path={[".R1 > port.right", ".LED1 > port.left"]} />
|
|
88
|
+
<trace path={[".R2 > port.right", ".LED2 > port.left"]} />
|
|
89
|
+
<trace path={[".LED1 > port.right", ".U1 > .pin1"]} />
|
|
90
|
+
<trace path={[".LED2 > port.right", ".U1 > .RXLED"]} />
|
|
91
|
+
<netalias net="GND" schX={-3} schY={4} schRotation="180deg" />
|
|
92
|
+
<netalias net="GND" schX={-5} schY={3} schRotation="180deg" />
|
|
93
|
+
<netalias net="GND" schX={-6} schY={3} schRotation="180deg" />
|
|
94
|
+
<netalias net="GND" schX={-7} schY={3} schRotation="180deg" />
|
|
95
|
+
<netalias net="GND" schX={-8} schY={2} schRotation="180deg" />
|
|
96
|
+
{/* <component>
|
|
77
97
|
<schematicbox
|
|
78
98
|
name="USB"
|
|
79
99
|
center={[-9, 0]}
|
|
@@ -83,15 +103,12 @@ const FTDIBasic3v3 = () => (
|
|
|
83
103
|
height={2}
|
|
84
104
|
/>
|
|
85
105
|
</component> */}
|
|
86
|
-
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
export const BugHighPortNumbers = () => {
|
|
90
|
-
return (
|
|
91
|
-
<Schematic style={{ height: 600 }}>
|
|
92
|
-
<FTDIBasic3v3 />
|
|
93
|
-
</Schematic>
|
|
106
|
+
</group>,
|
|
94
107
|
)
|
|
108
|
+
|
|
109
|
+
const circuitJson = circuit.getCircuitJson()
|
|
110
|
+
|
|
111
|
+
return <Schematic soup={circuitJson as any} style={{ height: 600 }} />
|
|
95
112
|
}
|
|
96
113
|
|
|
97
114
|
export default {
|
|
@@ -4,8 +4,9 @@ export const Bug1YFlip = () => {
|
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 600 }}>
|
|
6
6
|
<bug
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
name="U1"
|
|
8
|
+
schPortArrangement={{ topSize: 2 }}
|
|
9
|
+
pinLabels={{ 1: "foo", 2: "baz" }}
|
|
9
10
|
/>
|
|
10
11
|
</Schematic>
|
|
11
12
|
)
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { useResistor } from "@tscircuit/react-fiber"
|
|
2
1
|
import { Schematic } from "../../Schematic"
|
|
3
2
|
|
|
4
3
|
export const Bug3ScalingTrace = () => {
|
|
5
|
-
const R1 = useResistor("R1", { resistance: "10" })
|
|
6
|
-
const R2 = useResistor("R2", { resistance: "1k" })
|
|
7
4
|
return (
|
|
8
5
|
<Schematic style={{ height: 500 }}>
|
|
9
|
-
<
|
|
10
|
-
|
|
6
|
+
<board width={"10mm"} height={"10mm"} pcbX={0} pcbY={0}>
|
|
7
|
+
<resistor name="R1" resistance="10" schX={2} schY={1} />
|
|
8
|
+
<resistor
|
|
9
|
+
name="R2"
|
|
10
|
+
resistance="1k"
|
|
11
|
+
schX={0}
|
|
12
|
+
schY={3}
|
|
13
|
+
symbolName="boxresistor_vert"
|
|
14
|
+
/>
|
|
15
|
+
<trace path={[".R1 > port.right", ".R2 > port.left"]} />
|
|
16
|
+
</board>
|
|
11
17
|
</Schematic>
|
|
12
18
|
)
|
|
13
19
|
}
|
|
@@ -1,45 +1,36 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
1
|
import { layout } from "@tscircuit/layout"
|
|
3
|
-
import {
|
|
2
|
+
import { Schematic } from "../../Schematic"
|
|
4
3
|
|
|
5
4
|
export const Bug8Autolayout = () => {
|
|
6
|
-
const U1 = useBug("U1", {
|
|
7
|
-
pinLabels: {
|
|
8
|
-
1: "VCC",
|
|
9
|
-
2: "D0",
|
|
10
|
-
3: "D1",
|
|
11
|
-
4: "GND",
|
|
12
|
-
5: "INP",
|
|
13
|
-
6: "THR",
|
|
14
|
-
},
|
|
15
|
-
schPortArrangement: {
|
|
16
|
-
leftSize: 3,
|
|
17
|
-
topSize: 0,
|
|
18
|
-
bottomSize: 0,
|
|
19
|
-
rightSize: 3,
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const R1 = useResistor("R1", { resistance: "10k" })
|
|
24
|
-
const R2 = useResistor("R2", { resistance: "1k" })
|
|
25
|
-
const R3 = useResistor("R3", { resistance: "5k" })
|
|
26
|
-
const C1 = useCapacitor("C1", { capacitance: "1uF" })
|
|
27
|
-
|
|
28
5
|
return (
|
|
29
6
|
<div>
|
|
30
7
|
<Schematic style={{ height: 500 }}>
|
|
31
8
|
<board
|
|
32
9
|
layout={layout().autoLayoutSchematic()}
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
pcbX={0}
|
|
11
|
+
pcbY={0}
|
|
35
12
|
width={"10mm"}
|
|
36
13
|
height={"10mm"}
|
|
37
14
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
<bug
|
|
16
|
+
name="U1"
|
|
17
|
+
schX={0}
|
|
18
|
+
schY={0}
|
|
19
|
+
schPortArrangement={{
|
|
20
|
+
leftSize: 3,
|
|
21
|
+
topSize: 0,
|
|
22
|
+
bottomSize: 0,
|
|
23
|
+
rightSize: 3,
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
<resistor name="R1" resistance="10k" schX={0} schY={1} />
|
|
27
|
+
<resistor name="R2" resistance="1k" schX={0} schY={3} />
|
|
28
|
+
<resistor name="R3" resistance="5k" schX={2} schY={1} />
|
|
29
|
+
<capacitor name="C1" capacitance="1uF" schX={2} schY={3} />
|
|
30
|
+
<trace path={[".R1 > port.right", ".R2 > port.left"]} />
|
|
31
|
+
<trace path={[".R2 > port.right", ".R3 > port.left"]} />
|
|
32
|
+
<trace path={[".R3 > port.right", ".C1 > port.left"]} />
|
|
33
|
+
<trace path={[".C1 > port.right", ".R1 > port.left"]} />
|
|
43
34
|
</board>
|
|
44
35
|
</Schematic>
|
|
45
36
|
</div>
|
|
@@ -3,7 +3,9 @@ import { Schematic } from "../../Schematic"
|
|
|
3
3
|
export const Diode = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<diode name="D1" schX={2} schY={1} />
|
|
8
|
+
</board>
|
|
7
9
|
</Schematic>
|
|
8
10
|
)
|
|
9
11
|
}
|
|
@@ -3,7 +3,9 @@ import { Schematic } from "../../Schematic"
|
|
|
3
3
|
export const Resistor = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<resistor name="R1" resistance="10 ohm" schX={2} schY={1} />
|
|
8
|
+
</board>
|
|
7
9
|
</Schematic>
|
|
8
10
|
)
|
|
9
11
|
}
|
|
@@ -3,8 +3,8 @@ import { Schematic } from "Schematic"
|
|
|
3
3
|
export const ComponentDrawingExample = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 600 }}>
|
|
6
|
-
<component>
|
|
7
|
-
<schematicbox
|
|
6
|
+
<component name={"C1"}>
|
|
7
|
+
<schematicbox schX={0} schY={0} width="6mm" height="6mm" />
|
|
8
8
|
<schematicline x1={0} y1={0} x2={1} y2={1} />
|
|
9
9
|
</component>
|
|
10
10
|
</Schematic>
|
|
@@ -3,51 +3,46 @@ import { Schematic } from "../Schematic"
|
|
|
3
3
|
export const LEDCircuitReact = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
path={["
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<trace path={[".D1 > port.left", ".B1 > .RG"]} />
|
|
47
|
-
{/* <trace from=".D1 > .left" to=".B1 > .RG" /> */}
|
|
48
|
-
{/* <trace from=".D1 > .right" to=".C1> .right" /> */}
|
|
49
|
-
<netalias center={["10mm", "1.5mm"]} net="D0BUS" />
|
|
50
|
-
<trace path={[".B1 > .D0", ".D0BUS"]} />
|
|
6
|
+
<group>
|
|
7
|
+
<resistor name="R1" resistance="10 ohm" schX={2} schY={1}/>
|
|
8
|
+
<capacitor
|
|
9
|
+
name="C1"
|
|
10
|
+
capacitance="10 uF"
|
|
11
|
+
schX={4}
|
|
12
|
+
schY={2}
|
|
13
|
+
symbolName="capacitor_vert"
|
|
14
|
+
/>
|
|
15
|
+
<resistor
|
|
16
|
+
name="R2"
|
|
17
|
+
resistance="10 ohm"
|
|
18
|
+
schX={6}
|
|
19
|
+
schY={1}
|
|
20
|
+
/>
|
|
21
|
+
<trace path={[".R1 > port.right", ".C1 > port.left"]} />
|
|
22
|
+
<trace path={[".C1 > port.right", ".R2 > port.left"]} />
|
|
23
|
+
<powersource voltage={5} schX={1} schY={2} name="main_power" />
|
|
24
|
+
<trace path={[".main_power > port.positive", ".R1 > port.left"]} />
|
|
25
|
+
<trace path={[".main_power > port.negative", ".C1 > port.right"]} />
|
|
26
|
+
<trace path={[".C1 > port.right", ".R2 > port.right"]} />
|
|
27
|
+
<bug
|
|
28
|
+
name="B1"
|
|
29
|
+
schPortArrangement={{
|
|
30
|
+
leftSide: { pins: [3, 2, 1], direction: "top-to-bottom" },
|
|
31
|
+
rightSide: { pins: [6, 5, 4], direction: "top-to-bottom" },
|
|
32
|
+
}}
|
|
33
|
+
// schWidth={4}
|
|
34
|
+
schX={8}
|
|
35
|
+
schY={3}
|
|
36
|
+
pinLabels={{
|
|
37
|
+
1: "PWR",
|
|
38
|
+
2: "NC",
|
|
39
|
+
3: "RG",
|
|
40
|
+
4: "D0",
|
|
41
|
+
5: "D1",
|
|
42
|
+
6: "GND",
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</group>
|
|
51
46
|
</Schematic>
|
|
52
47
|
)
|
|
53
48
|
}
|
|
@@ -7,13 +7,13 @@ export const OffCenterRendering = () => {
|
|
|
7
7
|
<Schematic style={{ height: 600 }}>
|
|
8
8
|
<bug
|
|
9
9
|
name="B1"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
schPortArrangement={{
|
|
11
|
+
leftSide: { pins: [3, 2, 1], direction: "top-to-bottom" },
|
|
12
|
+
rightSide: { pins: [6, 5, 4], direction: "top-to-bottom" },
|
|
13
13
|
}}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
schX={8}
|
|
15
|
+
schY={3}
|
|
16
|
+
pinLabels={{
|
|
17
17
|
"1": "D0",
|
|
18
18
|
"2": "D1",
|
|
19
19
|
}}
|
|
@@ -5,15 +5,15 @@ export const ThreeSidedBug = () => {
|
|
|
5
5
|
<Schematic style={{ height: 600 }}>
|
|
6
6
|
<bug
|
|
7
7
|
name="B1"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
schPortArrangement={{
|
|
9
|
+
leftSize: 3,
|
|
10
|
+
rightSize: 3,
|
|
11
|
+
topSize: 0,
|
|
12
|
+
bottomSize: 5,
|
|
13
13
|
}}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
schX={8}
|
|
15
|
+
schY={3}
|
|
16
|
+
pinLabels={{
|
|
17
17
|
"1": "D0",
|
|
18
18
|
"2": "D1",
|
|
19
19
|
}}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { createProjectBuilder } from "@tscircuit/builder"
|
|
2
|
-
import { useMaybePromise } from "lib/hooks"
|
|
3
|
-
import { Schematic } from "../Schematic"
|
|
4
|
-
|
|
5
|
-
const pb = createProjectBuilder()
|
|
6
|
-
const $elements = pb
|
|
7
|
-
.addGroup((gb) =>
|
|
8
|
-
gb
|
|
9
|
-
.addResistor((rb) =>
|
|
10
|
-
rb
|
|
11
|
-
.setSourceProperties({
|
|
12
|
-
resistance: "10 ohm",
|
|
13
|
-
name: "R1",
|
|
14
|
-
})
|
|
15
|
-
.setSchematicCenter(2, 1)
|
|
16
|
-
)
|
|
17
|
-
.addCapacitor((cb) =>
|
|
18
|
-
cb
|
|
19
|
-
.setSourceProperties({
|
|
20
|
-
name: "C1",
|
|
21
|
-
capacitance: "10 uF",
|
|
22
|
-
})
|
|
23
|
-
.setSchematicCenter(4, 2)
|
|
24
|
-
.setSchematicRotation("90deg")
|
|
25
|
-
)
|
|
26
|
-
.addResistor((cb) =>
|
|
27
|
-
cb
|
|
28
|
-
.setSourceProperties({
|
|
29
|
-
resistance: "10 ohm",
|
|
30
|
-
name: "R2",
|
|
31
|
-
})
|
|
32
|
-
.setSchematicCenter(6, 1)
|
|
33
|
-
.setSchematicRotation("90deg")
|
|
34
|
-
)
|
|
35
|
-
.addTrace([".R1 > port.right", ".C1 > port.left", ".R2 > port.left"])
|
|
36
|
-
.addPowerSource((cb) =>
|
|
37
|
-
cb
|
|
38
|
-
.setSourceProperties({
|
|
39
|
-
voltage: "5V",
|
|
40
|
-
name: "main_power",
|
|
41
|
-
})
|
|
42
|
-
.setSchematicCenter(1, 2)
|
|
43
|
-
)
|
|
44
|
-
.addTrace(["power > port.positive", ".R1 > port.left"])
|
|
45
|
-
.addTrace([
|
|
46
|
-
"power > port.negative",
|
|
47
|
-
".C1 > port.right",
|
|
48
|
-
".R2 > port.right",
|
|
49
|
-
])
|
|
50
|
-
.addBug((cb) =>
|
|
51
|
-
cb
|
|
52
|
-
.setSourceProperties({ name: "B1" })
|
|
53
|
-
.setSchematicProperties({
|
|
54
|
-
port_arrangement: {
|
|
55
|
-
left_size: 3,
|
|
56
|
-
right_size: 3,
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
.labelPort(1, "PWR")
|
|
60
|
-
.labelPort(2, "NC")
|
|
61
|
-
.labelPort(3, "RG")
|
|
62
|
-
.labelPort(4, "D0")
|
|
63
|
-
.labelPort(5, "D1")
|
|
64
|
-
.labelPort(6, "GND")
|
|
65
|
-
.setSchematicCenter(8, 3)
|
|
66
|
-
)
|
|
67
|
-
.addTrace([".B1 > port.PWR", ".R2 > port.left"])
|
|
68
|
-
.addGround((cb) =>
|
|
69
|
-
cb
|
|
70
|
-
.setSourceProperties({
|
|
71
|
-
name: "GND",
|
|
72
|
-
})
|
|
73
|
-
.setSchematicCenter(11, 3)
|
|
74
|
-
)
|
|
75
|
-
.addTrace([".B1 > port.GND", ".gnd"])
|
|
76
|
-
.addDiode((db) =>
|
|
77
|
-
db
|
|
78
|
-
.setSourceProperties({ name: "D1" })
|
|
79
|
-
.setSchematicCenter(6, 3.5)
|
|
80
|
-
.setSchematicRotation("180deg")
|
|
81
|
-
)
|
|
82
|
-
.addTrace([".D1 > .left", ".B1 > .RG"])
|
|
83
|
-
.addTrace([".D1 > .right", ".C1 > .right"])
|
|
84
|
-
)
|
|
85
|
-
.build(pb.createBuildContext())
|
|
86
|
-
|
|
87
|
-
export default () => {
|
|
88
|
-
const elements = useMaybePromise($elements)
|
|
89
|
-
if (!elements) return null
|
|
90
|
-
return (
|
|
91
|
-
<>
|
|
92
|
-
<Schematic style={{ height: 400 }} elements={elements} />
|
|
93
|
-
<pre>{JSON.stringify(elements, null, " ")}</pre>
|
|
94
|
-
</>
|
|
95
|
-
)
|
|
96
|
-
}
|