diff --git a/examples/mountedPcbModule-female.example.tsx b/examples/mountedPcbModule-female.example.tsx new file mode 100644 index 0000000..9f91621 --- /dev/null +++ b/examples/mountedPcbModule-female.example.tsx @@ -0,0 +1,20 @@ +import { JsCadView } from "jscad-fiber" +import { ExtrudedPads } from "lib/index" +import MountedPCBModule from "lib/MountedPcbModule" + +export default () => { + return ( + + + + + ) +} diff --git a/lib/FemaleHeader.tsx b/lib/FemaleHeader.tsx index a44366c..466284f 100644 --- a/lib/FemaleHeader.tsx +++ b/lib/FemaleHeader.tsx @@ -3,6 +3,7 @@ import { Colorize, Cuboid, Cylinder, Hull, Subtract } from "jscad-fiber" export const FemaleHeader = ({ x, y, + z = 0, pitch = 2.54, legsLength = 3, innerDiameter = 0.945, @@ -13,6 +14,7 @@ export const FemaleHeader = ({ }: { x: number y: number + z?: number pitch?: number legsLength?: number innerDiameter?: number @@ -31,19 +33,19 @@ export const FemaleHeader = ({ {innerDiameter ? ( ) : ( )} @@ -53,18 +55,18 @@ export const FemaleHeader = ({ diff --git a/lib/Footprinter3d.tsx b/lib/Footprinter3d.tsx index 0718180..3588e24 100644 --- a/lib/Footprinter3d.tsx +++ b/lib/Footprinter3d.tsx @@ -374,6 +374,7 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => { holeInset={holeInset} pinRowHoleEdgeToEdgeDist={pinRowHoleEdgeToEdgeDist} nopin={fpJson.nopin} + female={fpJson.female} /> ) } diff --git a/lib/MountedPcbModule.tsx b/lib/MountedPcbModule.tsx index 898db74..bc0fb07 100644 --- a/lib/MountedPcbModule.tsx +++ b/lib/MountedPcbModule.tsx @@ -1,5 +1,6 @@ import { Colorize, Cuboid, Cylinder, Subtract } from "jscad-fiber" import { PinHeader } from "./PinHeader" +import { FemaleHeader } from "./FemaleHeader" export const MountedPcbModule = ({ numPins = 5, @@ -14,6 +15,7 @@ export const MountedPcbModule = ({ holes = [], holeInset = 1.0, pinRowHoleEdgeToEdgeDist = 2.0, + female, nopin, }: { numPins?: number @@ -28,6 +30,7 @@ export const MountedPcbModule = ({ holes?: string[] holeInset?: number pinRowHoleEdgeToEdgeDist?: number + female?: boolean nopin?: boolean }) => { const boardCenterZ = boardThickness / 2 @@ -121,7 +124,7 @@ export const MountedPcbModule = ({ const pinBodyHeight = 2 const longSidePinLength = 6 const shortSidePinLength = 3 - const boardOffsetZ = nopin ? 0 : pinBodyHeight + const boardOffsetZ = nopin || female ? 0 : pinBodyHeight // Board body with holes subtracted const boardBody = ( @@ -181,11 +184,21 @@ export const MountedPcbModule = ({ /> )) + const femaleHeaderRow = pins.map((pin, index) => ( + -z} + /> + )) + return ( <> {boardBody} {platedHoles} - {!nopin && headerPins} + {!female && !nopin && headerPins} + {female && femaleHeaderRow} ) } diff --git a/tests/snapshots/__snapshots__/mountedpcbmodule-female.snap.png b/tests/snapshots/__snapshots__/mountedpcbmodule-female.snap.png new file mode 100644 index 0000000..6c10832 Binary files /dev/null and b/tests/snapshots/__snapshots__/mountedpcbmodule-female.snap.png differ diff --git a/tests/snapshots/mountedpcbmodule-female.test.ts b/tests/snapshots/mountedpcbmodule-female.test.ts new file mode 100644 index 0000000..6fa4c69 --- /dev/null +++ b/tests/snapshots/mountedpcbmodule-female.test.ts @@ -0,0 +1,9 @@ +import { expect, test } from "bun:test" +import { renderFootprint } from "tests/helpers/render-footprint" + +test("mountedpcbmodule with female header and holes", async () => { + const pngBuffer = renderFootprint( + "mountedpcbmodule_pinrow20_rows2_pinrowbottom_width40_height22_female_holes(topleft,topright,bottomleft,bottomright)", + ) + await expect(pngBuffer).toMatchPngSnapshot(import.meta.path) +}, 10000)