pixalynx/nrf9151-gps-tracker

A compact 44×32 mm, 4-layer nRF9151 LTE-M/NB-IoT/GNSS tracker PCB with nPM1300 LiPo/USB-C power, nano-SIM/eSIM switching, nRF7002 Wi‑Fi scanning, accelerometer, antennas, buzzer, LEDs, SOS button, and SWD/debug connectors.

Version
0.1.4
License
unset
Stars
0

lib/passives.tsx

/** Compact helpers for two-terminal passives. Every part carries the JLCPCB part number
 * that the BOM will use; the mapping lives in one table so a value change is a one-line edit. */

export type Side = "top" | "bottom"
import type { ReactElement } from "react"
import { Cap0201 } from "./footprints"
export type PassiveSpec = {
  name: string; value: string; x: number; y: number; rot?: number; side?: Side
  sch: [number, number]; section: string; footprint?: string | ReactElement; fpKey?: string; jlc?: string; dnp?: boolean; note?: string; schRot?: number; schOrientation?: "vertical" | "horizontal"
}

/** JLCPCB part numbers for the passive values used on the three boards (checked 2026-09-14
 * against jlcsearch.tscircuit.com, re-checked 2026-09-23 for this board; see docs/bom.md). Keys are `${value}@${footprint}`. */
export const JLC: Record<string, string> = {
  // capacitors
  "100nF@0402": "C1525", "1uF@0402": "C52923", "4.7uF@0402": "C23733", "10nF@0402": "C15195", "100pF@0402": "C1546",
  "22pF@0402": "C1555", "1nF@0402": "C1523", "2.2nF@0402": "C2987940", "22nF@0402": "C107026", "39pF@0402": "C1563",
  "10uF@0603": "C19702", "47uF@0805": "C2292827", "2.2uF@0603": "C23630", "10uF@0805": "C15850", "1uF@0603": "C15849",
  "470nF@0603": "C1623", "100nF@0603": "C14663", "10nF@0603": "C57112", "22nF@0603": "C106222", "56nF@0603": "C282072",
  "10uF@0402": "C15525", "2.2uF@0402": "C12530", "470nF@0402": "C106255", "220nF@0402": "C16772",
  "100nF@0201": "C5142565", "10nF@0201": "C5142551", "22nF@0201": "C5142560", "220nF@0201": "C76936", "470nF@0201": "C2169138",
  "1uF@0201": "C2846675", "2.2uF@0201": "C335106", "3.3uH@1008": "C98339", "22uF@0805": "C45783", "15nF@0603": "C107076",
  // resistors
  "10k@0402": "C25744", "330@0402": "C25104", "68k@0402": "C2909379", "100k@0402": "C25741", "47k@0402": "C25792", "1k@0402": "C11702", "0@0402": "C17168",
  "1M@0402": "C26083", "20k@0402": "C25765", "68@0402": "C2909380", "200@0402": "C25087", "1.5k@0402": "C25867",
  "33k@0402": "C25779", "3.3k@0402": "C2909345", "100k@0603": "C25803", "1k@0603": "C21190", "10k@0603": "C2906982",
  "0.02@0805": "C601084", "5.1k@0402": "C25905", "2.2k@0402": "C25879", "330k@0402": "C25778",
  // inductors / beads
  "2.2uH@0806": "C337893", "1.5nH@0402": "C18221", "22nH@0402": "C12670", "9.1nH@0402": "C162547", "68nH@0402": "C108965",
  "FB22R@0603": "C710389", "FB120R@0402": "C85812",
}

const jlcFor = (p: PassiveSpec, fp: string | ReactElement) => p.jlc ?? JLC[`${p.value}@${typeof fp === "string" ? fp : p.fpKey ?? "custom"}`]

export const Cap = (p: PassiveSpec) => {
  const fp = p.footprint === "0201" ? <Cap0201 /> : p.footprint ?? "0402"
  const jlc = p.footprint === "0201" ? p.jlc ?? JLC[`${p.value}@0201`] : jlcFor(p, fp)
  return (
    <capacitor name={p.name} capacitance={p.value} footprint={fp} pcbX={p.x} pcbY={p.y} pcbRotation={p.rot ?? 0} layer={p.side ?? "top"}
      schX={p.sch[0]} schY={p.sch[1]} schRotation={p.schRot ?? 0} schOrientation={p.schOrientation} schSectionName={p.section} doNotPlace={p.dnp}
      supplierPartNumbers={jlc ? { jlcpcb: [jlc] } : undefined} />
  )
}
export const Res = (p: PassiveSpec) => {
  const fp = p.footprint ?? "0402"
  const jlc = jlcFor(p, fp)
  return (
    <resistor name={p.name} resistance={p.value} footprint={fp} pcbX={p.x} pcbY={p.y} pcbRotation={p.rot ?? 0} layer={p.side ?? "top"}
      schX={p.sch[0]} schY={p.sch[1]} schRotation={p.schRot ?? 0} schSectionName={p.section} doNotPlace={p.dnp}
      supplierPartNumbers={jlc ? { jlcpcb: [jlc] } : undefined} />
  )
}
export const Ind = (p: PassiveSpec) => {
  const fp = p.footprint ?? "0402"
  const jlc = jlcFor(p, fp)
  return (
    <inductor name={p.name} inductance={p.value} footprint={fp} pcbX={p.x} pcbY={p.y} pcbRotation={p.rot ?? 0} layer={p.side ?? "top"}
      schX={p.sch[0]} schY={p.sch[1]} schRotation={p.schRot ?? 0} schSectionName={p.section} doNotPlace={p.dnp}
      supplierPartNumbers={jlc ? { jlcpcb: [jlc] } : undefined} />
  )
}
/** Ferrite bead modelled as a chip so its value string ("22R@100MHz") is preserved in the BOM. */
export const Bead = (p: PassiveSpec & { mpn: string }) => {
  const fp = p.footprint ?? "0603"
  return (
    <chip name={p.name} manufacturerPartNumber={p.mpn} footprint={fp} pcbX={p.x} pcbY={p.y} pcbRotation={p.rot ?? 0} layer={p.side ?? "top"}
      schX={p.sch[0]} schY={p.sch[1]} schRotation={p.schRot ?? 0} schSectionName={p.section} pinLabels={{ pin1: ["A"], pin2: ["B"] }}
      schWidth={0.6} schHeight={1} schPinArrangement={{ topSide: { direction: "left-to-right", pins: ["A"] }, bottomSide: { direction: "left-to-right", pins: ["B"] } }}
      supplierPartNumbers={p.jlc ? { jlcpcb: [p.jlc] } : undefined} />
  )
}