Skip to content

Commit d162431

Browse files
authored
Pass traceClearance as a configuration for the distance b/w trace and pad being used by freerouting (#108)
* Add minimum distance b/w trace and pad * update pad * update * add traceClearance as a parameter * test name update
1 parent 4387302 commit d162431

4 files changed

Lines changed: 29 additions & 9 deletions

File tree

lib/dsn-pcb/circuit-json-to-dsn-json/convert-circuit-json-to-dsn-json.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { processPlatedHoles } from "./process-plated-holes"
77

88
export function convertCircuitJsonToDsnJson(
99
circuitElements: AnyCircuitElement[],
10+
options: {
11+
traceClearance?: number
12+
} = {},
1013
): DsnPcb {
1114
// Find the PCB board element
1215
const pcbBoard = circuitElements.find(
@@ -57,13 +60,10 @@ export function convertCircuitJsonToDsnJson(
5760
},
5861
via: "Via[0-1]_600:300_um",
5962
rule: {
63+
// Default clearance having fallback value
6064
clearances: [
6165
{
62-
value: 200,
63-
},
64-
{
65-
value: 200,
66-
type: "default_smd",
66+
value: options.traceClearance ?? 300, // fallback gap between any <-> any
6767
},
6868
{
6969
value: 50,
@@ -108,10 +108,10 @@ export function convertCircuitJsonToDsnJson(
108108
use_via: "Via[0-1]_600:300_um",
109109
},
110110
rule: {
111+
// Actual value being used in the dsn for the specific network class
111112
clearances: [
112113
{
113-
value: 200,
114-
type: "",
114+
value: options.traceClearance ?? 300,
115115
},
116116
],
117117
width: 150, // trace width used in freerouting

lib/dsn-pcb/circuit-json-to-dsn-json/convert-circuit-json-to-dsn-string.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { stringifyDsnJson } from "./stringify-dsn-json"
44

55
export const convertCircuitJsonToDsnString = (
66
circuitJson: AnyCircuitElement[],
7+
options: {
8+
traceClearance?: number
9+
} = {},
710
) => {
8-
const dsnJson = convertCircuitJsonToDsnJson(circuitJson)
11+
const dsnJson = convertCircuitJsonToDsnJson(circuitJson, options)
912
return stringifyDsnJson(dsnJson)
1013
}

lib/dsn-pcb/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface DsnPcb {
6060
}
6161
rule: {
6262
clearances: Array<{
63-
type: any
63+
type?: any
6464
value: number
6565
}>
6666
width: number
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect, test } from "bun:test"
2+
import { convertCircuitJsonToDsnJson } from "lib"
3+
4+
import circuitJson from "../assets/repro/XIAO_S3.json"
5+
import type { AnyCircuitElement } from "circuit-json"
6+
7+
test("configuration passed to converter", async () => {
8+
const dsnJson = convertCircuitJsonToDsnJson(
9+
circuitJson as AnyCircuitElement[],
10+
{
11+
traceClearance: 6969,
12+
},
13+
)
14+
15+
const traceClearance = dsnJson.network.classes[0].rule.clearances[0].value
16+
expect(traceClearance).toBe(6969)
17+
})

0 commit comments

Comments
 (0)