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-usbcmidmount16.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 = "usbcmidmount16"

export default () => (
<JsCadView zAxisUp showGrid>
<Footprinter3d footprint={footprint} />
<ExtrudedPads footprint={footprint} />
</JsCadView>
)
39 changes: 39 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 { UsbCMidMount } from "./UsbCMidMount"

/**
* Outputs a 3d model for any [footprinter string](https://github.com/tscircuit/footprinter)
Expand Down Expand Up @@ -103,6 +104,22 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => {
screenheight?: number
screencenteroffsetx?: number
screencenteroffsety?: number
split?: boolean
reverse?: boolean
rowy?: number
ph?: number
powerpw?: number
powerx?: number
shellx?: number
topy?: number
bottomy?: number
tophw?: number
tophh?: number
topring?: number
bottomhw?: number
bottomhh?: number
bottomring?: number
bodybottom?: number
}

switch (fpJson.fn) {
Expand Down Expand Up @@ -287,6 +304,28 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => {
return <JSTZH1_5mm numPins={fpJson.num_pins} />
}
break
case "usbcmidmount":
return (
<UsbCMidMount
split={fpJson.split}
reverse={fpJson.reverse}
rowY={fpJson.rowy}
padHeight={fpJson.ph}
signalPadWidth={fpJson.pw}
powerPadWidth={fpJson.powerpw}
powerX={fpJson.powerx}
shellX={fpJson.shellx}
topY={fpJson.topy}
bottomY={fpJson.bottomy}
topHoleWidth={fpJson.tophw}
topHoleHeight={fpJson.tophh}
topRing={fpJson.topring}
bottomHoleWidth={fpJson.bottomhw}
bottomHoleHeight={fpJson.bottomhh}
bottomRing={fpJson.bottomring}
bodyBottom={fpJson.bodybottom}
/>
)
case "soic":
return (
<SOIC
Expand Down
165 changes: 165 additions & 0 deletions lib/UsbCMidMount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import { Colorize, Cuboid, RoundedCuboid, Subtract } from "jscad-fiber"

export interface UsbCMidMountProps {
split?: boolean
reverse?: boolean
rowY?: number
padHeight?: number
signalPadWidth?: number
powerPadWidth?: number
powerX?: number
shellX?: number
topY?: number
bottomY?: number
topHoleWidth?: number
topHoleHeight?: number
topRing?: number
bottomHoleWidth?: number
bottomHoleHeight?: number
bottomRing?: number
bodyBottom?: number
}

export const UsbCMidMount = ({
split = false,
reverse = false,
rowY = 2.125,
padHeight = 1.1,
signalPadWidth = 0.3,
powerPadWidth = 0.55,
powerX = 3.2,
shellX = 4.325,
topY = 1.575,
bottomY = 2.625,
topHoleWidth = 0.6,
topHoleHeight = 1.5,
topRing = 0.25,
bottomHoleWidth = 0.6,
bottomHoleHeight = 1.2,
bottomRing = 0.3,
bodyBottom = 5.225,
}: UsbCMidMountProps) => {
const innerPowerX = powerX - 0.8
const mergedSignalXs = [
-powerX,
-innerPowerX,
-1.75,
-1.25,
-0.75,
-0.25,
0.25,
0.75,
1.25,
1.75,
innerPowerX,
powerX,
]
const splitSignalXs = [
-3.35, -3.05, -2.55, -2.25, -1.75, -1.25, -0.75, -0.25, 0.25, 0.75, 1.25,
1.75, 2.25, 2.55, 3.05, 3.35,
]
const leftToRightSignalXs = split ? splitSignalXs : mergedSignalXs
const signalXs = reverse
? leftToRightSignalXs.slice().reverse()
: leftToRightSignalXs.slice()
const signalWidths = signalXs.map((_, index) =>
split || (index >= 2 && index < signalXs.length - 2)
? signalPadWidth
: powerPadWidth,
)
const rearY = rowY + padHeight / 2
const frontY = -bodyBottom
const bodyDepth = rearY - frontY
const bodyCenterY = (rearY + frontY) / 2
const outerWidth = shellX * 2 - 0.1
const outerHeight = 2.5
const bodyCenterZ = 0.25
const innerWidth = Math.max(outerWidth - 0.85, 5)
const innerHeight = outerHeight - 0.65
const shellThickness = 0.22
const tongueWidth = Math.min(innerWidth - 0.45, 6.6)
const tongueDepth = bodyDepth * 0.72
const tongueCenterY = frontY + tongueDepth / 2 + 0.35
const tongueZ = bodyCenterZ - 0.12
const innerContactLength = tongueDepth * 0.58
const innerContactY = frontY + innerContactLength / 2 + 0.55
const shellTabs = [
{
x: -shellX,
y: topY,
width: topHoleWidth + 2 * topRing,
length: topHoleHeight + 2 * topRing,
},
{
x: shellX,
y: topY,
width: topHoleWidth + 2 * topRing,
length: topHoleHeight + 2 * topRing,
},
{
x: -shellX,
y: -bottomY,
width: bottomHoleWidth + 2 * bottomRing,
length: bottomHoleHeight + 2 * bottomRing,
},
{
x: shellX,
y: -bottomY,
width: bottomHoleWidth + 2 * bottomRing,
length: bottomHoleHeight + 2 * bottomRing,
},
]

return (
<>
{shellTabs.map((tab, index) => (
<Cuboid
key={index}
color="#aeb1b4"
center={[tab.x, tab.y, 0]}
size={[tab.width, tab.length, 0.18]}
/>
))}
{signalXs.map((x, index) => (
<Cuboid
key={`lead:${index}`}
color="#c8a84e"
center={[x, rowY, 0.04]}
size={[signalWidths[index]!, padHeight, 0.08]}
/>
))}
<Colorize color="#b8bbbd">
<Subtract>
<RoundedCuboid
center={[0, bodyCenterY, bodyCenterZ]}
size={[outerWidth, bodyDepth, outerHeight]}
roundRadius={0.45}
/>
<RoundedCuboid
center={[0, bodyCenterY - shellThickness, bodyCenterZ]}
size={[innerWidth, bodyDepth - shellThickness, innerHeight]}
roundRadius={0.32}
/>
</Subtract>
</Colorize>
<RoundedCuboid
color="#242629"
center={[0, tongueCenterY, tongueZ]}
size={[tongueWidth, tongueDepth, 0.42]}
roundRadius={0.14}
/>
{signalXs.map((x, index) => (
<Cuboid
key={`contact:${index}`}
color="#d2af4f"
center={[x * 0.88, innerContactY, tongueZ + 0.225]}
size={[
Math.max(signalWidths[index]! * 0.62, 0.11),
innerContactLength,
0.03,
]}
/>
))}
</>
)
}
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 "./UsbCMidMount"
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/usbcmidmount.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("USB-C mid-mount connector", async () => {
const pngBuffer = await renderFootprint("usbcmidmount16")
await expect(pngBuffer).toMatchPngSnapshot(import.meta.path)
})
Loading