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 @@ -78,3 +78,4 @@ export { sot } from "./sot"
export { sot343 } from "./sot343"
export { m2host } from "./m2host"
export { to92l } from "./to92l"
export { soj } from "./soj"
10 changes: 9 additions & 1 deletion src/fn/soic.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the change in the file soic.ts unrelated

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const extendSoicDef = (newDefaults: {
num_pins?: number
legsoutside?: boolean
pillpads?: boolean
reftextsize?: number
}) =>
base_def
.extend({
Expand All @@ -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")
Expand Down Expand Up @@ -135,7 +143,7 @@ export const soicWithoutParsing = (parameters: z.infer<typeof soic_def>) => {
const silkscreenRefText: SilkscreenRef = silkscreenRef(
0,
sh / 2 + 0.4,
sh / 12,
parameters.reftextsize ?? sh / 12,
)
const silkscreenBorder: PcbSilkscreenPath = {
type: "pcb_silkscreen_path",
Expand Down
26 changes: 26 additions & 0 deletions src/fn/soj.ts
Original file line number Diff line number Diff line change
@@ -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,
}
}
1 change: 1 addition & 0 deletions tests/__snapshots__/soj40_w18.3mm_p1.27mm.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.
1 change: 1 addition & 0 deletions tests/kicad-parity/__snapshots__/soj44_parity.snap.svg
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/soj_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/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",
)
})
12 changes: 12 additions & 0 deletions tests/soj.test.ts
Original file line number Diff line number Diff line change
@@ -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",
)
})