pixalynx/pixal-nfc-card
This code defines React components representing specific electronic hardware components—namely, a 100-ohm SMD resistor, a surface-mount LED, and a chip with labeled pins—each modeled with detailed footprints, 3D CAD models, and manufacturer part information for PCB design.
- Version
- 1.1.0
- License
- unset
- Stars
- 0
lib/coil.ts
export type Pt = { x: number; y: number }
export interface CoilSpec {
/** Outer-turn centreline bounds in board millimetres */
left: number
right: number
bottom: number
top: number
turns: number
/** Copper width and edge-to-edge gap between turns, mm */
width: number
gap: number
/** Terminal offset above (inner end) / below (outer end) the coil's horizontal centre line */
leadOffset: number
}
const r4 = (v: number) => Math.round(v * 1e4) / 1e4
export const coilPitch = (s: CoilSpec) => s.width + s.gap
/**
* Rectangular spiral centreline from the outer terminal (right edge, below
* centre) to the inner terminal (innermost right edge, above centre). Each turn
* steps inward by one pitch at the bottom-right corner, so no copper crosses on
* this layer and both terminals face the chip.
*/
export function coilPath(s: CoilSpec): Pt[] {
const p = coilPitch(s)
const ym = (s.top + s.bottom) / 2
const pts: Pt[] = [{ x: s.right, y: ym - s.leadOffset }]
for (let k = 0; k < s.turns; k++) {
pts.push(
{ x: s.right - k * p, y: s.top - k * p },
{ x: s.left + k * p, y: s.top - k * p },
{ x: s.left + k * p, y: s.bottom + k * p },
{ x: s.right - (k + 1) * p, y: s.bottom + k * p },
)
}
pts.push({ x: s.right - s.turns * p, y: ym + s.leadOffset })
return pts.map((q) => ({ x: r4(q.x), y: r4(q.y) }))
}