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 { plcc } from "./plcc"
33 changes: 33 additions & 0 deletions src/fn/plcc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { AnyCircuitElement } from "circuit-json"
import { quad, quad_def } from "./quad"
import type { z } from "zod"

export const plcc_def = quad_def

export const plcc = (
raw_params: z.input<typeof quad_def>,
): { circuitJson: AnyCircuitElement[]; parameters: any } => {
if (!raw_params.p) {
raw_params.p = 1.27
}

if (!raw_params.pl) {
raw_params.pl = 1.7
}

if (!raw_params.pw) {
raw_params.pw = 0.6
}

if (raw_params.pcdfe === undefined && raw_params.w) {
const w =
typeof raw_params.w === "number"
? raw_params.w
: parseFloat(raw_params.w as string)
if (!isNaN(w)) {
raw_params.pcdfe = 8.0 - w / 2
}
}

return quad(raw_params)
}
16 changes: 10 additions & 6 deletions src/fn/quad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const base_quad_def = base_def.extend({
pl: length.optional(),
thermalpad: z.union([z.literal(true), dim2d]).optional(),
legsoutside: z.boolean().default(false),
pcdfe: length.optional(),
Copy link
Member

Choose a reason for hiding this comment

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

What is this one?

Copy link
Author

Choose a reason for hiding this comment

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

its Pad Center Distance From Edge, actaully my parity test was failing as you know in pr.

I have introduced this to dyanmically able to change position of pads from center.

Earlier there was only one option of legsoutside?: boolean but this was enough to perfectly place pads to kikad footprint.

I have take care for other taste to not break.

Copy link
Author

Choose a reason for hiding this comment

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

Should i Add comments for this ?

Copy link
Member

Choose a reason for hiding this comment

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

@Sahil-Gupta584 if you are using this flags then please describe it with . describe()

})

export const quadTransform = <T extends z.infer<typeof base_quad_def>>(
Expand Down Expand Up @@ -81,8 +82,9 @@ export const getQuadCoords = (params: {
p: number // pitch between pins
pl: number // length of the pin
legsoutside?: boolean
pcdfe?: number
}) => {
const { pin_count, pn, w, h, p, pl, legsoutside } = params
const { pin_count, pn, w, h, p, pl, legsoutside, pcdfe: pcdfe_param } = params
const sidePinCount = pin_count / 4
const side = SIDES_CCW[Math.floor((pn - 1) / sidePinCount)]
const pos = (pn - 1) % sidePinCount
Expand All @@ -93,17 +95,18 @@ export const getQuadCoords = (params: {
const ibh = p * (sidePinCount - 1)

/** pad center distance from edge (negative is inside, positive is outside) */
const pcdfe = legsoutside ? pl / 2 : -pl / 2
const pcdfe = pcdfe_param ?? (legsoutside ? pl / 2 : -pl / 2)
const offset = pcdfe_param === undefined ? 0.1 : 0

switch (side) {
case "left":
return { x: -w / 2 - pcdfe + 0.1, y: ibh / 2 - pos * p, o: "vert" }
return { x: -w / 2 - pcdfe + offset, y: ibh / 2 - pos * p, o: "vert" }
case "bottom":
return { x: -ibw / 2 + pos * p, y: -h / 2 - pcdfe + 0.1, o: "horz" }
return { x: -ibw / 2 + pos * p, y: -h / 2 - pcdfe + offset, o: "horz" }
case "right":
return { x: w / 2 + pcdfe - 0.1, y: -ibh / 2 + pos * p, o: "vert" }
return { x: w / 2 + pcdfe - offset, y: -ibh / 2 + pos * p, o: "vert" }
case "top":
return { x: ibw / 2 - pos * p, y: h / 2 + pcdfe - 0.1, o: "horz" }
return { x: ibw / 2 - pos * p, y: h / 2 + pcdfe - offset, o: "horz" }
default:
throw new Error("Invalid pin number")
}
Expand All @@ -130,6 +133,7 @@ export const quad = (
p: parameters.p ?? 0.5,
pl: parameters.pl,
legsoutside: parameters.legsoutside,
pcdfe: parameters.pcdfe,
})

let pw = parameters.pw
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/plcc44_w16.5_h16.5_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__/plcc44_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/plcc_kikac_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/plcc44", async () => {
const { combinedFootprintElements, booleanDifferenceSvg } =
await compareFootprinterVsKicad(
"plcc44_w16.6_h16.6_p1.27mm",
"Package_LCC.pretty/PLCC-44_16.6x16.6mm_P1.27mm.circuit.json",
)

const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "plcc44_parity")
expect(booleanDifferenceSvg).toMatchSvgSnapshot(
import.meta.path,
"plcc44_parity._boolean_difference",
)
})
Comment on lines +1 to +18
Copy link
Contributor

Choose a reason for hiding this comment

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

The test file name 'plcc_kikac_parity.test.ts' contains a typo ('kikac' instead of 'kicad') and doesn't follow proper kebab-case naming convention. The file name should be consistent with the project naming standards and should be 'plcc-kicad-parity.test.ts' to match kebab-case convention and correct the spelling error.

Spotted by Graphite Agent (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Member

Choose a reason for hiding this comment

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

@Sahil-Gupta584 your test file name is wrong.

Copy link
Author

Choose a reason for hiding this comment

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

ohh my bad

12 changes: 12 additions & 0 deletions tests/plcc.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("plcc44_w16.5_h16.5_p1.27mm", () => {
const soup = fp.string("plcc44_w16.5_h16.5_p1.27mm").circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(soup)
expect(svgContent).toMatchSvgSnapshot(
import.meta.path,
"plcc44_w16.5_h16.5_p1.27mm",
)
})