Skip to content
Closed
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
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions examples/footprinter3d/fp-smdpushbutton4.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { JsCadView } from "jscad-fiber"
import { ExtrudedPads } from "lib/ExtrudedPads"
import { Footprinter3d } from "lib/Footprinter3d"

const footprint = "smdpushbutton4"

export default () => (
<JsCadView zAxisUp showGrid>
<Footprinter3d footprint={footprint} />
<ExtrudedPads footprint={footprint} />
</JsCadView>
)
13 changes: 13 additions & 0 deletions lib/Footprinter3d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { StampBoard } from "./stampboard"
import { MountedPcbModule } from "./MountedPcbModule"
import SOD723 from "./SOD723"
import { JSTZH1_5mm } from "./JSTZH1_5mm"
import { SmdPushButton } from "./SmdPushButton"

/**
* Outputs a 3d model for any [footprinter string](https://github.com/tscircuit/footprinter)
Expand Down Expand Up @@ -103,6 +104,9 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => {
screenheight?: number
screencenteroffsetx?: number
screencenteroffsety?: number
px?: number
py?: number
ph?: number
}

switch (fpJson.fn) {
Expand Down Expand Up @@ -282,6 +286,15 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => {
innerDiameter={fpJson.id}
/>
)
case "smdpushbutton":
return (
<SmdPushButton
padPitchX={fpJson.px}
padPitchY={fpJson.py}
padWidth={fpJson.pw}
padHeight={fpJson.ph}
/>
)
case "jst":
if (fpJson.zh) {
return <JSTZH1_5mm numPins={fpJson.num_pins} />
Expand Down
75 changes: 75 additions & 0 deletions lib/SmdPushButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Cuboid, Cylinder, RoundedCuboid } from "jscad-fiber"

export interface SmdPushButtonProps {
padPitchX?: number
padPitchY?: number
padWidth?: number
padHeight?: number
}

export const SmdPushButton = ({
padPitchX = 4.2,
padPitchY = 2.15,
padWidth = 1.05,
padHeight = 0.7,
}: SmdPushButtonProps) => {
const bodyWidth = Math.max(padPitchX - padWidth, 2)
const bodyLength = Math.max(padPitchY + padHeight - 0.25, 1.8)
const terminalLength = Math.max((padPitchX + padWidth - bodyWidth) / 2, 0.35)
const terminalX = bodyWidth / 2 + terminalLength / 2
const terminalHeight = 0.1
const frameHeight = 0.28
const housingHeight = 0.48
const actuatorHeight = 0.32

return (
<>
{[-1, 1].flatMap((xDirection) =>
[-1, 1].map((yDirection) => (
<Cuboid
key={`${xDirection}:${yDirection}`}
color="#b9babc"
center={[
xDirection * terminalX,
yDirection * (padPitchY / 2),
terminalHeight / 2,
]}
size={[
terminalLength,
Math.max(padHeight * 0.78, 0.3),
terminalHeight,
]}
/>
)),
)}
<RoundedCuboid
color="#b9babc"
center={[0, 0, frameHeight / 2]}
size={[bodyWidth, bodyLength, frameHeight]}
roundRadius={0.12}
/>
<RoundedCuboid
color="#202226"
center={[0, 0, frameHeight + housingHeight / 2]}
size={[bodyWidth - 0.28, bodyLength - 0.28, housingHeight]}
roundRadius={0.18}
/>
<Cylinder
color="#d7d8d9"
center={[0, 0, frameHeight + housingHeight + actuatorHeight / 2]}
height={actuatorHeight}
radius={Math.min(bodyWidth, bodyLength) * 0.28}
/>
<Cylinder
color="#34363a"
center={[
-bodyWidth * 0.33,
bodyLength * 0.3,
frameHeight + housingHeight + 0.012,
]}
height={0.024}
radius={Math.min(bodyWidth, bodyLength) * 0.035}
/>
</>
)
}
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ export * from "./TO92"
export * from "./MountedPcbModule"
export * from "./Screen"
export * from "./JSTZH1_5mm"
export * from "./SmdPushButton"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@tscircuit/footprinter": "^0.0.374",
"@tscircuit/footprinter": "^0.0.391",
"@types/react": "19",
"@types/react-dom": "19",
"@types/three": "^0.179.0",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/snapshots/smdpushbutton.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from "bun:test"
import "../fixtures/png-matcher"
import { renderFootprint } from "../helpers/render-footprint"

test("SMD push button", async () => {
const pngBuffer = await renderFootprint("smdpushbutton4")
await expect(pngBuffer).toMatchPngSnapshot(import.meta.path)
})
Loading