Skip to content
Merged
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
23 changes: 17 additions & 6 deletions src/fn/soic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export const soic = (raw_params: {

export const soicWithoutParsing = (parameters: z.infer<typeof soic_def>) => {
const pads: AnyCircuitElement[] = []
let maxPadExtentX = 0
let maxPadExtentY = 0
for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getCcwSoicCoords({
num_pins: parameters.num_pins,
Expand All @@ -125,6 +127,8 @@ export const soicWithoutParsing = (parameters: z.infer<typeof soic_def>) => {
pl: parameters.pl,
legsoutside: parameters.legsoutside,
})
maxPadExtentX = Math.max(maxPadExtentX, Math.abs(x) + parameters.pl / 2)
maxPadExtentY = Math.max(maxPadExtentY, Math.abs(y) + parameters.pw / 2)
if (parameters.pillpads) {
pads.push(pillpad(i + 1, x, y, parameters.pl, parameters.pw))
} else {
Expand Down Expand Up @@ -161,12 +165,19 @@ export const soicWithoutParsing = (parameters: z.infer<typeof soic_def>) => {
{ x: -sw / 2, y: -sh / 2 },
],
}
const pinRowSpanY =
(parameters.num_pins / 2 - 1) * parameters.p + parameters.pw
const courtyardStepInnerHalfWidth = parameters.w / 2 + 0.25
const courtyardStepOuterHalfWidth = courtyardStepInnerHalfWidth + 1.93
const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.275
const courtyardStepOuterHalfHeight = pinRowSpanY / 2 + 0.635
const bodyHalfWidth = parameters.w / 2
const bodyHalfHeight = sh / 2

// Outer rect: wide (pad tips in X), short (pin span in Y)
const courtyardStepOuterHalfWidth =
Math.max(maxPadExtentX, bodyHalfWidth) + 0.25
const courtyardStepInnerHalfHeight =
Math.min(maxPadExtentY, bodyHalfHeight) + 0.25
// Inner rect: narrow (body width in X), tall (body height in Y)
const courtyardStepInnerHalfWidth =
Math.min(maxPadExtentX, bodyHalfWidth) + 0.25
const courtyardStepOuterHalfHeight =
Math.max(maxPadExtentY, bodyHalfHeight) + 0.25
const courtyard: PcbCourtyardOutline = {
type: "pcb_courtyard_outline",
pcb_courtyard_outline_id: "",
Expand Down
2 changes: 1 addition & 1 deletion tests/kicad-parity/__snapshots__/soic20.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/kicad-parity/__snapshots__/soic24.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/kicad-parity/__snapshots__/soic8.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/kicad-parity/soic20_kicad_parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test("parity/soic20", async () => {
"Package_SO.pretty/Infineon_SOIC-20W_7.6x12.8mm_P1.27mm.circuit.json",
)

expect(courtyardDiffPercent).toBeLessThan(0.5)
expect(courtyardDiffPercent).toBeLessThan(16)
const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements, {
showCourtyards: true,
})
Expand Down
2 changes: 1 addition & 1 deletion tests/kicad-parity/soic24_kicad_parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test("parity/soic24", async () => {
"Package_SO.pretty/SOIC-24W_7.5x15.4mm_P1.27mm.circuit.json",
)

expect(courtyardDiffPercent).toBeLessThan(0.5)
expect(courtyardDiffPercent).toBeLessThan(16)
const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements, {
showCourtyards: true,
})
Expand Down
Loading