Skip to content

feat: add PDIP footprint support#474

Open
Kemalyavas wants to merge 4 commits intotscircuit:mainfrom
Kemalyavas:feat/add-pdip-footprint
Open

feat: add PDIP footprint support#474
Kemalyavas wants to merge 4 commits intotscircuit:mainfrom
Kemalyavas:feat/add-pdip-footprint

Conversation

@Kemalyavas
Copy link

Summary

  • Add support for PDIP (Plastic Dual In-line Package) footprint string
  • PDIP is a standard alias for DIP packages, commonly used in datasheets
  • Supports all DIP variants: pdip8, pdip14, pdip16, pdip8_wide, etc.

Changes

  • src/fn/pdip.ts - New file that exports DIP as PDIP alias
  • src/fn/index.ts - Export pdip function
  • src/footprinter.ts - Add pdip type definition
  • tests/pdip.test.ts - Tests for pdip8, pdip14, pdip16, pdip8_wide

Test Plan

  • All 345 existing tests pass
  • 6 new pdip tests pass
  • pdip8 parameters match dip8 parameters
  • Case-insensitive: PDIP8 resolves same as pdip8

Closes #371

/claim #371

Add support for PDIP (Plastic Dual In-line Package) footprint string.
PDIP is an alias for DIP packages, commonly used in datasheets and component listings.

Closes tscircuit#371
Comment on lines 6 to 48
test("pdip8 footprint", () => {
const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8")
})

test("pdip8 parameters match dip8", () => {
const pdipJson = fp.string("pdip8").json()
const dipJson = fp.string("dip8").json()

// PDIP should have same parameters as DIP (except fn name)
expect(pdipJson.num_pins).toBe(dipJson.num_pins)
expect(pdipJson.w).toBe(dipJson.w)
expect(pdipJson.p).toBe(dipJson.p)
expect(pdipJson.id).toBe(dipJson.id)
expect(pdipJson.od).toBe(dipJson.od)
})

test("pdip14 footprint", () => {
const circuitJson = fp.string("pdip14").circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip14")
})

test("pdip16 footprint", () => {
const circuitJson = fp.string("pdip16").circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip16")
})

test("pdip8_wide footprint", () => {
const circuitJson = fp
.string("pdip8_wide")
.circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8_wide")
})

test("PDIP8 string resolves using lowercase function", () => {
const uppercaseJson = fp.string("PDIP8").json()
const lowercaseJson = fp.string("pdip8").json()
expect(uppercaseJson).toEqual(lowercaseJson)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

This test file contains 6 test functions, which violates the rule that a *.test.ts file may have AT MOST one test(...). The file should be split into multiple numbered files such as pdip1.test.ts, pdip2.test.ts, pdip3.test.ts, pdip4.test.ts, pdip5.test.ts, and pdip6.test.ts, with each file containing only one test function.

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

Fix in Graphite


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

Copy link
Contributor

@rushabhcodes rushabhcodes left a comment

Choose a reason for hiding this comment

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

also add kicad parity test, see others for ref

src/fn/pdip.ts Outdated
Comment on lines 1 to 20
/**
* PDIP (Plastic Dual In-line Package) footprint
*
* PDIP is the standard plastic version of DIP packages.
* Common variants: PDIP-8, PDIP-14, PDIP-16, PDIP-20, PDIP-28, etc.
*
* Standard specifications:
* - Pin pitch: 2.54mm (100 mil)
* - Row spacing: 7.62mm (300 mil) for narrow, 15.24mm (600 mil) for wide
*/

import { dip, dip_def, extendDipDef, getCcwDipCoords } from "./dip"

// PDIP uses the same implementation as DIP
export const pdip = dip

// Export the definition for type compatibility
export const pdip_def = dip_def
export const extendPdipDef = extendDipDef
export const getCcwPdipCoords = getCcwDipCoords
Copy link
Member

Choose a reason for hiding this comment

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

please follow code maintainability

src/fn/pdip.ts Outdated
Comment on lines 1 to 10
/**
* PDIP (Plastic Dual In-line Package) footprint
*
* PDIP is the standard plastic version of DIP packages.
* Common variants: PDIP-8, PDIP-14, PDIP-16, PDIP-20, PDIP-28, etc.
*
* Standard specifications:
* - Pin pitch: 2.54mm (100 mil)
* - Row spacing: 7.62mm (300 mil) for narrow, 15.24mm (600 mil) for wide
*/
Copy link
Member

Choose a reason for hiding this comment

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

Unrelavent comment, if you need describe use .describe()

Copy link
Member

@techmannih techmannih left a comment

Choose a reason for hiding this comment

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

See Comments

Comment on lines 5 to 17
test("parity/pdip8", async () => {
const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } =
await compareFootprinterVsKicad(
"pdip8_w7.62mm",
"Package_DIP.pretty/DIP-8_W7.62mm.circuit.json",
)

const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8")
expect(booleanDifferenceSvg).toMatchSvgSnapshot(
import.meta.path,
"pdip8_boolean_difference",
)
Copy link
Member

Choose a reason for hiding this comment

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

Adding pdip and comparing with dip, this is incorrect

PDIP is an alias for DIP (Plastic Dual In-line Package), so there's no
separate PDIP footprint in KiCAD library. Instead, added a test that
verifies pdip produces identical circuit json as dip.
@Kemalyavas
Copy link
Author

Thanks for the feedback! You're right - I've replaced the KiCAD parity test.

PDIP (Plastic Dual In-line Package) is just an alias for DIP - they have identical physical dimensions. KiCAD library doesn't have separate PDIP footprints because they're the same as DIP.

Instead, I've added an alias verification test (pdip7.test.ts) that confirms pdip8 produces identical circuit JSON as dip8. This is more appropriate since PDIP is purely an alias.

Copy link
Member

@techmannih techmannih left a comment

Choose a reason for hiding this comment

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

are the pdip and dip same?

@Kemalyavas
Copy link
Author

Yes, PDIP and DIP are the same physically.

PDIP = Plastic Dual In-line Package

It's just a more specific naming convention used in datasheets to indicate the package material is plastic (as opposed to CDIP = Ceramic DIP). The pin pitch (2.54mm) and row spacing (7.62mm for narrow, 15.24mm for wide) are identical.

Many component datasheets use "PDIP-8" instead of "DIP-8", so having this alias makes it easier to match footprint names with datasheet terminology.

@Kemalyavas
Copy link
Author

Friendly ping for review! I've addressed all the feedback - removed unnecessary comments and added an alias verification test instead of KiCAD parity test (since PDIP is just an alias for DIP). Ready for another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement PDIP-8

3 participants