Skip to content

Commit 9613597

Browse files
rename + default trace margin
1 parent 6430f34 commit 9613597

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { checkEachPcbPortConnected } from "./lib/check-each-pcb-port-connected"
22
export { checkEachPcbTraceNonOverlapping } from "./lib/check-each-pcb-trace-non-overlapping/check-each-pcb-trace-non-overlapping"
33
export { NetManager } from "./lib/net-manager"
4-
export { checkViasOutOfBoard } from "./lib/check-pcb-components-out-of-board/checkViasOutOfBoard"
4+
export { checkViasOutOfBoard } from "./lib/check-pcb-components-out-of-board/checkViasOffBoard"

lib/check-pcb-components-out-of-board/checkViasOutOfBoard.ts renamed to lib/check-pcb-components-out-of-board/checkViasOffBoard.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import type {
55
PcbPlacementError,
66
} from "circuit-json"
77
import { getReadableNameForElement } from "@tscircuit/circuit-json-util"
8+
import { DEFAULT_VIA_BOARD_MARGIN } from "lib/drc-defaults"
89

9-
export function checkViasOutOfBoard(
10+
export function checkViasOffBoard(
1011
circuitJson: AnyCircuitElement[],
1112
): PcbPlacementError[] {
1213
const board = circuitJson.find((el) => el.type === "pcb_board") as PcbBoard
@@ -32,10 +33,10 @@ export function checkViasOutOfBoard(
3233
const viaMaxY = via.y + viaRadius
3334

3435
if (
35-
viaMinX < boardMinX ||
36-
viaMaxX > boardMaxX ||
37-
viaMinY < boardMinY ||
38-
viaMaxY > boardMaxY
36+
viaMinX < boardMinX + DEFAULT_VIA_BOARD_MARGIN ||
37+
viaMaxX > boardMaxX - DEFAULT_VIA_BOARD_MARGIN ||
38+
viaMinY < boardMinY + DEFAULT_VIA_BOARD_MARGIN ||
39+
viaMaxY > boardMaxY - DEFAULT_VIA_BOARD_MARGIN
3940
) {
4041
const viaName = getReadableNameForElement(circuitJson, via.pcb_via_id)
4142
errors.push({

lib/check-vias-out-of-board/checkViasOutOfBoard.ts

Whitespace-only changes.

lib/drc-defaults.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const DEFAULT_TRACE_MARGIN = 0.1
22
export const DEFAULT_TRACE_THICKNESS = 0.15
33
export const DEFAULT_VIA_DIAMETER = 0.6
4+
export const DEFAULT_VIA_BOARD_MARGIN = 0.3
45

56
export const EPSILON = 0.005

tests/lib/check-vias-out-of-board.test.ts renamed to tests/lib/check-vias-off-board.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "bun:test"
22
import type { AnyCircuitElement, PcbPlacementError } from "circuit-json"
3-
import { checkViasOutOfBoard } from "lib/check-pcb-components-out-of-board/checkViasOutOfBoard"
3+
import { checkViasOffBoard } from "lib/check-pcb-components-out-of-board/checkViasOffBoard"
44

55
test("no board, should return no errors", () => {
66
const soup: AnyCircuitElement[] = [
@@ -14,7 +14,7 @@ test("no board, should return no errors", () => {
1414
layers: ["top", "bottom"],
1515
},
1616
]
17-
const errors = checkViasOutOfBoard(soup)
17+
const errors = checkViasOffBoard(soup)
1818
expect(errors).toEqual([])
1919
})
2020

@@ -30,7 +30,7 @@ test("no vias, should return no errors", () => {
3030
thickness: 1.2,
3131
},
3232
]
33-
const errors = checkViasOutOfBoard(soup)
33+
const errors = checkViasOffBoard(soup)
3434
expect(errors).toEqual([])
3535
})
3636

@@ -55,7 +55,7 @@ test("via completely inside board, should return no errors", () => {
5555
layers: ["top", "bottom"],
5656
},
5757
]
58-
const errors = checkViasOutOfBoard(soup)
58+
const errors = checkViasOffBoard(soup)
5959
expect(errors).toEqual([])
6060
})
6161

@@ -80,7 +80,7 @@ test("via partially outside board (crossing boundary), should return an error",
8080
layers: ["top", "bottom"],
8181
},
8282
]
83-
const errors = checkViasOutOfBoard(soup)
83+
const errors = checkViasOffBoard(soup)
8484
expect(errors).toHaveLength(1)
8585
expect(errors[0].message).toContain(
8686
"Via pcb_via[#via_partially_out] is outside or crossing the board boundary",
@@ -111,7 +111,7 @@ test("via completely outside board, should return an error", () => {
111111
layers: ["top", "bottom"],
112112
},
113113
]
114-
const errors = checkViasOutOfBoard(soup)
114+
const errors = checkViasOffBoard(soup)
115115
expect(errors).toHaveLength(1)
116116
expect(errors[0].message).toContain(
117117
"Via pcb_via[#via_completely_out] is outside or crossing the board boundary",
@@ -163,7 +163,7 @@ test("multiple vias, some in, some out", () => {
163163
layers: ["top", "bottom"],
164164
},
165165
]
166-
const errors = checkViasOutOfBoard(soup)
166+
const errors = checkViasOffBoard(soup)
167167
expect(errors).toHaveLength(2)
168168
const errorMessages = errors.map((e) => e.message)
169169
expect(errorMessages).toContain(

0 commit comments

Comments
 (0)