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/render-system-diagram.tsx

// Render the system diagram pages to docs/system-diagram/<page>.svg and .png:  bun tools/render-system-diagram.tsx
import { Circuit } from "tscircuit"
import { convertCircuitJsonToSystemSvg } from "circuit-to-svg"
import { Resvg } from "@resvg/resvg-js"
import { mkdirSync, writeFileSync } from "node:fs"
import SystemDiagram from "../system-diagram.circuit"

const output = "docs/system-diagram"
mkdirSync(output, { recursive: true })
const circuit = new Circuit({ platform: { partsEngineDisabled: true } } as any)
circuit.add(<SystemDiagram />)
await circuit.renderUntilSettled()
const json: any[] = circuit.getCircuitJson()
const errors = json.filter((x) => x.type.endsWith("_error"))
if (errors.length) throw new Error(JSON.stringify(errors, null, 2))
const pages = json.filter((x) => x.type === "system_block_page")
for (const page of pages) {
  const svg = convertCircuitJsonToSystemSvg(json as any, { systemBlockPageId: page.system_block_page_id, width: 2200, includeVersion: false } as any)
  writeFileSync(`${output}/${page.name}.svg`, svg)
  writeFileSync(`${output}/${page.name}.png`, new Resvg(svg, { background: "#ffffff" }).render().asPng())
  console.log(`Rendered ${page.name}`)
}