@tscircuit/footprinter 0.0.17 → 0.0.19
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/package.json +1 -1
- package/src/fn/quad.ts +115 -12
- package/src/helpers/get-quad-pin-map.ts +2 -2
- package/tests/quad.test.ts +6 -27
package/package.json
CHANGED
package/src/fn/quad.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnySoupElement } from "@tscircuit/soup"
|
|
1
|
+
import type { AnySoupElement, PcbSilkscreenPath } from "@tscircuit/soup"
|
|
2
2
|
import { z } from "zod"
|
|
3
3
|
import { length } from "@tscircuit/soup"
|
|
4
4
|
import type { NowDefined } from "../helpers/zod/now-defined"
|
|
@@ -11,7 +11,12 @@ const base_quad_def = z.object({
|
|
|
11
11
|
quad: z.literal(true),
|
|
12
12
|
cc: z.literal(true).optional(),
|
|
13
13
|
ccw: z.literal(true).optional(),
|
|
14
|
-
startingpin: z
|
|
14
|
+
startingpin: z
|
|
15
|
+
.string()
|
|
16
|
+
.or(z.array(pin_order_specifier))
|
|
17
|
+
.transform((a) => (typeof a === "string" ? a.slice(1, -1).split(",") : a))
|
|
18
|
+
.pipe(z.array(pin_order_specifier))
|
|
19
|
+
.optional(),
|
|
15
20
|
num_pins: z.number(),
|
|
16
21
|
w: length.optional(),
|
|
17
22
|
h: length.optional(),
|
|
@@ -60,15 +65,13 @@ export const getQuadCoords = (
|
|
|
60
65
|
pn: number, // pin number
|
|
61
66
|
w: number, // width of the package
|
|
62
67
|
h: number, // height (length) of the package
|
|
63
|
-
p: number // pitch between pins
|
|
68
|
+
p: number, // pitch between pins
|
|
69
|
+
pl: number // length of the pin
|
|
64
70
|
) => {
|
|
65
71
|
const sidePinCount = pinCount / 4
|
|
66
72
|
const side = SIDES_CCW[Math.floor((pn - 1) / sidePinCount)]
|
|
67
73
|
const pos = (pn - 1) % sidePinCount
|
|
68
74
|
|
|
69
|
-
const halfW = w / 2
|
|
70
|
-
const halfH = h / 2
|
|
71
|
-
|
|
72
75
|
/** inner box width */
|
|
73
76
|
const ibw = p * (sidePinCount - 1)
|
|
74
77
|
/** inner box height */
|
|
@@ -76,13 +79,13 @@ export const getQuadCoords = (
|
|
|
76
79
|
|
|
77
80
|
switch (side) {
|
|
78
81
|
case "left":
|
|
79
|
-
return { x: -
|
|
82
|
+
return { x: -w / 2 + pl / 2, y: ibh / 2 - pos * p, o: "vert" }
|
|
80
83
|
case "bottom":
|
|
81
|
-
return { x: -ibw / 2 + pos * p, y: -
|
|
84
|
+
return { x: -ibw / 2 + pos * p, y: -h / 2 + pl / 2, o: "horz" }
|
|
82
85
|
case "right":
|
|
83
|
-
return { x:
|
|
86
|
+
return { x: w / 2 - pl / 2, y: -ibh / 2 + pos * p, o: "vert" }
|
|
84
87
|
case "top":
|
|
85
|
-
return { x: ibw / 2 - pos * p, y:
|
|
88
|
+
return { x: ibw / 2 - pos * p, y: h / 2 - pl / 2, o: "horz" }
|
|
86
89
|
default:
|
|
87
90
|
throw new Error("Invalid pin number")
|
|
88
91
|
}
|
|
@@ -104,7 +107,8 @@ export const quad = (
|
|
|
104
107
|
i + 1,
|
|
105
108
|
params.w,
|
|
106
109
|
params.h,
|
|
107
|
-
params.p ?? 0.5
|
|
110
|
+
params.p ?? 0.5,
|
|
111
|
+
params.pl
|
|
108
112
|
)
|
|
109
113
|
|
|
110
114
|
let pw = params.pw
|
|
@@ -130,5 +134,104 @@ export const quad = (
|
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
|
|
137
|
+
// Silkscreen corners
|
|
138
|
+
const silkscreen_corners: PcbSilkscreenPath[] = []
|
|
139
|
+
for (let corner_index = 0; corner_index < 4; corner_index++) {
|
|
140
|
+
const dx = Math.floor(corner_index / 2) * 2 - 1
|
|
141
|
+
const dy = 1 - (corner_index % 2) * 2
|
|
142
|
+
const corner_x = (params.w / 2 - params.pl / 2) * dx
|
|
143
|
+
const corner_y = (params.h / 2 - params.pl / 2) * dy
|
|
144
|
+
let arrow: "none" | "in1" | "in2" = "none"
|
|
145
|
+
/** corner size */
|
|
146
|
+
const csz = params.pw * 2
|
|
147
|
+
if (pin_map[1] === 1 && corner_index === 0) {
|
|
148
|
+
arrow = "in1"
|
|
149
|
+
} else if (pin_map[16] === 1 && corner_index === 0) {
|
|
150
|
+
arrow = "in2"
|
|
151
|
+
}
|
|
152
|
+
if (arrow === "none") {
|
|
153
|
+
silkscreen_corners.push({
|
|
154
|
+
layer: "top",
|
|
155
|
+
pcb_component_id: "",
|
|
156
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner_index}`,
|
|
157
|
+
route: [
|
|
158
|
+
{
|
|
159
|
+
x: corner_x - csz * dx,
|
|
160
|
+
y: corner_y,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
x: corner_x,
|
|
164
|
+
y: corner_y,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
x: corner_x,
|
|
168
|
+
y: corner_y - csz * dy,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
type: "pcb_silkscreen_path",
|
|
172
|
+
})
|
|
173
|
+
} else {
|
|
174
|
+
const rotate_arrow = arrow === "in1" ? 1 : -1
|
|
175
|
+
silkscreen_corners.push(
|
|
176
|
+
{
|
|
177
|
+
layer: "top",
|
|
178
|
+
pcb_component_id: "",
|
|
179
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner_index}`,
|
|
180
|
+
route: [
|
|
181
|
+
{
|
|
182
|
+
x: corner_x - csz * dx,
|
|
183
|
+
y: corner_y,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
x: corner_x - (csz * dx) / 2,
|
|
187
|
+
y: corner_y,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
type: "pcb_silkscreen_path",
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
layer: "top",
|
|
194
|
+
pcb_component_id: "",
|
|
195
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner_index}`,
|
|
196
|
+
route: [
|
|
197
|
+
{
|
|
198
|
+
x: corner_x,
|
|
199
|
+
y: corner_y - (csz * dy) / 2,
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
x: corner_x,
|
|
203
|
+
y: corner_y - csz * dy,
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
type: "pcb_silkscreen_path",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
layer: "top",
|
|
210
|
+
pcb_component_id: "",
|
|
211
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner_index}`,
|
|
212
|
+
route: [
|
|
213
|
+
{
|
|
214
|
+
x: corner_x - 0.2,
|
|
215
|
+
y: corner_y + 0.2 * rotate_arrow,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
x: corner_x,
|
|
219
|
+
y: corner_y,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
x: corner_x + 0.2 * rotate_arrow,
|
|
223
|
+
y: corner_y + 0.2,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
x: corner_x - 0.2,
|
|
227
|
+
y: corner_y + 0.2 * rotate_arrow,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
type: "pcb_silkscreen_path",
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return [...pads, ...silkscreen_corners]
|
|
134
237
|
}
|
|
@@ -22,7 +22,7 @@ import type { PinOrderSpecifier } from "./zod/pin-order-specifier"
|
|
|
22
22
|
* 8 -> 2
|
|
23
23
|
*
|
|
24
24
|
* Which allows us to create the CW version of the package using...
|
|
25
|
-
* new_pin = pin_map[
|
|
25
|
+
* new_pin = pin_map[normal_ccw_pin]
|
|
26
26
|
*
|
|
27
27
|
* 2 3
|
|
28
28
|
* 1 4
|
|
@@ -88,7 +88,7 @@ export const getQuadPinMap = ({
|
|
|
88
88
|
// going CCW this means incrementing, if we're going CW this means
|
|
89
89
|
// decrementing
|
|
90
90
|
for (let i = 0; i < num_pins; i++) {
|
|
91
|
-
pin_map
|
|
91
|
+
pin_map[current_position_ccw_normal] = i + 1
|
|
92
92
|
if (ccw || !cw) {
|
|
93
93
|
current_position_ccw_normal++
|
|
94
94
|
if (current_position_ccw_normal > num_pins) {
|
package/tests/quad.test.ts
CHANGED
|
@@ -11,35 +11,14 @@ test("quad16_w4_l4_p0.4_pw0.25_pl0.4", async (t) => {
|
|
|
11
11
|
t.pass()
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
test("quad16_w4_l4_p0.4_pw0.25_pl0.
|
|
14
|
+
test("quad16_w4_l4_p0.4_pw0.25_pl0.4_thermalpad_startingpin(topside,leftpin)", async (t) => {
|
|
15
15
|
const { fp, logSoup } = await getTestFixture(t)
|
|
16
|
-
const soup = fp
|
|
16
|
+
const soup = fp
|
|
17
|
+
.string(
|
|
18
|
+
"quad16_w4_l4_p0.4_pw0.25_pl0.4_thermalpad_startingpin(topside,leftpin)"
|
|
19
|
+
)
|
|
20
|
+
.soup()
|
|
17
21
|
|
|
18
22
|
await logSoup(soup)
|
|
19
23
|
t.pass()
|
|
20
24
|
})
|
|
21
|
-
|
|
22
|
-
// const ps = toPinPositionString(soup)
|
|
23
|
-
|
|
24
|
-
// t.is(
|
|
25
|
-
// ps,
|
|
26
|
-
// `
|
|
27
|
-
// 1 : -1.75 -2.00
|
|
28
|
-
// 2 : -1.25 -2.00
|
|
29
|
-
// 3 : -0.75 -2.00
|
|
30
|
-
// 4 : -0.25 -2.00
|
|
31
|
-
// 5 : 0.25 -2.00
|
|
32
|
-
// 6 : 0.75 -2.00
|
|
33
|
-
// 7 : 1.25 -2.00
|
|
34
|
-
// 8 : 1.75 -2.00
|
|
35
|
-
// 9 : 2.00 -1.75
|
|
36
|
-
// 10: 2.00 -1.25
|
|
37
|
-
// 11: 2.00 -0.75
|
|
38
|
-
// 12: 2.00 -0.25
|
|
39
|
-
// 13: 2.00 0.25
|
|
40
|
-
// 14: 2.00 0.75
|
|
41
|
-
// 15: 2.00 1.25
|
|
42
|
-
// 16: 2.00 1.75
|
|
43
|
-
// `.trim()
|
|
44
|
-
// )
|
|
45
|
-
// })
|