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
13 changes: 13 additions & 0 deletions examples/electrolytic.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { JsCadView } from "jscad-fiber"
import { ExtrudedPads, Footprinter3d } from "../lib"

const footprint = "electrolytic_d10.5mm_p7.5mm"

export default () => {
return (
<JsCadView zAxisUp showGrid>
<Footprinter3d footprint={footprint} />
<ExtrudedPads footprint={footprint} />
</JsCadView>
)
}
93 changes: 93 additions & 0 deletions lib/ElectrolyticCapacitor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Cuboid, Cylinder } from "jscad-fiber"

export interface ElectrolyticCapacitorProps {
pitch?: number
diameter?: number
height?: number
leadDiameter?: number
standoffHeight?: number
leadEmbedDepth?: number
leadInsertionDepth?: number
bodyColor?: string
stripeColor?: string
}

export const ElectrolyticCapacitor = ({
pitch = 7.5,
diameter = 10.5,
height,
leadDiameter = 0.6,
standoffHeight = 8,
leadEmbedDepth = 0.75,
leadInsertionDepth = 4,
bodyColor = "#202b3c",
stripeColor = "#c7c9cc",
}: ElectrolyticCapacitorProps) => {
const bodyHeight = height ?? diameter * 1.2
const bodyRadius = diameter / 2
const bodyCenterZ = standoffHeight + bodyHeight / 2
const bodyTopZ = standoffHeight + bodyHeight
const leadTopZ = standoffHeight + leadEmbedDepth
const leadBottomZ = -leadInsertionDepth
const leadHeight = leadTopZ - leadBottomZ
const leadCenterZ = (leadTopZ + leadBottomZ) / 2
const leadRadius = leadDiameter / 2
const bungHeight = Math.min(0.6, bodyHeight * 0.08)
const topDiscHeight = Math.min(0.2, bodyHeight * 0.03)
const polarityStripeWidth = Math.min(1.6, diameter * 0.18)
const polarityStripeDepth = Math.min(0.18, diameter * 0.025)
const ventWidth = diameter * 0.52
const ventThickness = Math.max(0.1, diameter * 0.015)

return (
<>
{[-pitch / 2, pitch / 2].map((x) => (
<Cylinder
key={x}
color="#b8b8b8"
radius={leadRadius}
height={leadHeight}
center={[x, 0, leadCenterZ]}
/>
))}

<Cylinder
color={bodyColor}
radius={bodyRadius}
height={bodyHeight}
center={[0, 0, bodyCenterZ]}
/>

<Cylinder
color="#16191e"
radius={bodyRadius * 0.9}
height={bungHeight}
center={[0, 0, standoffHeight + bungHeight / 2]}
/>

<Cuboid
color={stripeColor}
size={[polarityStripeDepth, polarityStripeWidth, bodyHeight * 0.78]}
center={[bodyRadius - polarityStripeDepth / 2 + 0.01, 0, bodyCenterZ]}
/>

<Cylinder
color="#9fa3a7"
radius={bodyRadius * 0.86}
height={topDiscHeight}
center={[0, 0, bodyTopZ + topDiscHeight / 2]}
/>

<Cuboid
color="#666a6e"
size={[ventWidth, ventThickness, topDiscHeight / 2]}
center={[0, 0, bodyTopZ + topDiscHeight]}
/>
<Cuboid
color="#666a6e"
size={[ventThickness, ventWidth, topDiscHeight / 2]}
center={[0, 0, bodyTopZ + topDiscHeight]}
/>
</>
)
}
6 changes: 6 additions & 0 deletions lib/Footprinter3d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { JSTZH1_5mm } from "./JSTZH1_5mm"
import { Crystal } from "./Crystal"
import { FPC } from "./FPC"
import { SmdPinHeader } from "./SmdPinHeader"
import { ElectrolyticCapacitor } from "./ElectrolyticCapacitor"
import { Led5050 } from "./Led5050"
import { RJ45 } from "./RJ45"

Expand Down Expand Up @@ -121,6 +122,7 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => {
mounttop?: boolean
mpw?: number
mpl?: number
d?: number
ledpins?: boolean
firstpinleft?: boolean
firstpintop?: boolean
Expand Down Expand Up @@ -156,6 +158,10 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => {
)
case "axial":
return <AxialCapacitor pitch={fpJson.p} />
case "electrolytic":
return (
<ElectrolyticCapacitor pitch={fpJson.p} diameter={fpJson.d ?? 10.5} />
)
case "tssop":
return (
<Tssop
Expand Down
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from "./ChipBody"
export * from "./Crystal"
// export * from "./Dip"
export * from "./ExtrudedPads"
export * from "./ElectrolyticCapacitor"
export * from "./FootprintPad"
export * from "./FootprintPlatedHole"
export * from "./Footprinter3d"
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/electrolytic.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("Radial electrolytic capacitor", async () => {
const pngBuffer = await renderFootprint("electrolytic_d10.5mm_p7.5mm")
await expect(pngBuffer).toMatchPngSnapshot(import.meta.path)
})
Loading