-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Introduce pad for a simple single-pin pad (#115)
* feat: introduce pad for simple single-pin pad (#114) * feat: fix pad.test * feat: add single-pin pad footprint- Add pad footprint with configurable width and height- Add snapshot tests verifying dimensions- Position reference text above pad- Integrate with footprinter system * format * fix: slop test * chore: output come in snapshot folder * Chore: Use toMatchInlineSnapshot * Fix: TypeScript not recognizing the * Reverted .github/workflows/bun-formatcheck.yml to its original state * Remove redudant version specification
- Loading branch information
1 parent
555fe10
commit 77c16ca
Showing
10 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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,26 @@ | ||
import { z } from "zod" | ||
import { rectpad } from "../helpers/rectpad" | ||
import { silkscreenRef } from "../helpers/silkscreenRef" | ||
import type { AnySoupElement } from "circuit-json" | ||
import { length } from "circuit-json" | ||
import { mm } from "@tscircuit/mm" | ||
|
||
export const pad_def = z.object({ | ||
w: length, | ||
h: length, | ||
}) | ||
|
||
export type PadDef = z.input<typeof pad_def> | ||
|
||
export const pad = (params: PadDef): { circuitJson: AnySoupElement[] } => { | ||
const { w, h } = params | ||
const width = mm(w) | ||
const height = mm(h) | ||
|
||
return { | ||
circuitJson: [ | ||
rectpad(1, 0, 0, width, height), | ||
silkscreenRef(0, height / 2 + 0.5, 0.2), | ||
], | ||
} | ||
} |
This file contains 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 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 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 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,77 @@ | ||
import { expect, test } from "bun:test" | ||
import { fp } from "../src/footprinter" | ||
import { getTestFixture } from "./fixtures/get-test-fixture" | ||
|
||
test("pad footprint", async () => { | ||
const { snapshotSoup } = await getTestFixture("pad") | ||
const soup = fp().pad().w(2).h(1).circuitJson() | ||
expect(soup).toMatchInlineSnapshot(` | ||
[ | ||
{ | ||
"height": 1, | ||
"layer": "top", | ||
"pcb_smtpad_id": "", | ||
"port_hints": [ | ||
"1", | ||
], | ||
"shape": "rect", | ||
"type": "pcb_smtpad", | ||
"width": 2, | ||
"x": 0, | ||
"y": 0, | ||
}, | ||
{ | ||
"anchor_alignment": "center", | ||
"anchor_position": { | ||
"x": 0, | ||
"y": 1, | ||
}, | ||
"font": "tscircuit2024", | ||
"font_size": 0.2, | ||
"layer": "top", | ||
"pcb_component_id": "pcb_component_1", | ||
"pcb_silkscreen_text_id": "silkscreen_text_1", | ||
"text": "{REF}", | ||
"type": "pcb_silkscreen_text", | ||
}, | ||
] | ||
`) | ||
snapshotSoup(soup) | ||
}) | ||
|
||
test("pad footprint with different dimensions", async () => { | ||
const { snapshotSoup } = await getTestFixture("pad_3x2") | ||
const soup = fp().pad().w(3).h(2).circuitJson() | ||
expect(soup).toMatchInlineSnapshot(` | ||
[ | ||
{ | ||
"height": 2, | ||
"layer": "top", | ||
"pcb_smtpad_id": "", | ||
"port_hints": [ | ||
"1", | ||
], | ||
"shape": "rect", | ||
"type": "pcb_smtpad", | ||
"width": 3, | ||
"x": 0, | ||
"y": 0, | ||
}, | ||
{ | ||
"anchor_alignment": "center", | ||
"anchor_position": { | ||
"x": 0, | ||
"y": 1.5, | ||
}, | ||
"font": "tscircuit2024", | ||
"font_size": 0.2, | ||
"layer": "top", | ||
"pcb_component_id": "pcb_component_1", | ||
"pcb_silkscreen_text_id": "silkscreen_text_1", | ||
"text": "{REF}", | ||
"type": "pcb_silkscreen_text", | ||
}, | ||
] | ||
`) | ||
snapshotSoup(soup) | ||
}) |
This file contains 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