0hmX/TMDS62LEVM
This code defines the physical layout and component placement for a TI AM62L evaluation module, including mechanical and population components, without routing.
- Version
- 1.0.2
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone 0hmX/TMDS62LEVM # download the package files into ./TMDS62LEVM
tsci add 0hmX/TMDS62LEVM # add it to your project as @tsci/0hmX.TMDS62LEVMIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
src/generated/PlacedPackage.tsx
import { getAltiumFootprintSpec } from "./altiumFootprintMap"
import type { BoardLayer, PlacementRecord } from "./types"
interface LocalPad {
x: number
y: number
width: number
height: number
shape?: "rect" | "circle"
}
export const rotateIntoBoard = (
placement: PlacementRecord,
localX: number,
localY: number,
) => {
const angle = (placement.pcbRotation * Math.PI) / 180
return {
x:
placement.pcbX +
localX * Math.cos(angle) -
localY * Math.sin(angle),
y:
placement.pcbY +
localX * Math.sin(angle) +
localY * Math.cos(angle),
}
}
const rotatedSize = (width: number, height: number, rotation: number) => {
const normalized = ((rotation % 180) + 180) % 180
return normalized === 90
? { width: height, height: width }
: { width, height }
}
export const makePads = (
kind: ReturnType<typeof getAltiumFootprintSpec>["kind"],
pinCount: number,
width: number,
height: number,
): LocalPad[] => {
if (kind === "testpoint" || kind === "mechanical") {
const diameter = Math.max(0.35, Math.min(width, height))
return [{ x: 0, y: 0, width: diameter, height: diameter, shape: "circle" }]
}
if (kind === "passive") {
const padWidth = Math.max(0.2, Math.min(width * 0.46, 1.5))
const padHeight = Math.max(0.18, height * 0.9)
const offset = Math.max(width * 0.36, padWidth * 0.55)
return [
{ x: -offset, y: 0, width: padWidth, height: padHeight },
{ x: offset, y: 0, width: padWidth, height: padHeight },
]
}
if (kind === "bga") {
const columns = Math.max(2, Math.ceil(Math.sqrt(pinCount * (width / height))))
const rows = Math.max(2, Math.ceil(pinCount / columns))
const pitch = Math.min(
1,
(width - 0.4) / Math.max(1, columns - 1),
(height - 0.4) / Math.max(1, rows - 1),
)
const diameter = Math.max(0.1, Math.min(0.4, pitch * 0.45))
return Array.from({ length: pinCount }, (_, index) => ({
x: (index % columns - (columns - 1) / 2) * pitch,
y: ((rows - 1) / 2 - Math.floor(index / columns)) * pitch,
width: diameter,
height: diameter,
shape: "circle" as const,
}))
}
if (kind === "connector") {
const rows = pinCount > 1 ? 2 : 1
const columns = Math.ceil(pinCount / rows)
const pitchX =
pinCount >= 19
? 0.5
: Math.min(2.54, (width - 0.8) / Math.max(1, columns - 1))
const pitchY = rows === 1 ? 0 : Math.min(2.54, height * 0.42)
return Array.from({ length: pinCount }, (_, index) => ({
x: (index % columns - (columns - 1) / 2) * pitchX,
y: ((rows - 1) / 2 - Math.floor(index / columns)) * pitchY,
width: Math.max(0.3, Math.min(1, pitchX * 0.45)),
height: Math.max(0.5, Math.min(1.6, height * 0.18)),
}))
}
const sideCount = Math.max(1, Math.ceil(pinCount / 4))
const pitchX = Math.min(0.8, width / Math.max(2, sideCount))
const pitchY = Math.min(0.8, height / Math.max(2, sideCount))
const normal = Math.max(0.18, Math.min(0.4, Math.min(width, height) * 0.12))
const tangentX = Math.max(0.1, Math.min(0.28, pitchX * 0.42))
const tangentY = Math.max(0.1, Math.min(0.28, pitchY * 0.42))
const normalOffset = pinCount >= 48 ? normal / 2 : 0
return Array.from({ length: pinCount }, (_, index) => {
const side = index % 4
const position = Math.floor(index / 4) - (sideCount - 1) / 2
if (side === 0 || side === 2) {
return {
x:
side === 0
? -width / 2 - normalOffset
: width / 2 + normalOffset,
y: position * pitchY,
width: normal,
height: tangentY,
}
}
return {
x: position * pitchX,
y:
side === 1
? height / 2 + normalOffset
: -height / 2 - normalOffset,
width: tangentX,
height: normal,
}
})
}
const Pad = ({
pad,
placement,
}: {
pad: LocalPad
placement: PlacementRecord
}) => {
const boardPosition = rotateIntoBoard(placement, pad.x, pad.y)
const isDiagonal = Math.abs(placement.pcbRotation % 90) > 0.001
const renderAsDnpLand =
!placement.populated && !placement.name.startsWith("TP")
if (pad.shape === "circle" || isDiagonal) {
const diameter = Math.min(pad.width, pad.height) * 0.72
if (renderAsDnpLand) {
return (
<silkscreencircle
pcbX={boardPosition.x}
pcbY={boardPosition.y}
layer={placement.layer}
radius={diameter / 2}
strokeWidth={0.06}
/>
)
}
return (
<smtpad
pcbX={boardPosition.x}
pcbY={boardPosition.y}
layer={placement.layer}
radius={diameter / 2}
shape="circle"
/>
)
}
const size = rotatedSize(
pad.width * 0.5,
pad.height * 0.5,
placement.pcbRotation,
)
if (renderAsDnpLand) {
return (
<silkscreenrect
pcbX={boardPosition.x}
pcbY={boardPosition.y}
layer={placement.layer}
width={size.width}
height={size.height}
strokeWidth={0.06}
/>
)
}
return (
<smtpad
pcbX={boardPosition.x}
pcbY={boardPosition.y}
layer={placement.layer}
width={size.width}
height={size.height}
shape="rect"
/>
)
}
const Fiducial = ({
name,
pcbX,
pcbY,
layer,
}: {
name: string
pcbX: number
pcbY: number
layer: BoardLayer
}) => (
<fiducial
name={name}
pcbX={pcbX}
pcbY={pcbY}
layer={layer}
padDiameter={0.5}
soldermaskPullback={0.35}
/>
)
/**
* PCB-only rendering of an official placement. DNP records retain their pads,
* while fitted records also receive an IDF-positioned package body and label.
*/
export const PlacedPackage = ({ placement }: { placement: PlacementRecord }) => {
const spec = getAltiumFootprintSpec(placement.footprint)
if (spec.kind === "mechanical") {
return <Fiducial {...placement} />
}
const pads = makePads(
spec.kind,
spec.pinCount,
spec.bodyWidth,
spec.bodyHeight,
)
const showReference =
placement.populated && Math.max(spec.bodyWidth, spec.bodyHeight) >= 3.5
const bodySize = rotatedSize(
spec.bodyWidth,
spec.bodyHeight,
placement.pcbRotation,
)
const bodyX =
spec.kind === "connector" ? placement.bodyPcbX : placement.pcbX
const bodyY =
spec.kind === "connector" ? placement.bodyPcbY : placement.pcbY
return (
<>
{pads.map((pad, index) => (
<Pad key={`${placement.name}-${index}`} pad={pad} placement={placement} />
))}
{placement.populated && spec.kind !== "testpoint" && (
<silkscreenrect
pcbX={bodyX}
pcbY={bodyY}
layer={placement.layer}
width={bodySize.width}
height={bodySize.height}
strokeWidth={0.1}
/>
)}
{showReference && (
<silkscreentext
pcbX={bodyX}
pcbY={bodyY}
pcbRotation={placement.pcbRotation}
layer={placement.layer}
text={placement.name}
fontSize={0.55}
anchorAlignment="center"
/>
)}
</>
)
}