-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.stanza
117 lines (103 loc) · 3.51 KB
/
helpers.stanza
1
2
3
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
; ====================
; A number of helpful functions to check your designs, export to CAD,
; update your design in CAD, etc.
; ====================
#use-added-syntax(jitx)
defpackage helpers :
import core
import jitx
import jitx/commands
import jitx/parts
import jsl
; ==================
; setup-part-search
; ==================
jsl/design/settings/OPERATING-TEMPERATURE = min-max(0.0 50.0)
public var R-query
public var C-query
public defn setup-part-query (
--
vendors:Tuple<String|AuthorizedVendor> = jsl/design/settings/APPROVED-DISTRIBUTOR-LIST
) :
set-global-query-defaults!(
min-stock = 1,
mounting = "smd",
case = ["0402", "0603"],
sellers! = vendors
)
; Must instantiate after setting global defaults.
R-query = ResistorQuery(
precision = (1 %)
)
set-default-resistor-query!(R-query)
C-query = CapacitorQuery(
type = "ceramic",
temperature-coefficient_code = ["X7R", "X5R"],
precision = (10 %),
rated-voltage = AtLeast(6.0)
)
set-default-capacitor-query!(C-query)
; =================
; Setup BOM stuff
; =================
public defn setup-bill-of-materials (qty:Int, vendors:Tuple<String|AuthorizedVendor>) :
set-bom-metrics([
BOMMetric(BOMMetricLineItems, "Line Items"),
BOMMetric(BOMMetricComponentCount, "Components"),
BOMMetric(BOMMetricTotalCost, "Cost")
])
set-bom-columns([
BOMColumn(BOMFieldStatus, "Status", 10.0)
BOMColumn(BOMFieldQuantity, "Qty", 5.0)
BOMColumn(BOMFieldInsts, "References", 10.0)
BOMColumn(BOMFieldMPN, "MPN", 10.0)
BOMColumn(BOMFieldManufacturer, "Manufacturer", 10.0)
BOMColumn(BOMFieldDescription, "Description", 20.0)
BOMColumn(BOMFieldVendor, "Supplier", 10.0)
BOMColumn(BOMFieldSKU, "SKU", 10.0)
BOMColumn(BOMFieldDatasheet, "Datasheet", 10.0)
BOMColumn(BOMFieldPreferred, "Preferred", 5.0)
])
set-bom-vendors(vendors)
set-bom-design-quantity(qty)
; ====================
; Setup the board information using https://github.com/JITx-Inc/jlc-pcb.git
; ====================
public val substrate = jlc-pcb/stackups/JLC04161H-1080/JLC04161H-1080()
; ============
; setup-design
; ============
public defn setup-design (name:String, board-shape:Shape
--
signal-shrink:Double = ?
vendors:Tuple<String|AuthorizedVendor> = jsl/design/settings/APPROVED-DISTRIBUTOR-LIST
quantity:Int = jsl/design/settings/DESIGN-QUANTITY
paper-size:Paper = ANSI-A
) :
set-current-design(name)
setup-part-query(vendors = vendors)
set-board(make-board-def(substrate, board-shape, signal-shrink = signal-shrink))
set-rules(jlc-pcb/rules/multi_1oz/jlcpcb-rules-multi-1oz)
setup-bill-of-materials(quantity, vendors)
set-paper(paper-size)
set-use-layout-groups()
set-export-backend(`kicad) ; set the CAD software for export to be kicad (also supported: `altium)
; ====================
; Actual Export design
; ====================
public defn export-to-cad () :
; if we are exporting to Kicad for boards assembled at JLCPCB, we can add:
; ["vendor_part_numbers.lcsc" => "LCSC"] to the argument of export-cad()
export-cad()
; ====================
; Export design to CAD
; ====================
public defn export-design () :
set-export-board?(true)
export-to-cad()
; ===================================
; Update CAD, keeping layout progress
; ===================================
public defn update-design () :
set-export-board?(false)
export-to-cad()