Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,23 +570,29 @@ export type Footprinter = {
}

const normalizeDefinition = (def: string): string => {
return def
.trim()
.replace(/^pinheader(?=[\d_]|$)/i, "pinrow")
.replace(/^d2pak(\d+)(?=_|$)/i, "d2pak_$1")
.replace(/^to-252(?:-(\d+))?(?=_|$)/i, (_, pins) =>
pins ? `to252_${pins}` : "to252",
)
.replace(/^to-263(?:-(\d+))?(?=_|$)/i, (_, pins) =>
pins ? `to263_${pins}` : "to263",
)
.replace(/^sot-23(?:-(\d+))?(?=_|$)/i, (_, pins) =>
pins ? `sot23_${pins}` : "sot23",
)
.replace(/^sot23-(\d+)(?=_|$)/i, "sot23_$1")
.replace(/^sot-223-(\d+)(?=_|$)/i, "sot223_$1")
.replace(/^to-220f-(\d+)(?=_|$)/i, "to220f_$1")
.replace(/^jst_(ph|sh|zh|xh)_(\d+)(?=_|$)/i, "jst$2_$1")
return (
def
.trim()
.replace(/^pinheader(?=[\d_]|$)/i, "pinrow")
.replace(/^d2pak(\d+)(?=_|$)/i, "d2pak_$1")
.replace(/^to-252(?:-(\d+))?(?=_|$)/i, (_, pins) =>
pins ? `to252_${pins}` : "to252",
)
.replace(/^to-263(?:-(\d+))?(?=_|$)/i, (_, pins) =>
pins ? `to263_${pins}` : "to263",
)
.replace(/^sot-23(?:-(\d+))?(?=_|$)/i, (_, pins) =>
pins ? `sot23_${pins}` : "sot23",
)
.replace(/^sot23-(\d+)(?=_|$)/i, "sot23_$1")
.replace(/^sot-223-(\d+)(?=_|$)/i, "sot223_$1")
.replace(/^to-220f-(\d+)(?=_|$)/i, "to220f_$1")
.replace(/^jst_(ph|sh|zh|xh)_(\d+)(?=_|$)/i, "jst$2_$1")
// PDIP/SPDIP are the same plastic/shouldered DIP land pattern the `dip`
// footprint already emits (KiCad DIP-8_W7.62mm).
.replace(/^(?:pdip|spdip)(\d+)(?=_|$)/i, "dip$1")
.replace(/^(?:pdip|spdip)(?=_|$)/i, "dip")
)
}

const normalizeMicrometerLengths = (value: string): string =>
Expand Down
23 changes: 23 additions & 0 deletions tests/pdip-alias.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { test, expect } from "bun:test"
import { fp } from "src/footprinter"

test("pdip and spdip aliases render the standard DIP layout (#371)", () => {
for (const name of ["pdip8", "spdip8", "pdip16"]) {
const circuitJson = fp.string(name).circuitJson()
const pads = circuitJson.filter(
(el: any) => el.type === "pcb_plated_hole" || el.type === "pcb_smtpad",
)
const expected = Number.parseInt(name.replace(/\D/g, ""), 10)
expect(pads.length, `${name} should render ${expected} pads`).toBe(expected)
}

// same geometry as the equivalent dip footprint
const pdip = fp.string("pdip8").circuitJson()
const dip = fp.string("dip8").circuitJson()
const xs = (j: any) =>
j
.filter((el: any) => el.type === "pcb_plated_hole")
.map((el: any) => el.x)
.sort()
expect(xs(pdip)).toEqual(xs(dip))
})
Loading