MustafaMulla29/usb-pd-motherboard

4-layer USB-C PD hub motherboard with 20 V USB-C input, Linux T113-S3 computer, CH338F USB hub, four individually controlled 5–20 V PD outputs, USB data/camera ports, regulated rails, and hardware watchdog/E-stop safety interlock.

Version
1.0.24
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone MustafaMulla29/usb-pd-motherboard  # download the package files into ./usb-pd-motherboard
tsci add MustafaMulla29/usb-pd-motherboard    # add it to your project as @tsci/MustafaMulla29.usb-pd-motherboard

In 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.

tools/zoom.ts

// Render a region of the board (all layers) to SVG: bun tools/zoom.ts x0 y0 x1 y1 out.svg
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { readFileSync, writeFileSync } from "node:fs"
const [x0, y0, x1, y1] = process.argv.slice(2, 6).map(Number)
const out = process.argv[6]
const cj = JSON.parse(readFileSync("dist/index/circuit.json", "utf8"))
const inside = (x: number, y: number) => x >= x0 - 2 && x <= x1 + 2 && y >= y0 - 2 && y <= y1 + 2
const keep = cj.filter((e: any) => {
  if (e.type === "pcb_board") return false
  if (e.type === "pcb_trace") return e.route.some((p: any) => inside(p.x, p.y))
  if (e.type === "pcb_copper_pour" || e.type.startsWith("pcb_silkscreen") || e.type.startsWith("pcb_fabrication") || e.type === "pcb_courtyard_rect" || e.type.includes("courtyard")) return false
  if (typeof e.x === "number" && typeof e.y === "number") return inside(e.x, e.y)
  if (e.center) return inside(e.center.x, e.center.y)
  return !e.type.startsWith("pcb_") || e.type === "pcb_port"
})
keep.push({ type: "pcb_board", pcb_board_id: "zoom", center: { x: (x0 + x1) / 2, y: (y0 + y1) / 2 }, width: x1 - x0, height: y1 - y0, thickness: 1.6, num_layers: 8, material: "fr4" })
writeFileSync(out, convertCircuitJsonToPcbSvg(keep, { width: 1400, height: Math.round(1400 * (y1 - y0) / (x1 - x0)) } as any))