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
1 change: 1 addition & 0 deletions src/fn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ export { sot343 } from "./sot343"
export { m2host } from "./m2host"
export { mountedpcbmodule } from "./mountedpcbmodule"
export { to92l } from "./to92l"
export { pdip } from "./pdip"
24 changes: 24 additions & 0 deletions src/fn/pdip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { dip, extendDipDef } from "./dip"
import { z } from "zod"

export const pdip_def = extendDipDef({ w: "300mil", p: "2.54mm" }).extend({

Check failure on line 4 in src/fn/pdip.ts

View workflow job for this annotation

GitHub Actions / test

TypeError: extendDipDef({ w: "300mil"

})', 'extendDipDef({ w: "300mil", p: "2.54mm" }).extend' is undefined) at /home/runner/work/footprinter/footprinter/src/fn/pdip.ts:4:68 at loadAndEvaluateModule (2:1)
fn: z.string(),
})

export const pdip = (raw_params: {
pdip: true
num_pins: number
w: number
p?: number
id?: string | number
od?: string | number
}) => {
return dip({
dip: true,
num_pins: raw_params.num_pins,
w: raw_params.w,
p: raw_params.p,
id: raw_params.id,
od: raw_params.od,
})
}
3 changes: 3 additions & 0 deletions src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export type Footprinter = {
dip: (
num_pins?: number,
) => FootprinterParamsBuilder<"w" | "p" | "id" | "od" | "wide" | "narrow">
pdip: (
num_pins?: number,
) => FootprinterParamsBuilder<"w" | "p" | "id" | "od" | "wide" | "narrow">
cap: () => FootprinterParamsBuilder<CommonPassiveOptionKey>
crystal: (
num_pins?: number,
Expand Down
35 changes: 35 additions & 0 deletions tests/pdip.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, expect } from "bun:test"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { fp } from "../src/footprinter"
import type { AnyCircuitElement } from "circuit-json"

test("pdip8", () => {
const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8")
})

test("pdip8 matches dip8 with same defaults", () => {
const pdipJson = fp.string("pdip8").json()
const dipJson = fp.string("dip8").json()

expect(pdipJson.num_pins).toBe(8)
expect(pdipJson.w).toBe(dipJson.w)
expect(pdipJson.p).toBe(dipJson.p)
expect(pdipJson.id).toBe(dipJson.id)
expect(pdipJson.od).toBe(dipJson.od)
})

test("pdip8 with custom width", () => {
const circuitJson = fp
.string("pdip8_w7.62mm")
.circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8_w7.62mm")
})

test("pdip14", () => {
const circuitJson = fp.string("pdip14").circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip14")
})
Loading