Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion src/fn/sot23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,55 @@ export const sot23_3 = (parameters: z.infer<typeof sot23_def>) => {
0.3,
)

const width = w / 2 - pl / 2
const height = h / 2
const silkscreenPath1: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
pcb_silkscreen_path_id: "silkscreen_path_1",
route: [
{ x: -width, y: height },
{ x: width + 0.2, y: height },
{ x: width + 0.2, y: height / 2 },
],
type: "pcb_silkscreen_path",
stroke_width: 0.1,
}
const silkscreenPath2: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
pcb_silkscreen_path_id: "silkscreen_path_2",
route: [
{ x: -width, y: -height },
{ x: width + 0.2, y: -height },
{ x: width + 0.2, y: -height / 2 },
],
type: "pcb_silkscreen_path",
stroke_width: 0.1,
}

const pin1Position = getCcwSot23Coords({
num_pins: parameters.num_pins,
pn: 1,
w,
h,
pl,
p,
})
const pin1Indicator: PcbSilkscreenPath = {
type: "pcb_silkscreen_path",
layer: "top",
pcb_component_id: "",
pcb_silkscreen_path_id: "pin1_indicator",
route: [
{ x: pin1Position.x - pl / 2 - 0.2, y: pin1Position.y + 0.15 },
{ x: pin1Position.x - pl / 2 - 0.5, y: pin1Position.y },
{ x: pin1Position.x - pl / 2 - 0.2, y: pin1Position.y - 0.15 },
{ x: pin1Position.x - pl / 2 - 0.2, y: pin1Position.y + 0.15 },
],
stroke_width: 0.05,
}

const courtyard: PcbCourtyardOutline = {
type: "pcb_courtyard_outline",
pcb_courtyard_outline_id: "",
Expand All @@ -154,7 +203,14 @@ export const sot23_3 = (parameters: z.infer<typeof sot23_def>) => {
layer: "top",
}

return [...pads, silkscreenRefText as AnyCircuitElement, courtyard]
return [
...pads,
silkscreenPath1,
silkscreenPath2,
pin1Indicator as AnyCircuitElement,
silkscreenRefText as AnyCircuitElement,
courtyard,
]
}

export const getCcwSot235Coords = (parameters: {
Expand Down
18 changes: 18 additions & 0 deletions tests/sot23-silkscreen.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "bun:test"
import { fp } from "../src/index"

test("sot23 (3-pin) generates silkscreen body outline and pin 1 indicator (#732)", () => {
const elements = fp.string("sot23").circuitJson()

const silkscreenPaths = elements.filter(
(e: any) => e.type === "pcb_silkscreen_path",
) as Array<any>

expect(silkscreenPaths.length).toBeGreaterThanOrEqual(3)

const pin1Indicator = silkscreenPaths.find(
(p) => p.pcb_silkscreen_path_id === "pin1_indicator",
)
expect(pin1Indicator).toBeDefined()
expect(pin1Indicator.route.length).toBe(4)
})
Loading