@tscircuit/footprinter 0.0.38 → 0.0.40
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/README.md +44 -11
- package/dist/index.cjs +22 -17
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,12 +42,39 @@ fp.string("dip4_w7.62mm") // same as fp.dip(4).w(7.62)
|
|
|
42
42
|
fp.string("dip4_w0.3in") // same as fp.dip(4).w("0.3in")
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
##
|
|
45
|
+
## Getting JSON output from the builder
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
Use the `.soup()` function to output [tscircuit soup JSON](https://github.com/tscircuit/soup)
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
fp.string("res0402").soup()
|
|
51
|
+
/*
|
|
52
|
+
[
|
|
53
|
+
{
|
|
54
|
+
type: 'pcb_smtpad',
|
|
55
|
+
x: -0.5,
|
|
56
|
+
y: 0,
|
|
57
|
+
width: 0.6000000000000001,
|
|
58
|
+
height: 0.6000000000000001,
|
|
59
|
+
layer: 'top',
|
|
60
|
+
shape: 'rect',
|
|
61
|
+
pcb_smtpad_id: '',
|
|
62
|
+
port_hints: [ '1' ]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'pcb_smtpad',
|
|
66
|
+
x: 0.5,
|
|
67
|
+
y: 0,
|
|
68
|
+
width: 0.6000000000000001,
|
|
69
|
+
height: 0.6000000000000001,
|
|
70
|
+
layer: 'top',
|
|
71
|
+
shape: 'rect',
|
|
72
|
+
pcb_smtpad_id: '',
|
|
73
|
+
port_hints: [ '2' ]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
*/
|
|
77
|
+
```
|
|
51
78
|
|
|
52
79
|
## Generation Defaults
|
|
53
80
|
|
|
@@ -69,14 +96,20 @@ industry best practices or otherwise "reasonable" defaults. In theory, upgrading
|
|
|
69
96
|
footprinter could cause the defaults to change, which is why sloppy definitions
|
|
70
97
|
are generally not desirable.
|
|
71
98
|
|
|
72
|
-
|
|
99
|
+
An example of a sloppy definition is `bga64`. It's very underconstrained and
|
|
100
|
+
unlikely to be correct (what's the pitch? pad size?). tscircuit strict mode
|
|
101
|
+
or a linter will eventually error if it sees these.
|
|
73
102
|
|
|
74
|
-
|
|
75
|
-
|
|
103
|
+
## Adding a new footprint function
|
|
104
|
+
|
|
105
|
+
You can add new footprint functions by introducing a new function in the [src/fn directory](https://github.com/tscircuit/footprinter/tree/main/src/fn). You'll also need to export it from the [footprint function index file](https://github.com/tscircuit/footprinter/blob/main/src/fn/index.ts)
|
|
76
106
|
|
|
77
107
|
After you've written the function, you can introduce a quick test, e.g. [soic.test.ts](https://github.com/tscircuit/footprinter/blob/main/tests/soic.test.ts)
|
|
78
108
|
Currently it's not possible to see if a given definition is sloppy.
|
|
79
109
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
110
|
+
To run tests, just run `npx ava ./tests/soic.test.ts` or whatever your test
|
|
111
|
+
file is.
|
|
112
|
+
|
|
113
|
+
You'll sometimes see this `logSoup` function- this makes some debug output
|
|
114
|
+
appear at https://debug.tscircuit.com. Make sure to hit "pcb" and "pcb_renderer"
|
|
115
|
+
after the design.
|
package/dist/index.cjs
CHANGED
|
@@ -3670,12 +3670,12 @@ ${JSON.stringify(
|
|
|
3670
3670
|
var import_zod5 = require("zod");
|
|
3671
3671
|
var import_soup3 = __toESM(require_dist(), 1);
|
|
3672
3672
|
var extendSoicDef = (newDefaults) => import_zod5.z.object({
|
|
3673
|
-
soic: import_zod5.z.literal(true),
|
|
3674
3673
|
num_pins: import_zod5.z.number(),
|
|
3675
3674
|
w: import_soup3.length.default(import_soup3.length.parse(newDefaults.w ?? "5.3mm")),
|
|
3676
3675
|
p: import_soup3.length.default(import_soup3.length.parse(newDefaults.p ?? "1.27mm")),
|
|
3677
3676
|
pw: import_soup3.length.optional(),
|
|
3678
|
-
pl: import_soup3.length.optional()
|
|
3677
|
+
pl: import_soup3.length.optional(),
|
|
3678
|
+
legsoutside: import_zod5.z.boolean().optional().default(newDefaults.legsoutside ?? false)
|
|
3679
3679
|
}).transform((v) => {
|
|
3680
3680
|
if (!v.pw && !v.pl) {
|
|
3681
3681
|
v.pw = import_soup3.length.parse("0.6mm");
|
|
@@ -3688,16 +3688,18 @@ var extendSoicDef = (newDefaults) => import_zod5.z.object({
|
|
|
3688
3688
|
return v;
|
|
3689
3689
|
});
|
|
3690
3690
|
var soic_def = extendSoicDef({});
|
|
3691
|
-
var getCcwSoicCoords = (
|
|
3692
|
-
const
|
|
3691
|
+
var getCcwSoicCoords = (params) => {
|
|
3692
|
+
const { num_pins, pn, w, p, pl, legsoutside } = params;
|
|
3693
|
+
const ph = num_pins / 2;
|
|
3693
3694
|
const isLeft = pn <= ph;
|
|
3694
3695
|
const leftPinGaps = ph - 1;
|
|
3695
3696
|
const gs = p;
|
|
3696
3697
|
const h = gs * leftPinGaps;
|
|
3698
|
+
const legoffset = legsoutside ? pl / 2 : -pl / 2;
|
|
3697
3699
|
if (isLeft) {
|
|
3698
|
-
return { x: -w / 2, y: h / 2 - (pn - 1) * gs };
|
|
3700
|
+
return { x: -w / 2 - legoffset, y: h / 2 - (pn - 1) * gs };
|
|
3699
3701
|
} else {
|
|
3700
|
-
return { x: w / 2, y: -h / 2 + (pn - ph - 1) * gs };
|
|
3702
|
+
return { x: w / 2 + legoffset, y: -h / 2 + (pn - ph - 1) * gs };
|
|
3701
3703
|
}
|
|
3702
3704
|
};
|
|
3703
3705
|
var soic = (raw_params) => {
|
|
@@ -3706,16 +3708,18 @@ var soic = (raw_params) => {
|
|
|
3706
3708
|
var soicWithoutParsing = (params) => {
|
|
3707
3709
|
const pads = [];
|
|
3708
3710
|
for (let i = 0; i < params.num_pins; i++) {
|
|
3709
|
-
const { x, y } = getCcwSoicCoords(
|
|
3710
|
-
params.num_pins,
|
|
3711
|
-
i + 1,
|
|
3712
|
-
params.w,
|
|
3713
|
-
params.p ?? 1.27
|
|
3714
|
-
|
|
3715
|
-
|
|
3711
|
+
const { x, y } = getCcwSoicCoords({
|
|
3712
|
+
num_pins: params.num_pins,
|
|
3713
|
+
pn: i + 1,
|
|
3714
|
+
w: params.w,
|
|
3715
|
+
p: params.p ?? 1.27,
|
|
3716
|
+
pl: params.pl,
|
|
3717
|
+
legsoutside: params.legsoutside
|
|
3718
|
+
});
|
|
3719
|
+
pads.push(rectpad(i + 1, x, y, params.pl ?? "1mm", params.pw ?? "0.6mm"));
|
|
3716
3720
|
}
|
|
3717
|
-
const sw = params.w - params.
|
|
3718
|
-
const sh = (params.num_pins / 2 - 1) * params.p + params.
|
|
3721
|
+
const sw = params.w - (params.legsoutside ? 0 : params.pl * 2) - 0.2;
|
|
3722
|
+
const sh = (params.num_pins / 2 - 1) * params.p + params.pw;
|
|
3719
3723
|
const silkscreenBorder = {
|
|
3720
3724
|
layer: "top",
|
|
3721
3725
|
pcb_component_id: "",
|
|
@@ -4095,10 +4099,11 @@ var tssop = (raw_params) => {
|
|
|
4095
4099
|
// src/fn/sot236.ts
|
|
4096
4100
|
var sot236_def = extendSoicDef({
|
|
4097
4101
|
p: "0.95mm",
|
|
4098
|
-
w: "1.6mm"
|
|
4102
|
+
w: "1.6mm",
|
|
4103
|
+
legsoutside: true
|
|
4099
4104
|
});
|
|
4100
4105
|
var sot236 = (params) => {
|
|
4101
|
-
return soicWithoutParsing(sot236_def.parse(params));
|
|
4106
|
+
return soicWithoutParsing(sot236_def.parse({ ...params, num_pins: 6 }));
|
|
4102
4107
|
};
|
|
4103
4108
|
|
|
4104
4109
|
// src/helpers/is-not-null.ts
|