0hmX/am3352-ddr-track-b-byte0-wip-20261007
Partial full-board preview: 11 of 47 DDR signal nets routed; power and interfaces incomplete. Fabrication and electrical release blocked.
- Version
- 0.0.1
- License
- unset
- Stars
- 0
imported-footprint.tsx
import footprintContracts from "./contracts/support-footprints.json"
import mechanics from "./contracts/support-mechanics.json"
import type { FootprintContract, SupportPart } from "./part-contract"
import { PmicFootprint } from "./pmic-footprint"
const footprints: Record<string, FootprintContract> = footprintContracts
const courtyards: Record<string, { bounds: number[] }> = mechanics.courtyards
export function padPin(part: SupportPart, pin: string) {
return `pin${Object.keys(part.pinLabels).indexOf(pin) + 1}`
}
export function ImportedFootprint({ part }: { part: SupportPart }) {
if (part.name === "U_PMIC") return <PmicFootprint />
const footprint = footprints[part.footprintKey ?? ""]
if (!footprint) {
if (part.name.startsWith("TP_UART")) return <footprint><smtpad portHints={["pin1"]} shape="circle" radius={0.6} /></footprint>
throw new Error(`Missing imported footprint for ${part.name}`)
}
const bounds = courtyards[part.footprintKey ?? ""]?.bounds
return <footprint>{footprint.pads.map(pad => {
const portHints = pad.pin ? [padPin(part, pad.pin)] : []
if (pad.type === "np_thru_hole") return <hole pcbX={pad.x} pcbY={pad.y} diameter={Number(pad.drill?.[0] ?? pad.width)} />
if (pad.type === "thru_hole") {
if (pad.drill?.[0] === "oval") return <platedhole portHints={portHints} pcbX={pad.x} pcbY={pad.y}
shape="pill" holeWidth={Number(pad.drill[1])} holeHeight={Number(pad.drill[2])}
outerWidth={pad.width} outerHeight={pad.height} pcbRotation={pad.rotation} />
return <platedhole portHints={portHints} pcbX={pad.x} pcbY={pad.y} shape="circle"
holeDiameter={Number(pad.drill?.[0])} outerDiameter={Math.max(pad.width, pad.height)} />
}
if (pad.shape === "circle") return <smtpad portHints={portHints} pcbX={pad.x} pcbY={pad.y} shape="circle" radius={pad.width / 2} />
return <smtpad portHints={portHints} pcbX={pad.x} pcbY={pad.y} shape="rect"
width={Math.abs(pad.rotation ?? 0) % 180 === 90 ? pad.height : pad.width}
height={Math.abs(pad.rotation ?? 0) % 180 === 90 ? pad.width : pad.height} />
})}{bounds && <courtyardrect pcbX={(bounds[0] + bounds[2]) / 2} pcbY={(bounds[1] + bounds[3]) / 2}
width={bounds[2] - bounds[0]} height={bounds[3] - bounds[1]} />}</footprint>
}