From 8abd6b6b2c551d34380c0c21b3355a3a25e6fbe4 Mon Sep 17 00:00:00 2001 From: rushabhcodes Date: Sat, 22 Nov 2025 14:27:17 +0530 Subject: [PATCH 1/3] feat: enhance SOP-8 footprint definition and add tests for KiCad parity --- src/fn/sop8.ts | 15 ++++++++++----- tests/__snapshots__/sop8.snap.svg | 2 +- .../kicad-parity/__snapshots__/sop-8.snap.svg | 1 + .../sop-8_boolean_difference.snap.svg | 1 + tests/kicad-parity/sop8_kicad_parity.test.ts | 18 ++++++++++++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 tests/kicad-parity/__snapshots__/sop-8.snap.svg create mode 100644 tests/kicad-parity/__snapshots__/sop-8_boolean_difference.snap.svg create mode 100644 tests/kicad-parity/sop8_kicad_parity.test.ts diff --git a/src/fn/sop8.ts b/src/fn/sop8.ts index 8e855491..88c077ef 100644 --- a/src/fn/sop8.ts +++ b/src/fn/sop8.ts @@ -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({ @@ -49,7 +54,7 @@ export const sop8 = ( ...pads, silkscreenRefText, silkscreenLine, - ] as AnySoupElement[], + ] as AnyCircuitElement[], parameters, } } diff --git a/tests/__snapshots__/sop8.snap.svg b/tests/__snapshots__/sop8.snap.svg index 97cfee4a..3cd603b2 100644 --- a/tests/__snapshots__/sop8.snap.svg +++ b/tests/__snapshots__/sop8.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sop-8.snap.svg b/tests/kicad-parity/__snapshots__/sop-8.snap.svg new file mode 100644 index 00000000..b9900f6e --- /dev/null +++ b/tests/kicad-parity/__snapshots__/sop-8.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sop-8_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/sop-8_boolean_difference.snap.svg new file mode 100644 index 00000000..eea12f8f --- /dev/null +++ b/tests/kicad-parity/__snapshots__/sop-8_boolean_difference.snap.svg @@ -0,0 +1 @@ +SOP-8_3.76x4.96mm_P1.27mm - Alignment Analysis (Footprinter vs KiCad)sop8KiCad: SOP-8_3.76x4.96mm_P1.27mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/sop8_kicad_parity.test.ts b/tests/kicad-parity/sop8_kicad_parity.test.ts new file mode 100644 index 00000000..5845d99d --- /dev/null +++ b/tests/kicad-parity/sop8_kicad_parity.test.ts @@ -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", + ) +}) From e7806c988e5ba2cc39faa4323b21b4461f5c813b Mon Sep 17 00:00:00 2001 From: rushabhcodes Date: Sat, 22 Nov 2025 14:57:50 +0530 Subject: [PATCH 2/3] fix: update silkscreen reference position for SOP-8 footprint --- src/fn/sop8.ts | 2 +- tests/__snapshots__/sop8.snap.svg | 2 +- tests/kicad-parity/__snapshots__/sop-8.snap.svg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fn/sop8.ts b/src/fn/sop8.ts index 88c077ef..881144f0 100644 --- a/src/fn/sop8.ts +++ b/src/fn/sop8.ts @@ -33,7 +33,7 @@ export const sop8 = ( const sh = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, - sh / 2 - 0.5, + sh / 2 + 0.8, sh / 12, ) diff --git a/tests/__snapshots__/sop8.snap.svg b/tests/__snapshots__/sop8.snap.svg index 3cd603b2..3882e98a 100644 --- a/tests/__snapshots__/sop8.snap.svg +++ b/tests/__snapshots__/sop8.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sop-8.snap.svg b/tests/kicad-parity/__snapshots__/sop-8.snap.svg index b9900f6e..09280dda 100644 --- a/tests/kicad-parity/__snapshots__/sop-8.snap.svg +++ b/tests/kicad-parity/__snapshots__/sop-8.snap.svg @@ -1 +1 @@ -{REF}Diff: 0.00% \ No newline at end of file +{REF}Diff: 0.00% \ No newline at end of file From 2d385ebb12686cae3110a77f1c8a42267538fe08 Mon Sep 17 00:00:00 2001 From: rushabhcodes Date: Sun, 23 Nov 2025 23:14:21 +0530 Subject: [PATCH 3/3] fix: adjust silkscreen reference positions in SOP-8 footprint and update snapshots --- src/fn/sop8.ts | 10 +++------- tests/__snapshots__/sop8.snap.svg | 2 +- tests/kicad-parity/__snapshots__/sop-8.snap.svg | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/fn/sop8.ts b/src/fn/sop8.ts index 881144f0..93861fd3 100644 --- a/src/fn/sop8.ts +++ b/src/fn/sop8.ts @@ -31,11 +31,7 @@ export const sop8 = ( } const sh = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw - const silkscreenRefText: SilkscreenRef = silkscreenRef( - 0, - sh / 2 + 0.8, - sh / 12, - ) + const silkscreenRefText: SilkscreenRef = silkscreenRef(0, sh / 2 + 1, sh / 12) const silkscreenLine: PcbSilkscreenPath = { layer: "top", @@ -43,8 +39,8 @@ export const sop8 = ( 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, } diff --git a/tests/__snapshots__/sop8.snap.svg b/tests/__snapshots__/sop8.snap.svg index 3882e98a..bad2e9f8 100644 --- a/tests/__snapshots__/sop8.snap.svg +++ b/tests/__snapshots__/sop8.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sop-8.snap.svg b/tests/kicad-parity/__snapshots__/sop-8.snap.svg index 09280dda..130c3b40 100644 --- a/tests/kicad-parity/__snapshots__/sop-8.snap.svg +++ b/tests/kicad-parity/__snapshots__/sop-8.snap.svg @@ -1 +1 @@ -{REF}Diff: 0.00% \ No newline at end of file +{REF}Diff: 0.00% \ No newline at end of file