@tscircuit/footprinter 0.0.7 → 0.0.8
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/bga.ts +55 -1
- package/tsconfig.json +1 -0
- package/src/helpers/zod/bga-def.ts +0 -56
package/package.json
CHANGED
package/src/fn/bga.ts
CHANGED
|
@@ -1,7 +1,61 @@
|
|
|
1
1
|
import type { AnySoupElement, PCBSMTPad } from "@tscircuit/soup"
|
|
2
2
|
import { rectpad } from "../helpers/rectpad"
|
|
3
|
-
import { type BgaDefInput, bga_def } from "../helpers/zod/bga-def"
|
|
4
3
|
import { ALPHABET } from "../helpers/zod/ALPHABET"
|
|
4
|
+
import { z } from "zod"
|
|
5
|
+
import { length, distance } from "@tscircuit/soup"
|
|
6
|
+
import { dim2d } from "src/helpers/zod/dim-2d"
|
|
7
|
+
import { function_call } from "src/helpers/zod/function-call"
|
|
8
|
+
import type { NowDefined } from "src/helpers/zod/now-defined"
|
|
9
|
+
|
|
10
|
+
export const bga_def = z
|
|
11
|
+
.object({
|
|
12
|
+
num_pins: z.number(),
|
|
13
|
+
grid: dim2d.optional(),
|
|
14
|
+
p: distance.default("0.8mm"),
|
|
15
|
+
w: length.optional(),
|
|
16
|
+
h: length.optional(),
|
|
17
|
+
ball: length.optional().describe("ball diameter"),
|
|
18
|
+
pad: length.optional().describe("pad width/height"),
|
|
19
|
+
|
|
20
|
+
tlorigin: z.boolean().optional(),
|
|
21
|
+
blorigin: z.boolean().optional(),
|
|
22
|
+
trorigin: z.boolean().optional(),
|
|
23
|
+
brorigin: z.boolean().optional(),
|
|
24
|
+
|
|
25
|
+
missing: function_call.default([]),
|
|
26
|
+
})
|
|
27
|
+
.transform((a) => {
|
|
28
|
+
let origin: "tl" | "bl" | "tr" | "br" = "tl"
|
|
29
|
+
if (a.blorigin) origin = "bl"
|
|
30
|
+
if (a.trorigin) origin = "tr"
|
|
31
|
+
if (a.brorigin) origin = "br"
|
|
32
|
+
|
|
33
|
+
if (!a.grid) {
|
|
34
|
+
// find the largest square for the number of pins
|
|
35
|
+
const largest_square = Math.ceil(Math.sqrt(a.num_pins))
|
|
36
|
+
a.grid = { x: largest_square, y: largest_square }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (a.missing) {
|
|
40
|
+
a.missing = a.missing.map((s) => {
|
|
41
|
+
if (typeof s === "number") return s
|
|
42
|
+
if (s === "center") return "center"
|
|
43
|
+
if (s === "topleft") return "topleft"
|
|
44
|
+
const m = s.match(/([A-Z]+)(\d+)/)
|
|
45
|
+
if (!m) return s
|
|
46
|
+
let Y = ALPHABET.indexOf(m[1]!)
|
|
47
|
+
let X = parseInt(m[2]!) - 1
|
|
48
|
+
return Y * a.grid!.x + X + 1
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const new_def = { ...a, origin }
|
|
53
|
+
|
|
54
|
+
return new_def as NowDefined<typeof new_def, "w" | "h" | "grid">
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export type BgaDefInput = z.input<typeof bga_def>
|
|
58
|
+
export type BgaDef = z.infer<typeof bga_def>
|
|
5
59
|
|
|
6
60
|
export const bga = (params: BgaDefInput): AnySoupElement[] => {
|
|
7
61
|
const bga_params = bga_def.parse(params)
|
package/tsconfig.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { z } from "zod"
|
|
2
|
-
import { length, distance } from "@tscircuit/soup"
|
|
3
|
-
import { dim2d } from "./dim-2d"
|
|
4
|
-
import { function_call } from "./function-call"
|
|
5
|
-
import type { NowDefined } from "./now-defined"
|
|
6
|
-
import { ALPHABET } from "./ALPHABET"
|
|
7
|
-
|
|
8
|
-
export const bga_def = z
|
|
9
|
-
.object({
|
|
10
|
-
num_pins: z.number(),
|
|
11
|
-
grid: dim2d.optional(),
|
|
12
|
-
p: distance.default("0.8mm"),
|
|
13
|
-
w: length.optional(),
|
|
14
|
-
h: length.optional(),
|
|
15
|
-
ball: length.optional().describe("ball diameter"),
|
|
16
|
-
pad: length.optional().describe("pad width/height"),
|
|
17
|
-
|
|
18
|
-
tlorigin: z.boolean().optional(),
|
|
19
|
-
blorigin: z.boolean().optional(),
|
|
20
|
-
trorigin: z.boolean().optional(),
|
|
21
|
-
brorigin: z.boolean().optional(),
|
|
22
|
-
|
|
23
|
-
missing: function_call.default([]),
|
|
24
|
-
})
|
|
25
|
-
.transform((a) => {
|
|
26
|
-
let origin: "tl" | "bl" | "tr" | "br" = "tl"
|
|
27
|
-
if (a.blorigin) origin = "bl"
|
|
28
|
-
if (a.trorigin) origin = "tr"
|
|
29
|
-
if (a.brorigin) origin = "br"
|
|
30
|
-
|
|
31
|
-
if (!a.grid) {
|
|
32
|
-
// find the largest square for the number of pins
|
|
33
|
-
const largest_square = Math.ceil(Math.sqrt(a.num_pins))
|
|
34
|
-
a.grid = { x: largest_square, y: largest_square }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (a.missing) {
|
|
38
|
-
a.missing = a.missing.map((s) => {
|
|
39
|
-
if (typeof s === "number") return s
|
|
40
|
-
if (s === "center") return "center"
|
|
41
|
-
if (s === "topleft") return "topleft"
|
|
42
|
-
const m = s.match(/([A-Z]+)(\d+)/)
|
|
43
|
-
if (!m) return s
|
|
44
|
-
let Y = ALPHABET.indexOf(m[1]!)
|
|
45
|
-
let X = parseInt(m[2]!) - 1
|
|
46
|
-
return Y * a.grid!.x + X + 1
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const new_def = { ...a, origin }
|
|
51
|
-
|
|
52
|
-
return new_def as NowDefined<typeof new_def, "w" | "h" | "grid">
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
export type BgaDefInput = z.input<typeof bga_def>
|
|
56
|
-
export type BgaDef = z.infer<typeof bga_def>
|