@tscircuit/footprinter 0.0.39 → 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 CHANGED
@@ -96,14 +96,20 @@ industry best practices or otherwise "reasonable" defaults. In theory, upgrading
96
96
  footprinter could cause the defaults to change, which is why sloppy definitions
97
97
  are generally not desirable.
98
98
 
99
- ## Adding new footprint functions
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.
102
+
103
+ ## Adding a new footprint function
100
104
 
101
- You can add new footprint functions by introducing a new function in the [src/fn](https://github.com/tscircuit/footprinter/tree/main/src/fn)
102
- directory. You'll also need to export it from the [footprint function index file](https://github.com/tscircuit/footprinter/blob/main/src/fn/index.ts)
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)
103
106
 
104
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)
105
108
  Currently it's not possible to see if a given definition is sloppy.
106
109
 
107
- An example of a sloppy definition is `bga64`. It's very underconstrained and
108
- unlikely to be correct (what's the pitch? pad size?). tscircuit strict mode
109
- or a linter will eventually error if it sees these.
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 = (pinCount, pn, w, p) => {
3692
- const ph = pinCount / 2;
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
- pads.push(rectpad(i + 1, x, y, params.pw ?? "0.6mm", params.pl ?? "1mm"));
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.pw - 0.4;
3718
- const sh = (params.num_pins / 2 - 1) * params.p + params.pl + 0.4;
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