@tscircuit/footprinter 0.0.39 → 0.0.41

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
@@ -3498,16 +3498,19 @@ var passive = (params) => {
3498
3498
  ph = (sz.Z_mm_min - sz.G_mm_min) / 2;
3499
3499
  }
3500
3500
  if (pw === void 0)
3501
- throw new Error(`could not infer pad width`);
3501
+ throw new Error("could not infer pad width");
3502
3502
  if (ph === void 0)
3503
- throw new Error(`could not infer pad width`);
3503
+ throw new Error("could not infer pad width");
3504
3504
  if (tht) {
3505
3505
  return [
3506
3506
  platedhole(1, -p / 2, 0, pw, pw * 1 / 0.8),
3507
3507
  platedhole(2, -p / 2, 0, pw, pw * 1 / 0.8)
3508
3508
  ];
3509
3509
  } else {
3510
- return [rectpad(1, -p / 2, 0, pw, ph), rectpad(2, p / 2, 0, pw, ph)];
3510
+ return [
3511
+ rectpad(["1", "left"], -p / 2, 0, pw, ph),
3512
+ rectpad(["2", "right"], p / 2, 0, pw, ph)
3513
+ ];
3511
3514
  }
3512
3515
  };
3513
3516
 
@@ -3670,12 +3673,12 @@ ${JSON.stringify(
3670
3673
  var import_zod5 = require("zod");
3671
3674
  var import_soup3 = __toESM(require_dist(), 1);
3672
3675
  var extendSoicDef = (newDefaults) => import_zod5.z.object({
3673
- soic: import_zod5.z.literal(true),
3674
3676
  num_pins: import_zod5.z.number(),
3675
3677
  w: import_soup3.length.default(import_soup3.length.parse(newDefaults.w ?? "5.3mm")),
3676
3678
  p: import_soup3.length.default(import_soup3.length.parse(newDefaults.p ?? "1.27mm")),
3677
3679
  pw: import_soup3.length.optional(),
3678
- pl: import_soup3.length.optional()
3680
+ pl: import_soup3.length.optional(),
3681
+ legsoutside: import_zod5.z.boolean().optional().default(newDefaults.legsoutside ?? false)
3679
3682
  }).transform((v) => {
3680
3683
  if (!v.pw && !v.pl) {
3681
3684
  v.pw = import_soup3.length.parse("0.6mm");
@@ -3688,16 +3691,18 @@ var extendSoicDef = (newDefaults) => import_zod5.z.object({
3688
3691
  return v;
3689
3692
  });
3690
3693
  var soic_def = extendSoicDef({});
3691
- var getCcwSoicCoords = (pinCount, pn, w, p) => {
3692
- const ph = pinCount / 2;
3694
+ var getCcwSoicCoords = (params) => {
3695
+ const { num_pins, pn, w, p, pl, legsoutside } = params;
3696
+ const ph = num_pins / 2;
3693
3697
  const isLeft = pn <= ph;
3694
3698
  const leftPinGaps = ph - 1;
3695
3699
  const gs = p;
3696
3700
  const h = gs * leftPinGaps;
3701
+ const legoffset = legsoutside ? pl / 2 : -pl / 2;
3697
3702
  if (isLeft) {
3698
- return { x: -w / 2, y: h / 2 - (pn - 1) * gs };
3703
+ return { x: -w / 2 - legoffset, y: h / 2 - (pn - 1) * gs };
3699
3704
  } else {
3700
- return { x: w / 2, y: -h / 2 + (pn - ph - 1) * gs };
3705
+ return { x: w / 2 + legoffset, y: -h / 2 + (pn - ph - 1) * gs };
3701
3706
  }
3702
3707
  };
3703
3708
  var soic = (raw_params) => {
@@ -3706,16 +3711,18 @@ var soic = (raw_params) => {
3706
3711
  var soicWithoutParsing = (params) => {
3707
3712
  const pads = [];
3708
3713
  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"));
3714
+ const { x, y } = getCcwSoicCoords({
3715
+ num_pins: params.num_pins,
3716
+ pn: i + 1,
3717
+ w: params.w,
3718
+ p: params.p ?? 1.27,
3719
+ pl: params.pl,
3720
+ legsoutside: params.legsoutside
3721
+ });
3722
+ pads.push(rectpad(i + 1, x, y, params.pl ?? "1mm", params.pw ?? "0.6mm"));
3716
3723
  }
3717
- const sw = params.w - params.pw - 0.4;
3718
- const sh = (params.num_pins / 2 - 1) * params.p + params.pl + 0.4;
3724
+ const sw = params.w - (params.legsoutside ? 0 : params.pl * 2) - 0.2;
3725
+ const sh = (params.num_pins / 2 - 1) * params.p + params.pw;
3719
3726
  const silkscreenBorder = {
3720
3727
  layer: "top",
3721
3728
  pcb_component_id: "",
@@ -4095,10 +4102,11 @@ var tssop = (raw_params) => {
4095
4102
  // src/fn/sot236.ts
4096
4103
  var sot236_def = extendSoicDef({
4097
4104
  p: "0.95mm",
4098
- w: "1.6mm"
4105
+ w: "1.6mm",
4106
+ legsoutside: true
4099
4107
  });
4100
4108
  var sot236 = (params) => {
4101
- return soicWithoutParsing(sot236_def.parse(params));
4109
+ return soicWithoutParsing(sot236_def.parse({ ...params, num_pins: 6 }));
4102
4110
  };
4103
4111
 
4104
4112
  // src/helpers/is-not-null.ts