-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from tscircuit/layerflip
Support Flipping Components to Bottom Layer
- Loading branch information
Showing
10 changed files
with
186 additions
and
24 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
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
13 changes: 13 additions & 0 deletions
13
tests/components/normal-components/__snapshots__/chip-layer-flip-pcb.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions
65
tests/components/normal-components/chip-layer-flip.test.tsx
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,65 @@ | ||
import { test, expect } from "bun:test" | ||
import { getTestFixture } from "tests/fixtures/get-test-fixture" | ||
|
||
test("chip with manual footprint flips when layer is set to bottom", async () => { | ||
const { project } = getTestFixture() | ||
|
||
const footprint = ( | ||
<footprint> | ||
<smtpad | ||
shape="rect" | ||
width="0.5mm" | ||
height="0.5mm" | ||
pcbX={1} | ||
pcbY={1} | ||
portHints={["1"]} | ||
/> | ||
<smtpad | ||
shape="rect" | ||
width="0.3mm" | ||
height="0.3mm" | ||
pcbX={1} | ||
pcbY={-1} | ||
portHints={["2"]} | ||
/> | ||
<smtpad | ||
shape="rect" | ||
width="0.1mm" | ||
height="0.1mm" | ||
pcbX={-0.5} | ||
pcbY={0.1} | ||
portHints={["3"]} | ||
/> | ||
<silkscreentext | ||
pcbX={1} | ||
pcbY={0} | ||
anchorAlignment="center" | ||
fontSize={0.2} | ||
text="hi" | ||
/> | ||
</footprint> | ||
) | ||
|
||
project.add( | ||
<board width="7mm" height="3mm"> | ||
<chip name="U1" pcbX={-2} layer="bottom" footprint={footprint} /> | ||
<chip name="U2" pcbX={2} layer="top" footprint={footprint} /> | ||
</board>, | ||
) | ||
|
||
project.render() | ||
|
||
// Check if all SMT pads are on the bottom layer | ||
const smtPads = project.db.pcb_smtpad | ||
.list() | ||
.filter((pad) => pad.layer === "bottom") | ||
expect(smtPads.length).toBe(3) | ||
|
||
// Check if the positions are mirrored | ||
const padPositions = smtPads.map((pad) => ({ x: pad.x, y: pad.y })) | ||
expect(padPositions).toContainEqual({ x: -3, y: 1 }) | ||
expect(padPositions).toContainEqual({ x: -3, y: -1 }) | ||
|
||
// Use snapshot to verify the overall layout | ||
expect(project).toMatchPcbSnapshot(import.meta.path) | ||
}) |
Oops, something went wrong.