imrishabh18/rp2040-motor-controller

A library of PCB component definitions covering MOSFETs, motor drivers, USB-PD control, sensors, current monitors, transistors, diodes, resistors, speakers, connectors, and mirrored bottom-side logos, with pin mappings, footprints, and 3D models.

Version
1.0.55
License
unset
Stars
5

scripts/route-pg-branches.py

"""Route only new PG branches; retain the existing validated routes as obstacles."""
import json, subprocess
from pathlib import Path
folder=Path('dist/pg-sense');report=Path('reports/pg-sense-2026-10-22')
pending=json.loads((folder/('pending-routes.json' if (folder/'pending-routes.json').exists() else 'new-routes.json')).read_text())
order=['pg_pd_pg_decoupling','pg_pd_good','pg_pd_good_pulldown','pg_pd_pg_sense','pg_pd_pg_supply_sense','pg_pd_pg_supply_discharge','pg_pd_pg_logic_supply','pg_pd_pg_ground','pg_pd_pg_function','pg_pd_pg_decoupling_gnd','pg_pd_pg_supply_discharge_gnd','pg_pd_good_pulldown_gnd']
for id in order:
    if id not in pending:continue
    args=['.venv/bin/python','scripts/route-local.py',str(folder),id,'.15','--ripup='+','.join(pending),'--report-dir='+str(report)]
    if id.endswith('_gnd') or id in ['pg_pd_pg_ground','pg_pd_pg_function']:args.append('--ground-stitch')
    print('Routing',id,flush=True)
    with (report/(id+'.log')).open('w') as out:
        p=subprocess.run(args,stdout=out,stderr=subprocess.STDOUT)
    print((report/(id+'.log')).read_text()[-2500:],flush=True)
    if p.returncode:raise SystemExit(p.returncode)
    pending.remove(id)
    (folder/'pending-routes.json').write_text(json.dumps(pending,indent=2))