circuitscript 0.0.7 → 0.0.13

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.
@@ -42,6 +42,10 @@ def solder_bridge():
42
42
  return create component:
43
43
  pins: 2
44
44
 
45
+ gnd = dgnd()
46
+ v3v3 = supply("3V3")
47
+ v5v = supply("5V")
48
+
45
49
  atmega = create component:
46
50
  pins:
47
51
  1: "XTAL1"
@@ -189,7 +193,7 @@ at atmega:
189
193
  wire left 40
190
194
  branch:
191
195
  wire up 20
192
- to net("5V")
196
+ to v5v
193
197
  wire down 20
194
198
  branch:
195
199
  wire auto
@@ -223,7 +227,7 @@ at atmega:
223
227
  to icsp_conn2 pin 5
224
228
 
225
229
  branch:
226
- at net("5V")
230
+ at v5v
227
231
  wire down 20 left 20
228
232
  to icsp_conn2 pin 2
229
233
  point tmp4
@@ -393,19 +397,19 @@ at atmega:
393
397
  wire right 40
394
398
  add label("RXLED")
395
399
  wire right 100 down 100 right 60
396
- add led("yellow") pin 1 ..angle=180
400
+ add led("yellow") pin 2 right
397
401
  wire right 20
398
402
  add res(1k)
399
403
  wire right 20 up 80
400
404
  point tmp6
401
405
  wire up 20
402
- to net("5V")
406
+ to v5v
403
407
 
404
408
  11:
405
409
  wire right 40
406
410
  add label("TXLED")
407
411
  wire right 120 down 40 right 40
408
- add led("yellow") pin 1 ..angle=180
412
+ add led("yellow") pin 2 right
409
413
  wire right 20
410
414
  add res(1k)
411
415
  wire auto
@@ -419,11 +423,11 @@ power_conn2 = create component:
419
423
 
420
424
  at power_conn2:
421
425
  2:
422
- wire left 40
423
- add label("3V3")
426
+ wire left 60 up 80
427
+ add v3v3
424
428
  3:
425
- wire left 80 up 100
426
- to net("5V")
429
+ wire left 100 up 100
430
+ to v5v
427
431
 
428
432
  4:
429
433
  wire left 20 down 20
@@ -446,7 +450,7 @@ at atmega8:
446
450
  wire up 20
447
451
  add res(10k) pin 2 ..angle=90
448
452
  wire up 20
449
- to net("5V")
453
+ to v5v
450
454
  branch:
451
455
  wire left 40 up 420 right 120
452
456
  to power_conn2 pin 1
@@ -482,7 +486,7 @@ at atmega8:
482
486
  wire left 40
483
487
  branch:
484
488
  wire up 20
485
- to net("5V")
489
+ to v5v
486
490
  wire down 20
487
491
  add cap(100n)
488
492
  wire down 20
@@ -626,7 +630,7 @@ at icsp_conn:
626
630
  to gnd
627
631
  2:
628
632
  wire right 20 up 20
629
- to net("5V")
633
+ to v5v
630
634
 
631
635
  5:
632
636
  wire left 140
@@ -649,23 +653,6 @@ at icsp_conn:
649
653
  to gnd
650
654
 
651
655
 
652
- # Block for 5V leds
653
- at net("5V")
654
- wire down 20
655
- branch:
656
- wire right 20
657
- add res(1k)
658
- wire right 20
659
- point tmp9
660
- wire right 20
661
- add led("green") pin 2
662
- wire right 20 down 20
663
- to gnd
664
- wire down 40 right 20
665
- add res(1k)
666
- wire auto_
667
- to tmp9
668
-
669
656
  # 3V3 output converter
670
657
  dcdc_3v3 = create component:
671
658
  pins:
@@ -724,123 +711,157 @@ fet = create component:
724
711
  param:
725
712
  manufacturer_pn: "FDN304V"
726
713
 
727
- at label("VIN")
728
- wire right 40 down 20
729
- add res(10k) ..angle=90
730
- wire down 20
731
- branch:
732
- wire down 20
733
- add res(10k) ..angle=90
734
- to gnd
735
- wire right 80
736
- add label("CMP")
737
- wire right 20
738
- to opamp_1 pin 3
739
-
740
- at label("3V3")
741
- wire right 40
742
- to opamp_1 pin 2
743
-
744
- at label("USBVCC")
745
- wire right 40 to fet pin 1
746
-
747
- at opamp_1 pin 1
748
- wire right 80 down 100 left 20
749
- to fet pin 2
750
-
751
- at fet pin 3
752
- wire right 60
753
- branch:
754
- wire up 20
755
- to net("5V")
756
- wire right 60
757
- branch:
758
- wire right 20
759
- to dcdc_3v3 pin 1
760
- wire auto_
761
- to dcdc_3v3 pin 3
762
-
763
- at dcdc_3v3:
764
- 2:
765
- wire left 20 down 20
766
- to gnd
767
-
768
- 5:
769
- wire right 20
770
- add label("3V3")
771
- wire right 20 down 20
772
- add cap(1u)
773
- to gnd
774
-
775
-
776
-
777
- # Block for 5V power
778
- power_conn = create component:
779
- pins: 3
780
- arrange:
781
- left: 1,3
782
- right: 2
783
-
784
- at power_conn:
785
- 1:
786
- wire left 20 down 20
787
- branch:
788
- wire auto
789
- to power_conn pin 3
714
+ frame:
715
+ ..title = "Supply generation"
716
+ ..direction = "row"
717
+
718
+ frame:
719
+ ..title = "3V3 power"
720
+
721
+ at label("VIN")
722
+ wire right 40 down 20
723
+ add res(10k) ..angle=90
790
724
  wire down 20
791
- to gnd
792
- 2:
793
- wire right 20
794
- add label("PWRIN")
795
- wire right 40
796
- add diode()
797
- wire right 40
798
725
  branch:
799
726
  wire down 20
800
- add cap(47u)
727
+ add res(10k) ..angle=90
801
728
  to gnd
729
+ wire right 80
730
+ add label("CMP")
802
731
  wire right 20
803
- point tmp10
732
+ to opamp_1 pin 3
804
733
 
805
- at dcdc_5V:
806
- 1:
807
- wire left 20 down 20
808
- to gnd
809
- 3:
810
- wire left 80
811
- to tmp10
734
+ at v3v3 left
735
+ wire right 20
736
+ to opamp_1 pin 2
812
737
 
813
- wire up 20
814
- branch:
815
- wire right 20
816
- add label("VIN")
817
- wire right 40
818
- wire up 100 right 80
819
- to dcdc_5V_2 pin 3
820
- 2:
821
- wire right 40
822
- point tmp11
738
+ at label("USBVCC")
739
+ wire right 40 to fet pin 1
740
+
741
+ at opamp_1 pin 1
742
+ wire right 80 down 100 left 20
743
+ to fet pin 2
744
+
745
+ at fet pin 3
746
+ wire right 60
823
747
  branch:
824
- wire down 20
825
- add cap(47u)
826
- to gnd
748
+ wire up 20
749
+ to v5v
827
750
  wire right 60
828
751
  branch:
829
- wire down 20
830
- add cap(100n)
831
- to gnd
832
- wire right 20 up 20
833
- to net("5V")
834
-
752
+ wire right 20
753
+ to dcdc_3v3 pin 1
754
+ wire auto_
755
+ to dcdc_3v3 pin 3
756
+
757
+ at dcdc_3v3:
758
+ 2:
759
+ wire left 20 down 20
760
+ to gnd
761
+
762
+ 5:
763
+ wire right 40
764
+ branch:
765
+ wire up 20
766
+ to v3v3
767
+ wire down 20
768
+ add cap(1u)
769
+ to gnd
770
+
835
771
 
836
- at dcdc_5V_2:
837
- 1:
838
- wire left 20 down 20
839
- to gnd
840
- 4:
841
- wire right 20 down 20
842
- branch:
843
- wire auto
844
- to dcdc_5V_2 pin 2
845
- wire auto
846
- to tmp11
772
+ frame:
773
+ ..title = "5V power"
774
+
775
+ # Block for 5V power
776
+ power_conn = create component:
777
+ pins: 3
778
+ arrange:
779
+ left: 1,3
780
+ right: 2
781
+
782
+ at power_conn:
783
+ 1:
784
+ wire left 20 down 20
785
+ branch:
786
+ wire auto
787
+ to power_conn pin 3
788
+ wire down 20
789
+ to gnd
790
+ 2:
791
+ wire right 20
792
+ add label("PWRIN")
793
+ wire right 40
794
+ add diode()
795
+ wire right 40
796
+ branch:
797
+ wire down 20
798
+ add cap(47u)
799
+ to gnd
800
+ wire right 20
801
+ point tmp10
802
+
803
+ at dcdc_5V:
804
+ 1:
805
+ wire left 20 down 20
806
+ to gnd
807
+ 3:
808
+ wire left 80
809
+ to tmp10
810
+
811
+ wire up 20
812
+ branch:
813
+ wire right 20
814
+ add label("VIN")
815
+ wire right 40
816
+ wire up 100 right 80
817
+ to dcdc_5V_2 pin 3
818
+ 2:
819
+ wire right 40
820
+ point tmp11
821
+ branch:
822
+ wire down 20
823
+ add cap(47u)
824
+ to gnd
825
+ wire right 60
826
+ branch:
827
+ wire down 20
828
+ add cap(100n)
829
+ to gnd
830
+ wire right 20 up 20
831
+ to v5v
832
+
833
+
834
+ at dcdc_5V_2:
835
+ 1:
836
+ wire left 20 down 20
837
+ to gnd
838
+ 4:
839
+ wire right 20 down 20
840
+ branch:
841
+ wire auto
842
+ to dcdc_5V_2 pin 2
843
+ wire auto
844
+ to tmp11
845
+
846
+ frame:
847
+ ..title = "5V indication"
848
+ ..border = 0
849
+
850
+ # Block for 5V leds
851
+ at v5v
852
+ wire down 20
853
+ branch:
854
+ wire right 20
855
+ add res(1k)
856
+ wire right 20
857
+ point tmp9
858
+ wire right 20
859
+
860
+ add led("green")
861
+ wire right 20 down 20
862
+ to gnd
863
+
864
+ wire down 40 right 20
865
+ add res(1k)
866
+ wire auto_
867
+ to tmp9
package/jest.config.js ADDED
@@ -0,0 +1,23 @@
1
+ export default {
2
+ testEnvironment: 'node',
3
+ preset: 'ts-jest/presets/default-esm',
4
+ transform: {
5
+ '^.+\\.m?[tj]s?$': ['ts-jest', {
6
+ useESM: true,
7
+ diagnostics: false
8
+ }],
9
+ },
10
+ moduleNameMapper: {
11
+ '^(\\.{1,2}/.*)\\.(m)?js$': '$1',
12
+ },
13
+ testMatch: [
14
+ "<rootDir>/__tests__/test**.(ts|tsx)",
15
+ ],
16
+ coverageDirectory: 'coverage',
17
+ collectCoverageFrom: [
18
+ 'src/**/*.ts',
19
+ 'src/**/*.mts',
20
+ '!src/**/*.d.ts',
21
+ '!src/**/*.d.mts',
22
+ ],
23
+ };
package/libs/lib.cst ADDED
@@ -0,0 +1,190 @@
1
+ // Circuitscript default lib
2
+
3
+ def net(net_name):
4
+ return create component:
5
+ pins: 1
6
+ display: create graphic:
7
+ hline: -15, 0, 30
8
+ pin: 1, 0, 10, 0, 0
9
+ label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
10
+ type: "net"
11
+ params:
12
+ __is_net: 1
13
+ net_name: net_name
14
+ priority: 10
15
+
16
+ def supply(net_name):
17
+ return create component:
18
+ pins: 1
19
+ display: create graphic:
20
+ hline: -15, 0, 30
21
+ pin: 1, 0, 10, 0, 0
22
+ label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
23
+ type: "net"
24
+ params:
25
+ __is_net: 1
26
+ net_name: net_name
27
+ priority: 20
28
+
29
+ def label(value):
30
+ return create component:
31
+ pins: 1
32
+ display: create graphic:
33
+ label: "value", 0, -2, fontSize=10, anchor="left"
34
+ pin: 1, 0, 0, 0, 0
35
+ type: "label"
36
+ params:
37
+ __is_net: 1
38
+ net_name: value
39
+ value: value
40
+ priority: 5
41
+
42
+ def res(value):
43
+ width = 40
44
+ height = 20
45
+
46
+ return create component:
47
+ pins: 2
48
+ display: create graphic:
49
+ rect: 0, 0, width, height
50
+ pin: 1, -width/2 - 20, 0, -width / 2, 0
51
+ pin: 2, width/2 + 20, 0, width/2, 0
52
+ label: ("value", 0, 1, value, fontSize=10, anchor="middle", vanchor="middle")
53
+ label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
54
+
55
+ type: "res"
56
+ params:
57
+ value: value
58
+ size: "0402"
59
+ footprint: "Resistor_SMD:R_0402_1005Metric"
60
+
61
+ def cap(value):
62
+ width = 20
63
+ height = 40
64
+
65
+ return create component:
66
+ pins: 2
67
+ display: create graphic:
68
+ hline: -width/2, -3, width
69
+ hline: -width/2, 3, width
70
+ pin: 1, 0, -height/2, 0, -3
71
+ pin: 2, 0, height/2, 0, 3
72
+ label: "refdes", width/2+2, 0, "?", fontSize = 10, anchor="left"
73
+ label: "value", width/2+2, 5, value, fontSize = 10, anchor = "left", vanchor="top"
74
+ type: "cap"
75
+ params:
76
+ value: value
77
+ size: "0402"
78
+ footprint: "Capacitor_SMD:C_0402_1005Metric"
79
+
80
+ def ind(value):
81
+ width = 40
82
+ height = 20
83
+
84
+ return create component:
85
+ pins: 2
86
+ type: "ind"
87
+ display: create graphic:
88
+ arc: -15, 0, 5, 180, 360
89
+ arc: -5, 0, 5, 180, 360
90
+ arc: 5, 0, 5, 180, 360
91
+ arc: 15, 0, 5, 180, 360
92
+ pin: 1, -width/2 - 20, 0, -width / 2, 0
93
+ pin: 2, width/2 + 20, 0, width/2, 0
94
+ label: ("value", 0, 10, value, fontSize=10, anchor="middle", vanchor="middle")
95
+ label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
96
+ params:
97
+ value: value
98
+
99
+ def diode():
100
+ width = 20
101
+ height = 20
102
+
103
+ # Diode is drawn horizontally
104
+ # -|>|-
105
+ return create component:
106
+ pins: 2
107
+ type: "diode"
108
+ display: create graphic:
109
+ path: ("M", width/2, -height/2, "L", width/2, height/2,
110
+ "M", -width/2, -height/2, "L", -width/2, height/2,
111
+ "L", width/2, 0, "L", -width/2, -height/2)
112
+ pin: 1, -width/2-20, 0, -width/2, 0 # anode
113
+ pin: 2, width/2 + 20, 0, width/2, 0 # cathode
114
+ label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
115
+
116
+ def led(color):
117
+ width = 20
118
+ height = 20
119
+
120
+ return create component:
121
+ pins:
122
+ 1: "cathode"
123
+ 2: "anode"
124
+ type: "diode"
125
+ display: create graphic:
126
+ path: ("M", width/2, -height/2, "L", width/2, height/2,
127
+ "M", -width/2, -height/2, "L", -width/2, height/2,
128
+ "L", width/2, 0, "L", -width/2, -height/2)
129
+ path: ("M", 0, 8, "L", 5, 18,
130
+ "M", 3, 8, "L", 8, 18)
131
+ pin: 1, -width/2-20, 0, -width/2, 0 # anode
132
+ pin: 2, width/2 + 20, 0, width/2, 0 # cathode
133
+ label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
134
+ params:
135
+ size: "0603"
136
+ footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
137
+
138
+
139
+ def cgnd():
140
+ net_name = "gnd"
141
+ return create component:
142
+ pins: 1
143
+ display: create graphic:
144
+ hline: -15, 0, 30
145
+ hline: -10, 5, 20
146
+ hline: -5, 10, 10
147
+ pin: 1, 0, -10, 0, 0
148
+ label: "net_name", 0, 22, net_name, fontSize=10, anchor="middle"
149
+ type: "net"
150
+ params:
151
+ __is_net: 1
152
+ net_name: net_name
153
+ priority: 100
154
+
155
+ def dgnd():
156
+ height = 10
157
+ width = 20
158
+
159
+ net_name = "GND"
160
+ return create component:
161
+ pins: 1
162
+ display: create graphic:
163
+ path: ("M", -width/2, 0,
164
+ "L", width/2, 0,
165
+ "L", 0, height,
166
+ "Z")
167
+ pin: 1, 0, -10, 0, 0
168
+ label: "net_name", 0, height + 10, net_name, fontSize=10, anchor="middle"
169
+ type: "net"
170
+ params:
171
+ __is_net: 1
172
+ net_name: net_name
173
+ priority: 100
174
+
175
+ def marker_point():
176
+ return create component:
177
+ pins: 1
178
+ display: create graphic:
179
+ hline: -5, 0, 10
180
+ vline: 0, -5, 10
181
+ pin: 1, 0, 0, 0, 0
182
+ type: "net"
183
+
184
+ def arrow_point():
185
+ return create component:
186
+ pins: 1
187
+ display: create graphic:
188
+ path: ("M", 15, -5, "L", 20, 0, "L", 15, 5)
189
+ pin: 1, 0, 0, 20, 0
190
+ type: "net"
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "circuitscript",
3
- "version": "0.0.7",
3
+ "version": "0.0.13",
4
4
  "description": "Interpreter for the circuitscript language",
5
+ "homepage": "https://circuitscript.net",
5
6
  "engines": {
6
7
  "node": ">=16.0"
7
8
  },
@@ -45,27 +46,6 @@
45
46
  "profile-flame": "node --prof-process --preprocess -j isolate*.log | flamebearer",
46
47
  "server": "node server.js"
47
48
  },
48
- "jest": {
49
- "preset": "ts-jest",
50
- "verbose": true,
51
- "testMatch": [
52
- "**/__tests__/test**.ts"
53
- ],
54
- "transform": {
55
- "^.+\\.tsx?$": [
56
- "ts-jest",
57
- {
58
- "diagnostics": false
59
- }
60
- ]
61
- },
62
- "collectCoverageFrom": [
63
- "src/**/*.ts"
64
- ],
65
- "coveragePathIgnorePatterns": [
66
- "src/antlr"
67
- ]
68
- },
69
49
  "boilerplate_author": "Jakub Synowiec <jsynowiec@users.noreply.github.com>",
70
50
  "license": "MIT",
71
51
  "dependencies": {
@@ -1,3 +1,5 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
1
3
  // Generated from ./src/antlr/CircuitScript.g4 by ANTLR 4.13.1
2
4
  // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
3
5
  import {
@@ -1,3 +1,5 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
1
3
  // Generated from ./src/antlr/CircuitScript.g4 by ANTLR 4.13.1
2
4
  // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
3
5
 
@@ -1,3 +1,5 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
1
3
  // Generated from ./src/antlr/CircuitScript.g4 by ANTLR 4.13.1
2
4
 
3
5
  import {ParseTreeVisitor} from 'antlr4';
@@ -160,7 +160,9 @@ export abstract class SymbolGraphic {
160
160
  let dominantBaseline = 'auto';
161
161
 
162
162
  let useAnchor = anchor;
163
- if (this.angle === 180){
163
+ const isRotation180 = Math.abs(this.angle) === 180;
164
+
165
+ if (isRotation180){
164
166
  // Special case to flip the text instead of rotating
165
167
  useAnchor = this.flipTextAnchor(anchor);
166
168
  }
@@ -194,7 +196,7 @@ export abstract class SymbolGraphic {
194
196
  }
195
197
 
196
198
  const position = tmpLabel.getLabelPosition();
197
-
199
+
198
200
  let useFont = defaultFont;
199
201
  if (fontWeight === 'bold'){
200
202
  useFont = 'Inter-Bold';
@@ -210,7 +212,7 @@ export abstract class SymbolGraphic {
210
212
  // weight: fontWeight,
211
213
  });
212
214
 
213
- if (this.angle === 180){
215
+ if (isRotation180){
214
216
  text.translate(-position[0], position[1]);
215
217
  } else {
216
218
  text.translate(position[0], position[1])