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-motherboardIn 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/padnets.ts
// List top pads (with net names) in a region: bun tools/padnets.ts x0 y0 x1 y1 [netRegex] [layer]
import { readFileSync } from "node:fs"
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map"
const [x0,y0,x1,y1]=process.argv.slice(2,6).map(Number); const re=new RegExp(process.argv[6]??"."); const L=process.argv[7]??"top"
const cj=JSON.parse(readFileSync(process.env.CJ ?? "dist/index/circuit.json","utf8"))
const cm=getFullConnectivityMapFromCircuitJson(cj)
const by=(t:string)=>cj.filter((e:any)=>e.type===t)
const netName=new Map<string,string>()
for(const n of by("source_net")){const k=cm.getNetConnectedToId(n.source_net_id); if(k&&!netName.has(k))netName.set(k,n.name)}
const sp=new Map(by("source_port").map((p:any)=>[p.source_port_id,p]))
const sc=new Map(by("source_component").map((p:any)=>[p.source_component_id,p]))
const pp=new Map(by("pcb_port").map((p:any)=>[p.pcb_port_id,p]))
for(const pad of by("pcb_smtpad")){ if(pad.layer!==L)continue
let x=pad.x,y=pad.y; if(x===undefined&&pad.points){x=pad.points.reduce((a:number,p:any)=>a+p.x,0)/pad.points.length;y=pad.points.reduce((a:number,p:any)=>a+p.y,0)/pad.points.length}
if(x<x0||x>x1||y<y0||y>y1)continue
const port:any=pp.get(pad.pcb_port_id); const s:any=port&&sp.get(port.source_port_id)
const k=cm.getNetConnectedToId(pad.pcb_port_id??"")
const net=(k&&netName.get(k))??k??"-"
if(!re.test(net))continue
const c:any=s&&sc.get(s.source_component_id)
let w=pad.width,h=pad.height; if(pad.points){const xs=pad.points.map((p:any)=>p.x),ys=pad.points.map((p:any)=>p.y);w=Math.max(...xs)-Math.min(...xs);h=Math.max(...ys)-Math.min(...ys)}
if(pad.ccw_rotation&&Math.abs(pad.ccw_rotation%180)===90)[w,h]=[h,w]
console.log(`${(c?.name??"?")+"."+(s?.name??"?")}\t${net}\t${x.toFixed(2)}\t${y.toFixed(2)}\t${w.toFixed(2)}\t${h.toFixed(2)}`)}