@tscircuit/footprinter 0.0.9 → 0.0.11

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
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tscircuit/footprinter",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs",
7
7
  "scripts": {
8
- "test": "ava",
8
+ "test": "FULL_RUN=1 ava",
9
9
  "build": "tsup ./src/index.ts --dts --sourcemap"
10
10
  },
11
11
  "keywords": [],
package/src/fn/dip.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AnySoupElement } from "@tscircuit/soup"
1
+ import type { AnySoupElement, PcbSilkscreenPath } from "@tscircuit/soup"
2
2
  import { platedhole } from "../helpers/platedhole"
3
3
  import { z } from "zod"
4
4
  import { length } from "@tscircuit/soup"
package/src/fn/soic.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { AnySoupElement } from "@tscircuit/soup"
1
+ import type { AnySoupElement, PcbSilkscreenPath } from "@tscircuit/soup"
2
2
  import { platedhole } from "../helpers/platedhole"
3
3
  import { z } from "zod"
4
4
  import { length } from "@tscircuit/soup"
5
5
  import type { NowDefined } from "../helpers/zod/now-defined"
6
+ import { u_curve } from "../helpers/u-curve"
6
7
 
7
8
  const soic_def = z
8
9
  .object({
@@ -78,5 +79,28 @@ export const soic = (raw_params: {
78
79
  platedhole(i + 1, x, y, params.id ?? "0.6mm", params.od ?? "1mm")
79
80
  )
80
81
  }
81
- return platedHoles
82
+
83
+ /** silkscreen width */
84
+ const sw = params.w - params.od - 0.4
85
+ const sh = (params.num_pins / 2 - 1) * params.p + params.od + 0.4
86
+ const silkscreenBorder: PcbSilkscreenPath = {
87
+ layer: "top",
88
+ pcb_component_id: "",
89
+ pcb_silkscreen_path_id: "silkscreen_path_1",
90
+ route: [
91
+ { x: -sw / 2, y: -sh / 2 },
92
+ { x: -sw / 2, y: sh / 2 },
93
+ // Little U shape at the top
94
+ ...u_curve.map(({ x, y }) => ({
95
+ x: (x * sw) / 6,
96
+ y: (y * sw) / 6 + sh / 2,
97
+ })),
98
+ { x: sw / 2, y: sh / 2 },
99
+ { x: sw / 2, y: -sh / 2 },
100
+ { x: -sw / 2, y: -sh / 2 },
101
+ ],
102
+ type: "pcb_silkscreen_path",
103
+ }
104
+
105
+ return [...platedHoles, silkscreenBorder]
82
106
  }
@@ -0,0 +1,6 @@
1
+ export const u_curve = Array.from({ length: 9 }, (_, i) =>
2
+ Math.cos((i / 8) * Math.PI - Math.PI)
3
+ ).map((x) => ({
4
+ x,
5
+ y: -Math.sqrt(1 - x ** 2),
6
+ }))
package/tests/dip.test.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import test from "ava"
2
2
  import { fp } from "../src/footprinter"
3
3
  import type { AnySoupElement } from "@tscircuit/soup"
4
- import { toPinPositionString } from "./fixtures"
4
+ import { getTestFixture, toPinPositionString } from "./fixtures"
5
5
 
6
6
  test("dip params", (t) => {
7
7
  t.deepEqual(fp().dip(4).w(7.62).params(), {
@@ -26,7 +26,8 @@ test("dip footprint", (t) => {
26
26
  )
27
27
  })
28
28
 
29
- test("dip4_w3.00mm", (t) => {
29
+ test("dip4_w3.00mm", async (t) => {
30
+ const { fp, logSoup } = await getTestFixture(t)
30
31
  const soup = fp.string("dip4_w3.00mm").soup()
31
32
  const ps = toPinPositionString(soup)
32
33
 
@@ -39,4 +40,6 @@ test("dip4_w3.00mm", (t) => {
39
40
  4 : 1.50 1.27
40
41
  `.trim()
41
42
  )
43
+
44
+ await logSoup(soup)
42
45
  })
@@ -8,10 +8,12 @@ export const getTestFixture = async (t: ExecutionContext) => {
8
8
  fp,
9
9
  logSoup: (soup: AnySoupElement[]) => {
10
10
  if (process.env.CI) return
11
+ if (process.env.FULL_RUN) return
11
12
  return logSoup(`footprinter: ${t.title}`, soup)
12
13
  },
13
14
  logSoupWithPrefix: (prefix: string, soup: AnySoupElement[]) => {
14
15
  if (process.env.CI) return
16
+ if (process.env.FULL_RUN) return
15
17
  return logSoup(`footprinter: ${t.title} ${prefix}`, soup)
16
18
  },
17
19
  }
@@ -3,8 +3,9 @@ import { getTestFixture } from "tests/fixtures/get-test-fixture"
3
3
  import { su } from "@tscircuit/soup-util"
4
4
 
5
5
  test("soic8_w5.3mm_p1.27mm", async (t) => {
6
- const { fp } = await getTestFixture(t)
6
+ const { fp, logSoup } = await getTestFixture(t)
7
7
  const soup = fp.string("soic8_w5.3mm_p1.27mm").soup()
8
8
 
9
9
  t.is(su(soup).pcb_plated_hole.list().length, 8)
10
+ await logSoup(soup)
10
11
  })