diff --git a/src/fn/index.ts b/src/fn/index.ts index 07668c12..e95c0b94 100644 --- a/src/fn/index.ts +++ b/src/fn/index.ts @@ -78,3 +78,4 @@ export { sot } from "./sot" export { sot343 } from "./sot343" export { m2host } from "./m2host" export { to92l } from "./to92l" +export { soj } from "./soj" diff --git a/src/fn/soic.ts b/src/fn/soic.ts index a324887b..1e468e1e 100644 --- a/src/fn/soic.ts +++ b/src/fn/soic.ts @@ -16,6 +16,7 @@ export const extendSoicDef = (newDefaults: { num_pins?: number legsoutside?: boolean pillpads?: boolean + reftextsize?: number }) => base_def .extend({ @@ -33,9 +34,16 @@ export const extendSoicDef = (newDefaults: { .boolean() .optional() .default(newDefaults.pillpads ?? false), + reftextsize: z.number().optional(), silkscreen_stroke_width: z.number().optional().default(0.1), }) .transform((v) => { + if ( + v.reftextsize === undefined && + newDefaults.reftextsize !== undefined + ) { + v.reftextsize = newDefaults.reftextsize + } // Default inner diameter and outer diameter if (!v.pw && !v.pl) { v.pw = length.parse("0.6mm") @@ -135,7 +143,7 @@ export const soicWithoutParsing = (parameters: z.infer) => { const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, sh / 2 + 0.4, - sh / 12, + parameters.reftextsize ?? sh / 12, ) const silkscreenBorder: PcbSilkscreenPath = { type: "pcb_silkscreen_path", diff --git a/src/fn/soj.ts b/src/fn/soj.ts new file mode 100644 index 00000000..db8793f9 --- /dev/null +++ b/src/fn/soj.ts @@ -0,0 +1,26 @@ +import type { AnyCircuitElement } from "circuit-json" +import { extendSoicDef, soicWithoutParsing } from "./soic" + +export const soj_def = extendSoicDef({ + legsoutside: false, + pw: "0.6mm", + pl: "2.1mm", +}) + +export const soj = ( + raw_params: any, +): { circuitJson: AnyCircuitElement[]; parameters: any } => { + const parameters = soj_def.parse(raw_params) + parameters.w += 1.8 + + const m = Math.min(1, parameters.p / 2) + const sh = + (parameters.num_pins / 2 - 1) * parameters.p + (parameters.pw ?? 0.6) + m + + parameters.reftextsize = Math.max(0.5, Math.min(0.7, sh / 12)) + + return { + circuitJson: soicWithoutParsing(parameters), + parameters, + } +} diff --git a/tests/__snapshots__/soj40_w18.3mm_p1.27mm.snap.svg b/tests/__snapshots__/soj40_w18.3mm_p1.27mm.snap.svg new file mode 100644 index 00000000..0994a3ea --- /dev/null +++ b/tests/__snapshots__/soj40_w18.3mm_p1.27mm.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/soj44_parity._boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/soj44_parity._boolean_difference.snap.svg new file mode 100644 index 00000000..a5fdd34c --- /dev/null +++ b/tests/kicad-parity/__snapshots__/soj44_parity._boolean_difference.snap.svg @@ -0,0 +1 @@ +SOJ-44_10.16x28.575mm_P1.27mm - Alignment Analysis (Footprinter vs KiCad)soj44_w10.16mm_p1.27mmKiCad: SOJ-44_10.16x28.575mm_P1.27mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/soj44_parity.snap.svg b/tests/kicad-parity/__snapshots__/soj44_parity.snap.svg new file mode 100644 index 00000000..212a866c --- /dev/null +++ b/tests/kicad-parity/__snapshots__/soj44_parity.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 1.18% \ No newline at end of file diff --git a/tests/kicad-parity/soj_kicad_parity.test.ts b/tests/kicad-parity/soj_kicad_parity.test.ts new file mode 100644 index 00000000..ba80179c --- /dev/null +++ b/tests/kicad-parity/soj_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/soj44", async () => { + const { combinedFootprintElements, booleanDifferenceSvg } = + await compareFootprinterVsKicad( + "soj44_w10.16mm_p1.27mm", + "Package_SO.pretty/SOJ-44_10.16x28.575mm_P1.27mm.circuit.json", + ) + + const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements) + expect(svgContent).toMatchSvgSnapshot(import.meta.path, "soj44_parity") + expect(booleanDifferenceSvg).toMatchSvgSnapshot( + import.meta.path, + "soj44_parity._boolean_difference", + ) +}) diff --git a/tests/soj.test.ts b/tests/soj.test.ts new file mode 100644 index 00000000..586cc047 --- /dev/null +++ b/tests/soj.test.ts @@ -0,0 +1,12 @@ +import { test, expect } from "bun:test" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" +import { fp } from "../src/footprinter" + +test("soj40_w18.3mm_p1.27mm", () => { + const soup = fp.string("soj40_w18.3mm_p1.27mm").circuitJson() + const svgContent = convertCircuitJsonToPcbSvg(soup) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "soj40_w18.3mm_p1.27mm", + ) +})