Skip to content

Commit 3128095

Browse files
doublesidedpinlabel for pinrow
1 parent ab8b9e4 commit 3128095

5 files changed

Lines changed: 50 additions & 2 deletions

File tree

src/fn/pinrow.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export const pinrow_def = z
3232
.optional()
3333
.default(false)
3434
.describe("do not use rectangular pad for pin 1"),
35+
doublesidedpinlabel: z
36+
.boolean()
37+
.optional()
38+
.default(false)
39+
.describe("add silkscreen pins in top and bottom layers"),
3540
})
3641
.transform((data) => {
3742
const pinlabelAnchorSide = determinePinlabelAnchorSide(data)
@@ -68,6 +73,7 @@ export const pinrow = (
6873
pinlabelorthogonal,
6974
pinlabeltextalignleft,
7075
pinlabeltextalignright,
76+
doublesidedpinlabel,
7177
} = parameters
7278
let pinlabelTextAlign: "center" | "left" | "right" = "center"
7379
if (pinlabeltextalignleft) pinlabelTextAlign = "left"
@@ -133,8 +139,24 @@ export const pinrow = (
133139
textalign: pinlabelTextAlign,
134140
orthogonal: pinlabelorthogonal,
135141
verticallyinverted: pinlabelverticallyinverted,
142+
layer: "top",
136143
}),
137144
)
145+
if (doublesidedpinlabel) {
146+
holes.push(
147+
silkscreenPin({
148+
fs: od / 5,
149+
pn: pinNumber,
150+
anchor_x,
151+
anchor_y,
152+
anchorplacement: pinlabelAnchorSide,
153+
textalign: pinlabelTextAlign,
154+
orthogonal: pinlabelorthogonal,
155+
verticallyinverted: pinlabelverticallyinverted,
156+
layer: "bottom",
157+
}),
158+
)
159+
}
138160
}
139161

140162
// Track used positions to prevent overlaps

src/footprinter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type Footprinter = {
7777
| "pinlabelverticallyinverted"
7878
| "pinlabelorthogonal"
7979
| "nosquareplating"
80+
| "doublesidedpinlabel"
8081
>
8182
axial: () => FootprinterParamsBuilder<"p" | "id" | "od">
8283
hc49: () => FootprinterParamsBuilder<"p" | "id" | "od" | "w" | "h">

src/helpers/silkscreenPin.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PcbSilkscreenText } from "circuit-json"
1+
import type { LayerRef, PcbSilkscreenText } from "circuit-json"
22

33
type TextAlignType = "left" | "center" | "right"
44
type AnchorPlacementType = "top" | "bottom" | "left" | "right"
@@ -13,6 +13,7 @@ export const silkscreenPin = ({
1313
textalign = "center",
1414
orthogonal = false,
1515
verticallyinverted = false,
16+
layer = "top",
1617
}: {
1718
fs: number
1819
pn: number
@@ -22,6 +23,7 @@ export const silkscreenPin = ({
2223
anchorplacement?: AnchorPlacementType
2324
orthogonal?: boolean
2425
verticallyinverted?: boolean
26+
layer?: LayerRef
2527
}): PcbSilkscreenText => {
2628
let ccw_rotation: RotationType = 0
2729
if (orthogonal && verticallyinverted) {
@@ -44,14 +46,22 @@ export const silkscreenPin = ({
4446
else anchor_alignment = "center_right"
4547
}
4648

49+
if (layer === "bottom") {
50+
if (anchor_alignment === "center_left") {
51+
anchor_alignment = "center_right"
52+
} else if (anchor_alignment === "center_right") {
53+
anchor_alignment = "center_left"
54+
}
55+
}
56+
4757
return {
4858
type: "pcb_silkscreen_text",
4959
pcb_silkscreen_text_id: "silkscreen_text_1",
5060
font: "tscircuit2024",
5161
font_size: fs,
5262
pcb_component_id: "pcb_component_1",
5363
text: `{PIN${pn}}`,
54-
layer: "top",
64+
layer: layer,
5565
anchor_position: { x: anchor_x, y: anchor_y },
5666
anchor_alignment: anchor_alignment,
5767
ccw_rotation: ccw_rotation,
Lines changed: 1 addition & 0 deletions
Loading

tests/pinrow.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,17 @@ for (const textAlign of textAlignments) {
159159
}
160160
}
161161
}
162+
163+
test("pinrow5_doublesidedpinlabel", () => {
164+
const def = "pinrow5_doublesidedpinlabel"
165+
const soup = fp.string(def).circuitJson()
166+
const svgContent = convertCircuitJsonToPcbSvg(soup)
167+
168+
const pinrowJson = fp.string(def).json() as any
169+
expect(pinrowJson.doublesidedpinlabel).toBe(true)
170+
171+
expect(svgContent).toMatchSvgSnapshot(
172+
import.meta.path,
173+
"pinrow5_doublesidedpinlabel",
174+
)
175+
})

0 commit comments

Comments
 (0)