@tscircuit/footprinter 0.0.18 → 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 +94 -19
- 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
|
@@ -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(),
|
|
@@ -133,29 +138,99 @@ export const quad = (
|
|
|
133
138
|
const silkscreen_corners: PcbSilkscreenPath[] = []
|
|
134
139
|
for (let corner_index = 0; corner_index < 4; corner_index++) {
|
|
135
140
|
const dx = Math.floor(corner_index / 2) * 2 - 1
|
|
136
|
-
const dy = (corner_index % 2) * 2
|
|
137
|
-
const corner_x = (params.w / 2) * dx
|
|
138
|
-
const corner_y = (params.h / 2) * dy
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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(
|
|
144
176
|
{
|
|
145
|
-
|
|
146
|
-
|
|
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",
|
|
147
191
|
},
|
|
148
192
|
{
|
|
149
|
-
|
|
150
|
-
|
|
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",
|
|
151
207
|
},
|
|
152
208
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
+
}
|
|
159
234
|
}
|
|
160
235
|
|
|
161
236
|
return [...pads, ...silkscreen_corners]
|
|
@@ -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
|
-
// })
|