-
Notifications
You must be signed in to change notification settings - Fork 63
feat: add PDIP and SPDIP as separate footprint functions #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iprevail-io
wants to merge
3
commits into
tscircuit:main
Choose a base branch
from
iprevail-io:feat/pdip-spdip-aliases
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { AnyCircuitElement } from "circuit-json" | ||
| import { dip, extendDipDef } from "./dip" | ||
|
|
||
| export const pdip_def = extendDipDef({ | ||
| w: "300mil", | ||
| p: "2.54mm", | ||
| }) | ||
|
|
||
| export const pdip = ( | ||
| raw_params: Record<string, unknown>, | ||
| ): { circuitJson: AnyCircuitElement[]; parameters: any } => { | ||
| return dip(raw_params as any) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { AnyCircuitElement } from "circuit-json" | ||
| import { dip, extendDipDef } from "./dip" | ||
|
|
||
| export const spdip_def = extendDipDef({ | ||
| w: "300mil", | ||
| p: "1.778mm", | ||
| }) | ||
|
|
||
| export const spdip = ( | ||
| raw_params: Record<string, unknown>, | ||
| ): { circuitJson: AnyCircuitElement[]; parameters: any } => { | ||
| const parameters = spdip_def.parse(raw_params) | ||
| return dip({ ...parameters, dip: true } as any) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { test, expect } from "bun:test" | ||
| import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" | ||
| import { fp } from "../src/footprinter" | ||
| import type { AnyCircuitElement } from "circuit-json" | ||
|
|
||
| test("pdip8 generates 8 plated holes", () => { | ||
| const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[] | ||
| const platedHoles = circuitJson.filter((el) => el.type === "pcb_plated_hole") | ||
| expect(platedHoles.length).toBe(8) | ||
| }) | ||
|
|
||
| test("pdip8 has standard DIP pitch (2.54mm)", () => { | ||
| const params = fp.string("pdip8").json() | ||
| expect(params.p).toBeCloseTo(2.54, 2) | ||
| }) | ||
|
|
||
| test("PDIP8 case-insensitive", () => { | ||
| const uppercaseJson = fp.string("PDIP8").json() | ||
| const lowercaseJson = fp.string("pdip8").json() | ||
| expect(uppercaseJson).toEqual(lowercaseJson) | ||
| }) | ||
|
|
||
| test("pdip8 svg snapshot", () => { | ||
| const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[] | ||
| const svgContent = convertCircuitJsonToPcbSvg(circuitJson) | ||
| expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8") | ||
| }) | ||
|
|
||
| test("spdip28 generates 28 plated holes", () => { | ||
| const circuitJson = fp.string("spdip28").circuitJson() as AnyCircuitElement[] | ||
| const platedHoles = circuitJson.filter((el) => el.type === "pcb_plated_hole") | ||
| expect(platedHoles.length).toBe(28) | ||
| }) | ||
|
|
||
| test("spdip28 has shrink pitch (1.778mm)", () => { | ||
| const params = fp.string("spdip28").json() | ||
| expect(params.p).toBeCloseTo(1.778, 2) | ||
| }) | ||
|
|
||
| test("spdip28 svg snapshot", () => { | ||
| const circuitJson = fp.string("spdip28").circuitJson() as AnyCircuitElement[] | ||
| const svgContent = convertCircuitJsonToPcbSvg(circuitJson) | ||
| expect(svgContent).toMatchSvgSnapshot(import.meta.path, "spdip28") | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 (lines 6, 12, 18, 26, 32, and 38), which violates the rule that a *.test.ts file may have AT MOST one test(...). After the first test, the user should split into multiple numbered files. To fix this, split the tests into separate files like 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 (based on custom rule: Custom rule)

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