diff --git a/src/fn/sot23.ts b/src/fn/sot23.ts index 9981f8e4..5ac63f32 100644 --- a/src/fn/sot23.ts +++ b/src/fn/sot23.ts @@ -154,7 +154,45 @@ export const sot23_3 = (parameters: z.infer) => { layer: "top", } - return [...pads, silkscreenRefText as AnyCircuitElement, courtyard] + // Body outline + pin-1 marker, mirroring the sibling SOT footprints + // (sot23w/sot323 draw the same two paths). The 3-pin SOT-23 has two pads + // on the top edge and pin 1 on the bottom, so the outline spans the body + // between the rows and a short pin-1 tick marks the lone bottom pad. + const outlineHalfWidth = w / 2 - pl / 2 - 0.2 + const bodyPath: PcbSilkscreenPath = { + layer: "top", + pcb_component_id: "", + pcb_silkscreen_path_id: "silkscreen_path_body", + route: [ + { x: -outlineHalfWidth, y: h / 2 }, + { x: outlineHalfWidth, y: h / 2 }, + { x: outlineHalfWidth, y: -h / 2 }, + { x: -outlineHalfWidth, y: -h / 2 }, + { x: -outlineHalfWidth, y: h / 2 }, + ], + type: "pcb_silkscreen_path", + stroke_width: 0.1, + } + const pin1Path: PcbSilkscreenPath = { + layer: "top", + pcb_component_id: "", + pcb_silkscreen_path_id: "silkscreen_path_pin1", + route: [ + { x: -outlineHalfWidth, y: -h / 2 - 0.4 }, + { x: -outlineHalfWidth, y: -h / 2 }, + { x: -outlineHalfWidth + 0.4, y: -h / 2 }, + ], + type: "pcb_silkscreen_path", + stroke_width: 0.1, + } + + return [ + ...pads, + silkscreenRefText as AnyCircuitElement, + courtyard, + bodyPath, + pin1Path, + ] } export const getCcwSot235Coords = (parameters: { diff --git a/tests/__snapshots__/sot-23-3.snap.svg b/tests/__snapshots__/sot-23-3.snap.svg index c4c986de..d37ff669 100644 --- a/tests/__snapshots__/sot-23-3.snap.svg +++ b/tests/__snapshots__/sot-23-3.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sot23.snap.svg b/tests/__snapshots__/sot23.snap.svg index c4c986de..d37ff669 100644 --- a/tests/__snapshots__/sot23.snap.svg +++ b/tests/__snapshots__/sot23.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sot23_3.snap.svg b/tests/__snapshots__/sot23_3.snap.svg index c4c986de..d37ff669 100644 --- a/tests/__snapshots__/sot23_3.snap.svg +++ b/tests/__snapshots__/sot23_3.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sot23_3_micrometer_units.snap.svg b/tests/__snapshots__/sot23_3_micrometer_units.snap.svg index 9a31711e..4c1c5231 100644 --- a/tests/__snapshots__/sot23_3_micrometer_units.snap.svg +++ b/tests/__snapshots__/sot23_3_micrometer_units.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sot23_legacy_alias.snap.svg b/tests/__snapshots__/sot23_legacy_alias.snap.svg index c4c986de..d37ff669 100644 --- a/tests/__snapshots__/sot23_legacy_alias.snap.svg +++ b/tests/__snapshots__/sot23_legacy_alias.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sot23_w3_h1.5_p0.95mm.snap.svg b/tests/__snapshots__/sot23_w3_h1.5_p0.95mm.snap.svg index 6aeebeaf..ef724ae5 100644 --- a/tests/__snapshots__/sot23_w3_h1.5_p0.95mm.snap.svg +++ b/tests/__snapshots__/sot23_w3_h1.5_p0.95mm.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sot23.snap.svg b/tests/kicad-parity/__snapshots__/sot23.snap.svg index d80cecc4..009a07bb 100644 --- a/tests/kicad-parity/__snapshots__/sot23.snap.svg +++ b/tests/kicad-parity/__snapshots__/sot23.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/sot23-silkscreen.test.ts b/tests/sot23-silkscreen.test.ts new file mode 100644 index 00000000..a7dfb6c2 --- /dev/null +++ b/tests/sot23-silkscreen.test.ts @@ -0,0 +1,16 @@ +import { test, expect } from "bun:test" +import { fp } from "src/footprinter" + +test("sot23 draws a body outline and pin-1 marker (#732)", () => { + const circuitJson = fp.string("sot23").circuitJson() + const silks = circuitJson.filter( + (el: any) => el.type === "pcb_silkscreen_path", + ) + expect(silks.length).toBe(2) + + const ids = silks.map((s: any) => s.pcb_silkscreen_path_id).sort() + expect(ids).toEqual(["silkscreen_path_body", "silkscreen_path_pin1"]) + + const pads = circuitJson.filter((el: any) => el.type === "pcb_smtpad") + expect(pads.length).toBe(3) +})