@tscircuit/footprinter 0.0.17 → 0.0.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/fn/quad.ts +39 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/footprinter",
3
3
  "type": "module",
4
- "version": "0.0.17",
4
+ "version": "0.0.18",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs",
7
7
  "scripts": {
package/src/fn/quad.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AnySoupElement } from "@tscircuit/soup"
1
+ import type { AnySoupElement, PcbSilkscreenPath } from "@tscircuit/soup"
2
2
  import { z } from "zod"
3
3
  import { length } from "@tscircuit/soup"
4
4
  import type { NowDefined } from "../helpers/zod/now-defined"
@@ -60,15 +60,13 @@ export const getQuadCoords = (
60
60
  pn: number, // pin number
61
61
  w: number, // width of the package
62
62
  h: number, // height (length) of the package
63
- p: number // pitch between pins
63
+ p: number, // pitch between pins
64
+ pl: number // length of the pin
64
65
  ) => {
65
66
  const sidePinCount = pinCount / 4
66
67
  const side = SIDES_CCW[Math.floor((pn - 1) / sidePinCount)]
67
68
  const pos = (pn - 1) % sidePinCount
68
69
 
69
- const halfW = w / 2
70
- const halfH = h / 2
71
-
72
70
  /** inner box width */
73
71
  const ibw = p * (sidePinCount - 1)
74
72
  /** inner box height */
@@ -76,13 +74,13 @@ export const getQuadCoords = (
76
74
 
77
75
  switch (side) {
78
76
  case "left":
79
- return { x: -halfW / 2, y: ibh / 2 - pos * p, o: "vert" }
77
+ return { x: -w / 2 + pl / 2, y: ibh / 2 - pos * p, o: "vert" }
80
78
  case "bottom":
81
- return { x: -ibw / 2 + pos * p, y: -halfH / 2, o: "horz" }
79
+ return { x: -ibw / 2 + pos * p, y: -h / 2 + pl / 2, o: "horz" }
82
80
  case "right":
83
- return { x: halfW / 2, y: -ibh / 2 + pos * p, o: "vert" }
81
+ return { x: w / 2 - pl / 2, y: -ibh / 2 + pos * p, o: "vert" }
84
82
  case "top":
85
- return { x: ibw / 2 - pos * p, y: halfH / 2, o: "horz" }
83
+ return { x: ibw / 2 - pos * p, y: h / 2 - pl / 2, o: "horz" }
86
84
  default:
87
85
  throw new Error("Invalid pin number")
88
86
  }
@@ -104,7 +102,8 @@ export const quad = (
104
102
  i + 1,
105
103
  params.w,
106
104
  params.h,
107
- params.p ?? 0.5
105
+ params.p ?? 0.5,
106
+ params.pl
108
107
  )
109
108
 
110
109
  let pw = params.pw
@@ -130,5 +129,34 @@ export const quad = (
130
129
  }
131
130
  }
132
131
 
133
- return pads
132
+ // Silkscreen corners
133
+ const silkscreen_corners: PcbSilkscreenPath[] = []
134
+ for (let corner_index = 0; corner_index < 4; corner_index++) {
135
+ const dx = Math.floor(corner_index / 2) * 2 - 1
136
+ const dy = (corner_index % 2) * 2 - 1
137
+ const corner_x = (params.w / 2) * dx
138
+ const corner_y = (params.h / 2) * dy
139
+ silkscreen_corners.push({
140
+ layer: "top",
141
+ pcb_component_id: "",
142
+ pcb_silkscreen_path_id: `pcb_silkscreen_path_${corner_index}`,
143
+ route: [
144
+ {
145
+ x: corner_x - params.pw * dx,
146
+ y: corner_y,
147
+ },
148
+ {
149
+ x: corner_x,
150
+ y: corner_y,
151
+ },
152
+ {
153
+ x: corner_x,
154
+ y: corner_y - params.pw * dy,
155
+ },
156
+ ],
157
+ type: "pcb_silkscreen_path",
158
+ })
159
+ }
160
+
161
+ return [...pads, ...silkscreen_corners]
134
162
  }