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 @@ -81,3 +81,4 @@ export { sot343 } from "./sot343"
export { m2host } from "./m2host"
export { mountedpcbmodule } from "./mountedpcbmodule"
export { to92l } from "./to92l"
export { spdip } from "./spdip"
16 changes: 16 additions & 0 deletions src/fn/spdip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { AnyCircuitElement } from "circuit-json"
import { dip, extendDipDef } from "./dip"

export const spdip_def = extendDipDef({ w: "300mil", p: "1.778mm" })

export const spdip = (
raw_params: any,
): { circuitJson: AnyCircuitElement[]; parameters: any } => {
const parameters = spdip_def.parse(raw_params)
// Standard SDIP/SPDIP packages have smaller pad sizes to prevent overlap.
if (raw_params.id === undefined && raw_params.od === undefined) {
parameters.id = 0.7
parameters.od = 1.3
}
return dip({ ...parameters, dip: true } as any)
}
6 changes: 6 additions & 0 deletions src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ 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">
spdip: (
num_pins?: number,
) => FootprinterParamsBuilder<"w" | "p" | "id" | "od" | "wide" | "narrow">
cap: () => FootprinterParamsBuilder<CommonPassiveOptionKey>
res: () => FootprinterParamsBuilder<CommonPassiveOptionKey>
diode: () => FootprinterParamsBuilder<CommonPassiveOptionKey>
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/spdip28.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions tests/spdip.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect, test } from "bun:test"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { fp } from "../src/footprinter"

test("spdip28", () => {
const circuitJson = fp.string("spdip28").circuitJson()

// Exclude silkscreen path and courtyard to find only plated holes
const holes = circuitJson.filter((e: any) => e.type === "pcb_plated_hole")
expect(holes.length).toBe(28)

// Verify that row spacing is 300mil (7.62mm)
// Pin 1 (left row) and Pin 28 (right row) should have x-distance of 7.62mm
const pin1 = holes.find((h: any) => h.port_hints?.includes("1"))
const pin28 = holes.find((h: any) => h.port_hints?.includes("28"))
expect(pin1).toBeDefined()
expect(pin28).toBeDefined()
expect(Math.abs(pin28.x - pin1.x)).toBeCloseTo(7.62, 3)

// Verify that pin pitch is 1.778mm
// Pin 1 and Pin 2 (adjacent pins on same side) should have y-distance of 1.778mm
const pin2 = holes.find((h: any) => h.port_hints?.includes("2"))
expect(pin2).toBeDefined()
expect(Math.abs(pin2.y - pin1.y)).toBeCloseTo(1.778, 3)

const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "spdip28")
})

test("spdip (default 6 pins)", () => {
const circuitJson = fp.string("spdip").circuitJson()
const holes = circuitJson.filter((e: any) => e.type === "pcb_plated_hole")
expect(holes.length).toBe(6)
})
Loading