pixalynx/usb3-hub-10g
A USB 3.2 Gen 2 six-port hub board with USB-C PD power input, regulated 5 V/3.3 V/1.15 V rails, one upstream and four protected downstream USB-A/USB-C ports, SuperSpeed muxes, ESD protection, and controlled port power.
- Version
- 0.0.1
- License
- unset
- Stars
- 0
lib/jlc.tsx
import { Children } from "react"
import lib from "./jlc-footprints.json"
/** Footprints generated from JLCPCB's own EasyEDA land patterns (scripts/gen-jlc-footprints.py). They keep JLC's
* orientation and origin, so the CPL rotation equals pcbRotation and the CPL position is the component centre.
* Each land's port hint is `pin<n>`: the pad number, or for connectors the number from PINMAP in the generator. */
export type JlcKey = keyof typeof lib
type Pad = { kind: string; pin?: string; n?: number; x: number; y: number; w?: number; h?: number; d?: number; hole?: number; hw?: number; hh?: number; pill?: boolean; poly?: number[][] }
export const jlcLcsc = (key: JlcKey) => lib[key].lcsc
/** Body extent (mm, footprint frame): courtyard and silkscreen outline. Defaults to the land extent + 0.25 mm. */
export function JlcFootprint({ part, body, silk = true, margin = 0.25 }: { part: JlcKey; body?: [number, number, number, number]; silk?: boolean; margin?: number }) {
const f = lib[part]
const pads = f.pads as Pad[]
const [x0, y0, x1, y1] = body ?? (() => {
const ext = pads.map((p) => {
const hw = (p.w ?? p.d ?? 0) / 2, hh = (p.h ?? p.d ?? 0) / 2
return [p.x - hw, p.y - hh, p.x + hw, p.y + hh]
})
return [Math.min(...ext.map((e) => e[0])) - margin, Math.min(...ext.map((e) => e[1])) - margin, Math.max(...ext.map((e) => e[2])) + margin, Math.max(...ext.map((e) => e[3])) + margin] as [number, number, number, number]
})()
const rect = [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }, { x: x0, y: y0 }]
return (
<footprint>
{Children.toArray(pads.map((p) => {
const hint = [`pin${p.n}`]
if (p.kind === "hole") return <hole pcbX={p.x} pcbY={p.y} diameter={p.d!} />
if (p.kind === "th") return <platedhole portHints={hint} pcbX={p.x} pcbY={p.y} holeDiameter={p.hole!} outerDiameter={p.d!} shape="circle" />
if (p.kind === "slot")
return <platedhole portHints={hint} pcbX={p.x} pcbY={p.y} shape="pill" holeWidth={p.hw!} holeHeight={p.hh!} outerWidth={p.w!} outerHeight={p.h!} />
if (p.poly) return <smtpad portHints={hint} pcbX={p.x} pcbY={p.y} shape="polygon" points={p.poly.map(([x, y]) => ({ x, y }))} />
if (p.pill) return <smtpad portHints={hint} pcbX={p.x} pcbY={p.y} shape="pill" width={p.w!} height={p.h!} radius={Math.min(p.w!, p.h!) / 2} />
return <smtpad portHints={hint} pcbX={p.x} pcbY={p.y} shape="rect" width={p.w!} height={p.h!} />
}))}
{silk && <silkscreenpath route={rect} strokeWidth={0.1} />}
<courtyardoutline outline={rect} />
</footprint>
)
}