@tscircuit/footprinter 0.0.13 → 0.0.14
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
CHANGED
package/src/fn/quad.ts
CHANGED
|
@@ -3,17 +3,8 @@ import { z } from "zod"
|
|
|
3
3
|
import { length } from "@tscircuit/soup"
|
|
4
4
|
import type { NowDefined } from "../helpers/zod/now-defined"
|
|
5
5
|
import { rectpad } from "../helpers/rectpad"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"leftside",
|
|
9
|
-
"topside",
|
|
10
|
-
"rightside",
|
|
11
|
-
"bottomside",
|
|
12
|
-
"toppin",
|
|
13
|
-
"bottompin",
|
|
14
|
-
"leftpin",
|
|
15
|
-
"rightpin",
|
|
16
|
-
])
|
|
6
|
+
import { pin_order_specifier } from "src/helpers/zod/pin-order-specifier"
|
|
7
|
+
import { getQuadPinMap } from "src/helpers/get-quad-pin-map"
|
|
17
8
|
|
|
18
9
|
const base_quad_def = z.object({
|
|
19
10
|
quad: z.literal(true),
|
|
@@ -106,6 +97,7 @@ export const quad = (raw_params: {
|
|
|
106
97
|
}): AnySoupElement[] => {
|
|
107
98
|
const params = quad_def.parse(raw_params)
|
|
108
99
|
const pads: AnySoupElement[] = []
|
|
100
|
+
const pin_map = getQuadPinMap(params)
|
|
109
101
|
for (let i = 0; i < params.num_pins; i++) {
|
|
110
102
|
const {
|
|
111
103
|
x,
|
|
@@ -125,7 +117,8 @@ export const quad = (raw_params: {
|
|
|
125
117
|
;[pw, pl] = [pl, pw]
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
|
|
120
|
+
const pn = getQuadPinMap(params)[i + 1]
|
|
121
|
+
pads.push(rectpad(pn!, x, y, pw, pl))
|
|
129
122
|
}
|
|
130
123
|
return pads
|
|
131
124
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { PinOrderSpecifier } from "./zod/pin-order-specifier"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A counter-clockwise pin map is [1,2,3,4,5,6,7,8] for an 8-pin package
|
|
5
|
+
*
|
|
6
|
+
* 8 7
|
|
7
|
+
* 1 6
|
|
8
|
+
* 2 5
|
|
9
|
+
* 3 4
|
|
10
|
+
*
|
|
11
|
+
* Given some parameters, we're returning how to map the pins in a quad package
|
|
12
|
+
* with a different order. For example, if we pass in cw=true, we'll get the
|
|
13
|
+
* following mapping
|
|
14
|
+
*
|
|
15
|
+
* 1 -> 1
|
|
16
|
+
* 2 -> 8
|
|
17
|
+
* 3 -> 7
|
|
18
|
+
* 4 -> 6
|
|
19
|
+
* 5 -> 5
|
|
20
|
+
* 6 -> 4
|
|
21
|
+
* 7 -> 3
|
|
22
|
+
* 8 -> 2
|
|
23
|
+
*
|
|
24
|
+
* Which allows us to create the CW version of the package:
|
|
25
|
+
*
|
|
26
|
+
* 2 3
|
|
27
|
+
* 1 4
|
|
28
|
+
* 8 5
|
|
29
|
+
* 7 6
|
|
30
|
+
*/
|
|
31
|
+
export const getQuadPinMap = ({
|
|
32
|
+
num_pins,
|
|
33
|
+
cw,
|
|
34
|
+
ccw,
|
|
35
|
+
startingpin,
|
|
36
|
+
}: {
|
|
37
|
+
num_pins: number
|
|
38
|
+
cw?: boolean
|
|
39
|
+
ccw?: boolean
|
|
40
|
+
startingpin?: PinOrderSpecifier[]
|
|
41
|
+
}): number[] => {
|
|
42
|
+
const pin_map: number[] = []
|
|
43
|
+
const pins_per_side = num_pins / 4
|
|
44
|
+
let current_position_ccw_normal = 1
|
|
45
|
+
|
|
46
|
+
/** Starting Flag Pins */
|
|
47
|
+
const sfp: Record<PinOrderSpecifier, boolean> = {} as any
|
|
48
|
+
for (const specifier of startingpin ?? []) {
|
|
49
|
+
sfp[specifier] = true
|
|
50
|
+
}
|
|
51
|
+
if (!sfp.leftside && !sfp.topside && !sfp.rightside && !sfp.bottomside) {
|
|
52
|
+
sfp.leftside = true
|
|
53
|
+
}
|
|
54
|
+
if (!sfp.bottompin && !sfp.leftpin && !sfp.rightpin && !sfp.toppin) {
|
|
55
|
+
if (sfp.leftside) {
|
|
56
|
+
sfp.toppin = true
|
|
57
|
+
} else if (sfp.topside) {
|
|
58
|
+
sfp.rightpin = true
|
|
59
|
+
} else if (sfp.rightside) {
|
|
60
|
+
sfp.bottompin = true
|
|
61
|
+
} else if (sfp.bottomside) {
|
|
62
|
+
sfp.leftpin = true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (sfp.leftside && sfp.toppin) {
|
|
67
|
+
current_position_ccw_normal = 1
|
|
68
|
+
} else if (sfp.leftside && sfp.bottompin) {
|
|
69
|
+
current_position_ccw_normal = pins_per_side
|
|
70
|
+
} else if (sfp.bottomside && sfp.leftpin) {
|
|
71
|
+
current_position_ccw_normal = pins_per_side + 1
|
|
72
|
+
} else if (sfp.bottomside && sfp.rightpin) {
|
|
73
|
+
current_position_ccw_normal = pins_per_side * 2
|
|
74
|
+
} else if (sfp.rightside && sfp.bottompin) {
|
|
75
|
+
current_position_ccw_normal = pins_per_side * 2 + 1
|
|
76
|
+
} else if (sfp.rightside && sfp.toppin) {
|
|
77
|
+
current_position_ccw_normal = pins_per_side * 3
|
|
78
|
+
} else if (sfp.topside && sfp.rightpin) {
|
|
79
|
+
current_position_ccw_normal = pins_per_side * 3 + 1
|
|
80
|
+
} else if (sfp.topside && sfp.leftpin) {
|
|
81
|
+
current_position_ccw_normal = pins_per_side * 4
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
pin_map.push(-1) // the first index is meaningless
|
|
85
|
+
|
|
86
|
+
// Each iteration we move the current position to the next pin, if we're
|
|
87
|
+
// going CCW this means incrementing, if we're going CW this means
|
|
88
|
+
// decrementing
|
|
89
|
+
for (let i = 0; i < num_pins; i++) {
|
|
90
|
+
pin_map.push(current_position_ccw_normal)
|
|
91
|
+
if (ccw) {
|
|
92
|
+
current_position_ccw_normal++
|
|
93
|
+
if (current_position_ccw_normal > num_pins) {
|
|
94
|
+
current_position_ccw_normal = 1
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
current_position_ccw_normal--
|
|
98
|
+
if (current_position_ccw_normal < 1) {
|
|
99
|
+
current_position_ccw_normal = num_pins
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return pin_map
|
|
105
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
export const pin_order_specifier = z.enum([
|
|
3
|
+
"leftside",
|
|
4
|
+
"topside",
|
|
5
|
+
"rightside",
|
|
6
|
+
"bottomside",
|
|
7
|
+
"toppin",
|
|
8
|
+
"bottompin",
|
|
9
|
+
"leftpin",
|
|
10
|
+
"rightpin",
|
|
11
|
+
])
|
|
12
|
+
|
|
13
|
+
export type PinOrderSpecifier = z.infer<typeof pin_order_specifier>
|