@tscircuit/footprinter 0.0.19 → 0.0.21
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 +50 -30
- package/tests/quad.test.ts +2 -2
package/package.json
CHANGED
package/src/fn/quad.ts
CHANGED
|
@@ -60,14 +60,15 @@ const quad_def = base_quad_def.transform((v) => {
|
|
|
60
60
|
|
|
61
61
|
const SIDES_CCW = ["left", "bottom", "right", "top"] as const
|
|
62
62
|
|
|
63
|
-
export const getQuadCoords = (
|
|
64
|
-
|
|
65
|
-
pn: number
|
|
66
|
-
w: number
|
|
67
|
-
h: number
|
|
68
|
-
p: number
|
|
63
|
+
export const getQuadCoords = (params: {
|
|
64
|
+
pin_count: number
|
|
65
|
+
pn: number // pin number
|
|
66
|
+
w: number // width of the package
|
|
67
|
+
h: number // height (length) of the package
|
|
68
|
+
p: number // pitch between pins
|
|
69
69
|
pl: number // length of the pin
|
|
70
|
-
) => {
|
|
70
|
+
}) => {
|
|
71
|
+
const { pin_count: pinCount, pn, w, h, p, pl } = params
|
|
71
72
|
const sidePinCount = pinCount / 4
|
|
72
73
|
const side = SIDES_CCW[Math.floor((pn - 1) / sidePinCount)]
|
|
73
74
|
const pos = (pn - 1) % sidePinCount
|
|
@@ -97,19 +98,21 @@ export const quad = (
|
|
|
97
98
|
const params = quad_def.parse(raw_params)
|
|
98
99
|
const pads: AnySoupElement[] = []
|
|
99
100
|
const pin_map = getQuadPinMap(params)
|
|
101
|
+
/** Side pin count */
|
|
102
|
+
const spc = params.num_pins / 4
|
|
100
103
|
for (let i = 0; i < params.num_pins; i++) {
|
|
101
104
|
const {
|
|
102
105
|
x,
|
|
103
106
|
y,
|
|
104
107
|
o: orientation,
|
|
105
|
-
} = getQuadCoords(
|
|
106
|
-
params.num_pins,
|
|
107
|
-
i + 1,
|
|
108
|
-
params.w,
|
|
109
|
-
params.h,
|
|
110
|
-
params.p ?? 0.5,
|
|
111
|
-
params.pl
|
|
112
|
-
)
|
|
108
|
+
} = getQuadCoords({
|
|
109
|
+
pin_count: params.num_pins,
|
|
110
|
+
pn: i + 1,
|
|
111
|
+
w: params.w,
|
|
112
|
+
h: params.h,
|
|
113
|
+
p: params.p ?? 0.5,
|
|
114
|
+
pl: params.pl,
|
|
115
|
+
})
|
|
113
116
|
|
|
114
117
|
let pw = params.pw
|
|
115
118
|
let pl = params.pl
|
|
@@ -123,9 +126,8 @@ export const quad = (
|
|
|
123
126
|
|
|
124
127
|
if (params.thermalpad) {
|
|
125
128
|
if (typeof params.thermalpad === "boolean") {
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const ibh = params.p * (sidePinCount - 1) + params.pw
|
|
129
|
+
const ibw = params.p * (spc - 1) + params.pw
|
|
130
|
+
const ibh = params.p * (spc - 1) + params.pw
|
|
129
131
|
pads.push(rectpad(["thermalpad"], 0, 0, ibw, ibh))
|
|
130
132
|
} else {
|
|
131
133
|
pads.push(
|
|
@@ -136,24 +138,42 @@ export const quad = (
|
|
|
136
138
|
|
|
137
139
|
// Silkscreen corners
|
|
138
140
|
const silkscreen_corners: PcbSilkscreenPath[] = []
|
|
139
|
-
for (
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
for (const [corner, dx, dy] of [
|
|
142
|
+
["top-left", -1, 1],
|
|
143
|
+
["bottom-left", -1, -1],
|
|
144
|
+
["bottom-right", 1, -1],
|
|
145
|
+
["top-right", 1, 1],
|
|
146
|
+
] as const) {
|
|
147
|
+
// const dx = Math.floor(corner_index / 2) * 2 - 1
|
|
148
|
+
// const dy = 1 - (corner_index % 2) * 2
|
|
142
149
|
const corner_x = (params.w / 2 - params.pl / 2) * dx
|
|
143
150
|
const corner_y = (params.h / 2 - params.pl / 2) * dy
|
|
144
151
|
let arrow: "none" | "in1" | "in2" = "none"
|
|
145
152
|
/** corner size */
|
|
146
153
|
const csz = params.pw * 2
|
|
147
|
-
|
|
154
|
+
|
|
155
|
+
if (pin_map[1] === 1 && corner === "top-left") {
|
|
156
|
+
arrow = "in1"
|
|
157
|
+
} else if (pin_map[spc * 4] === 1 && corner === "top-left") {
|
|
158
|
+
arrow = "in2"
|
|
159
|
+
} else if (pin_map[spc * 3 + 1] === 1 && corner === "top-right") {
|
|
160
|
+
arrow = "in2"
|
|
161
|
+
} else if (pin_map[spc * 3] === 1 && corner === "top-right") {
|
|
162
|
+
arrow = "in1"
|
|
163
|
+
} else if (pin_map[spc] === 1 && corner === "bottom-left") {
|
|
164
|
+
arrow = "in1"
|
|
165
|
+
} else if (pin_map[spc + 1] === 1 && corner === "bottom-left") {
|
|
166
|
+
arrow = "in2"
|
|
167
|
+
} else if (pin_map[spc * 2] === 1 && corner === "bottom-right") {
|
|
148
168
|
arrow = "in1"
|
|
149
|
-
} else if (pin_map[
|
|
169
|
+
} else if (pin_map[spc * 2 + 1] === 1 && corner === "bottom-right") {
|
|
150
170
|
arrow = "in2"
|
|
151
171
|
}
|
|
152
172
|
if (arrow === "none") {
|
|
153
173
|
silkscreen_corners.push({
|
|
154
174
|
layer: "top",
|
|
155
175
|
pcb_component_id: "",
|
|
156
|
-
pcb_silkscreen_path_id: `pcb_silkscreen_path_${
|
|
176
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner}`,
|
|
157
177
|
route: [
|
|
158
178
|
{
|
|
159
179
|
x: corner_x - csz * dx,
|
|
@@ -176,7 +196,7 @@ export const quad = (
|
|
|
176
196
|
{
|
|
177
197
|
layer: "top",
|
|
178
198
|
pcb_component_id: "",
|
|
179
|
-
pcb_silkscreen_path_id: `pcb_silkscreen_path_${
|
|
199
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner}_1`,
|
|
180
200
|
route: [
|
|
181
201
|
{
|
|
182
202
|
x: corner_x - csz * dx,
|
|
@@ -192,7 +212,7 @@ export const quad = (
|
|
|
192
212
|
{
|
|
193
213
|
layer: "top",
|
|
194
214
|
pcb_component_id: "",
|
|
195
|
-
pcb_silkscreen_path_id: `pcb_silkscreen_path_${
|
|
215
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner}_2`,
|
|
196
216
|
route: [
|
|
197
217
|
{
|
|
198
218
|
x: corner_x,
|
|
@@ -208,10 +228,10 @@ export const quad = (
|
|
|
208
228
|
{
|
|
209
229
|
layer: "top",
|
|
210
230
|
pcb_component_id: "",
|
|
211
|
-
pcb_silkscreen_path_id: `pcb_silkscreen_path_${
|
|
231
|
+
pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner}_3`,
|
|
212
232
|
route: [
|
|
213
233
|
{
|
|
214
|
-
x: corner_x - 0.2,
|
|
234
|
+
x: corner_x - 0.2 * -dx,
|
|
215
235
|
y: corner_y + 0.2 * rotate_arrow,
|
|
216
236
|
},
|
|
217
237
|
{
|
|
@@ -219,11 +239,11 @@ export const quad = (
|
|
|
219
239
|
y: corner_y,
|
|
220
240
|
},
|
|
221
241
|
{
|
|
222
|
-
x: corner_x + 0.2 * rotate_arrow,
|
|
242
|
+
x: corner_x + 0.2 * rotate_arrow * -dx,
|
|
223
243
|
y: corner_y + 0.2,
|
|
224
244
|
},
|
|
225
245
|
{
|
|
226
|
-
x: corner_x - 0.2,
|
|
246
|
+
x: corner_x - 0.2 * -dx,
|
|
227
247
|
y: corner_y + 0.2 * rotate_arrow,
|
|
228
248
|
},
|
|
229
249
|
],
|
package/tests/quad.test.ts
CHANGED
|
@@ -11,11 +11,11 @@ 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.4_thermalpad_startingpin(
|
|
14
|
+
test("quad16_w4_l4_p0.4_pw0.25_pl0.4_thermalpad_startingpin(bottomside,leftpin)", async (t) => {
|
|
15
15
|
const { fp, logSoup } = await getTestFixture(t)
|
|
16
16
|
const soup = fp
|
|
17
17
|
.string(
|
|
18
|
-
"quad16_w4_l4_p0.4_pw0.25_pl0.4_thermalpad_startingpin(
|
|
18
|
+
"quad16_w4_l4_p0.4_pw0.25_pl0.4_thermalpad_startingpin(bottomside,leftpin)"
|
|
19
19
|
)
|
|
20
20
|
.soup()
|
|
21
21
|
|