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
25 changes: 13 additions & 12 deletions src/fn/sop8.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import type { AnySoupElement, PcbSilkscreenPath } from "circuit-json"
import type { AnyCircuitElement, 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_def = extendSoicDef({
w: "7.05mm",
p: "1.27mm",
pw: "0.65mm",
pl: "1.975mm",
})

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

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getCcwSoicCoords({
Expand All @@ -26,20 +31,16 @@ export const sop8 = (
}

const sh = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw
const silkscreenRefText: SilkscreenRef = silkscreenRef(
0,
sh / 2 - 0.5,
sh / 12,
)
const silkscreenRefText: SilkscreenRef = silkscreenRef(0, sh / 2 + 1, 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 },
{ x: -parameters.w / 3, y: sh / 2 + 0.4 },
{ x: parameters.w / 3, y: sh / 2 + 0.4 },
],
stroke_width: 0.1,
}
Expand All @@ -49,7 +50,7 @@ export const sop8 = (
...pads,
silkscreenRefText,
silkscreenLine,
] as AnySoupElement[],
] as AnyCircuitElement[],
parameters,
}
}
2 changes: 1 addition & 1 deletion 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.
1 change: 1 addition & 0 deletions tests/kicad-parity/__snapshots__/sop-8.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions tests/kicad-parity/sop8_kicad_parity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from "bun:test"
import { compareFootprinterVsKicad } from "../fixtures/compareFootprinterVsKicad"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"

test("parity/sop-8", async () => {
const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } =
await compareFootprinterVsKicad(
"sop8",
"Package_SO.pretty/SOP-8_3.76x4.96mm_P1.27mm.circuit.json",
)

const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "sop-8")
expect(booleanDifferenceSvg).toMatchSvgSnapshot(
import.meta.path,
"sop-8_boolean_difference",
)
})