Skip to content

Commit

Permalink
added SOP-8 (#128)
Browse files Browse the repository at this point in the history
* added SOP-8

* Added SOP-8
  • Loading branch information
Rishikesh63 authored Feb 5, 2025
1 parent 6c339f6 commit eb9077e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fn/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { sop8 } from "./sop8"
export { dip } from "./dip"
export { diode } from "./diode"
export { cap } from "./cap"
Expand Down Expand Up @@ -31,3 +32,4 @@ export { breakoutheaders } from "./breakoutheaders"
export { hc49 } from "./hc49"
export { pad } from "./pad"
export { to92 } from "./to92"
export { sop8 } from "./sop8"
55 changes: 55 additions & 0 deletions src/fn/sop8.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { AnySoupElement, PcbSilkscreenPath } from "circuit-json"
import { extendSoicDef, type SoicInput, getCcwSoicCoords } from "./soic"
import { rectpad } from "src/helpers/rectpad"
import { type SilkscreenRef, silkscreenRef } from "src/helpers/silkscreenRef"

export const sop8_def = extendSoicDef({})

export const sop8 = (
raw_params: SoicInput,
): { circuitJson: AnySoupElement[]; parameters: any } => {
const parameters = sop8_def.parse(raw_params)
const pads: AnySoupElement[] = []

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getCcwSoicCoords({
num_pins: parameters.num_pins,
pn: i + 1,
w: parameters.w,
p: parameters.p ?? 1.27,
pl: parameters.pl,
widthincludeslegs: true,
})
pads.push(
rectpad(i + 1, x, y, parameters.pl ?? "1.5mm", parameters.pw ?? "0.6mm"),
)
}

const sh = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw
const silkscreenRefText: SilkscreenRef = silkscreenRef(
0,
sh / 2 - 0.5,
sh / 12,
)

const silkscreenLine: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
pcb_silkscreen_path_id: "",
type: "pcb_silkscreen_path",
route: [
{ x: -parameters.w / 3, y: sh / 2 + 0.2 },
{ x: parameters.w / 3, y: sh / 2 + 0.2 },
],
stroke_width: 0.1,
}

return {
circuitJson: [
...pads,
silkscreenRefText,
silkscreenLine,
] as AnySoupElement[],
parameters,
}
}
13 changes: 13 additions & 0 deletions tests/__snapshots__/sop8.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions tests/sop8.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "bun:test"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { fp } from "../src/footprinter"

test("sop8", () => {
const soup = fp.string("sop8").circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(soup)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "sop8")
})

0 comments on commit eb9077e

Please sign in to comment.