circuitscript 0.0.14 → 0.0.15
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/.gitlab-ci.yml +22 -19
- package/__tests__/helpers.ts +12 -0
- package/__tests__/renderData/script1.cst.svg +1 -1
- package/__tests__/renderData/script2.cst.svg +1 -1
- package/__tests__/renderData/script3.cst.svg +1 -1
- package/__tests__/renderData/script4.cst +27 -5
- package/__tests__/renderData/script4.cst.svg +1 -1
- package/__tests__/renderData/script5.cst.svg +1 -1
- package/__tests__/testParse.ts +37 -2
- package/build/src/draw_symbols.js +207 -63
- package/build/src/geometry.js +35 -4
- package/build/src/helpers.js +7 -3
- package/build/src/layout.js +30 -17
- package/build/src/regenerate-tests.js +1 -1
- package/build/src/visitor.js +12 -4
- package/examples/example_arduino_uno.cst +390 -120
- package/examples/lib.cst +25 -28
- package/libs/lib.cst +23 -28
- package/package.json +1 -1
- package/src/draw_symbols.ts +270 -64
- package/src/geometry.ts +46 -5
- package/src/helpers.ts +8 -5
- package/src/layout.ts +42 -21
- package/src/regenerate-tests.ts +1 -1
- package/src/visitor.ts +16 -4
package/examples/lib.cst
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
// Circuitscript default lib
|
|
2
|
+
|
|
1
3
|
def net(net_name):
|
|
2
4
|
return create component:
|
|
3
5
|
pins: 1
|
|
4
6
|
display: create graphic:
|
|
5
7
|
hline: -15, 0, 30
|
|
6
|
-
|
|
8
|
+
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
7
9
|
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
8
10
|
type: "net"
|
|
9
11
|
params:
|
|
@@ -16,7 +18,7 @@ def supply(net_name):
|
|
|
16
18
|
pins: 1
|
|
17
19
|
display: create graphic:
|
|
18
20
|
hline: -15, 0, 30
|
|
19
|
-
|
|
21
|
+
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
20
22
|
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
21
23
|
type: "net"
|
|
22
24
|
params:
|
|
@@ -28,8 +30,8 @@ def label(value):
|
|
|
28
30
|
return create component:
|
|
29
31
|
pins: 1
|
|
30
32
|
display: create graphic:
|
|
31
|
-
label: "value", 0, -2, fontSize=10, anchor="left"
|
|
32
|
-
pin: 1, 0, 0, 0, 0
|
|
33
|
+
label: "value", 0, -2, "?", fontSize=10, anchor="left"
|
|
34
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=0
|
|
33
35
|
type: "label"
|
|
34
36
|
params:
|
|
35
37
|
__is_net: 1
|
|
@@ -45,11 +47,10 @@ def res(value):
|
|
|
45
47
|
pins: 2
|
|
46
48
|
display: create graphic:
|
|
47
49
|
rect: 0, 0, width, height
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
hpin: 1, -width/2 - 20, 0, 20
|
|
51
|
+
hpin: 2, width/2 + 20, 0, -20
|
|
50
52
|
label: ("value", 0, 1, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
51
53
|
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
52
|
-
|
|
53
54
|
type: "res"
|
|
54
55
|
params:
|
|
55
56
|
value: value
|
|
@@ -65,8 +66,8 @@ def cap(value):
|
|
|
65
66
|
display: create graphic:
|
|
66
67
|
hline: -width/2, -3, width
|
|
67
68
|
hline: -width/2, 3, width
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
vpin: 1, 0, -height/2, 20-3
|
|
70
|
+
vpin: 2, 0, height/2, -20+3
|
|
70
71
|
label: "refdes", width/2+2, 0, "?", fontSize = 10, anchor="left"
|
|
71
72
|
label: "value", width/2+2, 5, value, fontSize = 10, anchor = "left", vanchor="top"
|
|
72
73
|
type: "cap"
|
|
@@ -87,8 +88,8 @@ def ind(value):
|
|
|
87
88
|
arc: -5, 0, 5, 180, 360
|
|
88
89
|
arc: 5, 0, 5, 180, 360
|
|
89
90
|
arc: 15, 0, 5, 180, 360
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
hpin: 1, -width/2 - 20, 0, 20
|
|
92
|
+
hpin: 2, width/2 + 20, 0, -20
|
|
92
93
|
label: ("value", 0, 10, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
93
94
|
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
94
95
|
params:
|
|
@@ -104,11 +105,10 @@ def diode():
|
|
|
104
105
|
pins: 2
|
|
105
106
|
type: "diode"
|
|
106
107
|
display: create graphic:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
pin: 2, width/2 + 20, 0, width/2, 0 # cathode
|
|
108
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
109
|
+
vline: width/2, -height/2, height
|
|
110
|
+
hpin: 1, -width/2-20, 0, 20 # anode
|
|
111
|
+
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
112
112
|
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
113
113
|
|
|
114
114
|
def led(color):
|
|
@@ -121,14 +121,14 @@ def led(color):
|
|
|
121
121
|
2: "anode"
|
|
122
122
|
type: "diode"
|
|
123
123
|
display: create graphic:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"L", width/2, 0, "L", -width/2, -height/2)
|
|
124
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
125
|
+
vline: width/2, -height/2, height
|
|
127
126
|
path: ("M", 0, 8, "L", 5, 18,
|
|
128
127
|
"M", 3, 8, "L", 8, 18)
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
hpin: 1, -width/2-20, 0, 20 # anode
|
|
129
|
+
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
131
130
|
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
131
|
+
label: "color", width/2 + 5, 25, color
|
|
132
132
|
params:
|
|
133
133
|
size: "0603"
|
|
134
134
|
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
@@ -142,7 +142,7 @@ def cgnd():
|
|
|
142
142
|
hline: -15, 0, 30
|
|
143
143
|
hline: -10, 5, 20
|
|
144
144
|
hline: -5, 10, 10
|
|
145
|
-
|
|
145
|
+
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
146
146
|
label: "net_name", 0, 22, net_name, fontSize=10, anchor="middle"
|
|
147
147
|
type: "net"
|
|
148
148
|
params:
|
|
@@ -158,11 +158,8 @@ def dgnd():
|
|
|
158
158
|
return create component:
|
|
159
159
|
pins: 1
|
|
160
160
|
display: create graphic:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
"L", 0, height,
|
|
164
|
-
"Z")
|
|
165
|
-
pin: 1, 0, -10, 0, 0
|
|
161
|
+
triangle: 0, 0, 0, height, width
|
|
162
|
+
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
166
163
|
label: "net_name", 0, height + 10, net_name, fontSize=10, anchor="middle"
|
|
167
164
|
type: "net"
|
|
168
165
|
params:
|
|
@@ -184,5 +181,5 @@ def arrow_point():
|
|
|
184
181
|
pins: 1
|
|
185
182
|
display: create graphic:
|
|
186
183
|
path: ("M", 15, -5, "L", 20, 0, "L", 15, 5)
|
|
187
|
-
|
|
184
|
+
hpin: 1, 0, 0, 20
|
|
188
185
|
type: "net"
|
package/libs/lib.cst
CHANGED
|
@@ -5,7 +5,7 @@ def net(net_name):
|
|
|
5
5
|
pins: 1
|
|
6
6
|
display: create graphic:
|
|
7
7
|
hline: -15, 0, 30
|
|
8
|
-
|
|
8
|
+
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
9
9
|
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
10
10
|
type: "net"
|
|
11
11
|
params:
|
|
@@ -18,7 +18,7 @@ def supply(net_name):
|
|
|
18
18
|
pins: 1
|
|
19
19
|
display: create graphic:
|
|
20
20
|
hline: -15, 0, 30
|
|
21
|
-
|
|
21
|
+
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
22
22
|
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
23
23
|
type: "net"
|
|
24
24
|
params:
|
|
@@ -30,8 +30,8 @@ def label(value):
|
|
|
30
30
|
return create component:
|
|
31
31
|
pins: 1
|
|
32
32
|
display: create graphic:
|
|
33
|
-
label: "value", 0, -2, fontSize=10, anchor="left"
|
|
34
|
-
pin: 1, 0, 0, 0, 0
|
|
33
|
+
label: "value", 0, -2, "?", fontSize=10, anchor="left"
|
|
34
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=0
|
|
35
35
|
type: "label"
|
|
36
36
|
params:
|
|
37
37
|
__is_net: 1
|
|
@@ -47,11 +47,10 @@ def res(value):
|
|
|
47
47
|
pins: 2
|
|
48
48
|
display: create graphic:
|
|
49
49
|
rect: 0, 0, width, height
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
hpin: 1, -width/2 - 20, 0, 20
|
|
51
|
+
hpin: 2, width/2 + 20, 0, -20
|
|
52
52
|
label: ("value", 0, 1, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
53
53
|
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
54
|
-
|
|
55
54
|
type: "res"
|
|
56
55
|
params:
|
|
57
56
|
value: value
|
|
@@ -67,8 +66,8 @@ def cap(value):
|
|
|
67
66
|
display: create graphic:
|
|
68
67
|
hline: -width/2, -3, width
|
|
69
68
|
hline: -width/2, 3, width
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
vpin: 1, 0, -height/2, 20-3
|
|
70
|
+
vpin: 2, 0, height/2, -20+3
|
|
72
71
|
label: "refdes", width/2+2, 0, "?", fontSize = 10, anchor="left"
|
|
73
72
|
label: "value", width/2+2, 5, value, fontSize = 10, anchor = "left", vanchor="top"
|
|
74
73
|
type: "cap"
|
|
@@ -89,8 +88,8 @@ def ind(value):
|
|
|
89
88
|
arc: -5, 0, 5, 180, 360
|
|
90
89
|
arc: 5, 0, 5, 180, 360
|
|
91
90
|
arc: 15, 0, 5, 180, 360
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
hpin: 1, -width/2 - 20, 0, 20
|
|
92
|
+
hpin: 2, width/2 + 20, 0, -20
|
|
94
93
|
label: ("value", 0, 10, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
95
94
|
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
96
95
|
params:
|
|
@@ -106,11 +105,10 @@ def diode():
|
|
|
106
105
|
pins: 2
|
|
107
106
|
type: "diode"
|
|
108
107
|
display: create graphic:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
pin: 2, width/2 + 20, 0, width/2, 0 # cathode
|
|
108
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
109
|
+
vline: width/2, -height/2, height
|
|
110
|
+
hpin: 1, -width/2-20, 0, 20 # anode
|
|
111
|
+
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
114
112
|
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
115
113
|
|
|
116
114
|
def led(color):
|
|
@@ -123,14 +121,14 @@ def led(color):
|
|
|
123
121
|
2: "anode"
|
|
124
122
|
type: "diode"
|
|
125
123
|
display: create graphic:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"L", width/2, 0, "L", -width/2, -height/2)
|
|
124
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
125
|
+
vline: width/2, -height/2, height
|
|
129
126
|
path: ("M", 0, 8, "L", 5, 18,
|
|
130
127
|
"M", 3, 8, "L", 8, 18)
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
hpin: 1, -width/2-20, 0, 20 # anode
|
|
129
|
+
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
133
130
|
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
131
|
+
label: "color", width/2 + 5, 25, color
|
|
134
132
|
params:
|
|
135
133
|
size: "0603"
|
|
136
134
|
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
@@ -144,7 +142,7 @@ def cgnd():
|
|
|
144
142
|
hline: -15, 0, 30
|
|
145
143
|
hline: -10, 5, 20
|
|
146
144
|
hline: -5, 10, 10
|
|
147
|
-
|
|
145
|
+
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
148
146
|
label: "net_name", 0, 22, net_name, fontSize=10, anchor="middle"
|
|
149
147
|
type: "net"
|
|
150
148
|
params:
|
|
@@ -160,11 +158,8 @@ def dgnd():
|
|
|
160
158
|
return create component:
|
|
161
159
|
pins: 1
|
|
162
160
|
display: create graphic:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"L", 0, height,
|
|
166
|
-
"Z")
|
|
167
|
-
pin: 1, 0, -10, 0, 0
|
|
161
|
+
triangle: 0, 0, 0, height, width
|
|
162
|
+
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
168
163
|
label: "net_name", 0, height + 10, net_name, fontSize=10, anchor="middle"
|
|
169
164
|
type: "net"
|
|
170
165
|
params:
|
|
@@ -186,5 +181,5 @@ def arrow_point():
|
|
|
186
181
|
pins: 1
|
|
187
182
|
display: create graphic:
|
|
188
183
|
path: ("M", 15, -5, "L", 20, 0, "L", 15, 5)
|
|
189
|
-
|
|
184
|
+
hpin: 1, 0, 0, 20
|
|
190
185
|
type: "net"
|