seveibar/am3352-dev-board

A 324-ball TI AM3352 ARM processor with DDR3, LCD, USB, Ethernet, storage, serial, analog, clock, reset, power, and JTAG interfaces, paired with configurable JST-GH board connectors and constrained PCB routing.

Version
1.0.2
License
unset
Stars
0

scripts/check-filled-via-sites.py

import runpy,json,math
from pathlib import Path
from shapely.geometry import Point
from shapely.ops import unary_union
from shapely.prepared import prep
x=runpy.run_path('scripts/audit-copper.py');report=[]
for net,ps in x['netports'].items():
 name=x['netnames'].get(net,net)
 if name not in x['incomplete']:continue
 groups={}
 for p in set(ps):groups.setdefault(x['component'](x['padnodes'][p][0]),[]).append(p)
 main=max(groups,key=lambda k:len(groups[k]));block=prep(unary_union([g for g,m in zip(x['shapes'],x['meta']) if m[1]!=net and not m[2].startswith('pcb_copper_pour')]).buffer(.250001))
 for group,ports in groups.items():
  if group==main:continue
  found=None
  for p in ports:
   pad=x['shapes'][x['padnodes'][p][0]];port=x['ports'][p]
   for dx,dy in sorted([(a,b) for a in [-.1,-.075,-.05,-.025,0,.025,.05,.075,.1] for b in [-.1,-.075,-.05,-.025,0,.025,.05,.075,.1]],key=lambda z:z[0]**2+z[1]**2):
    point=Point(port['x']+dx,port['y']+dy)
    if not pad.covers(point) or block.intersects(point):continue
    found={'port':p,'x':point.x,'y':point.y};break
   if found:break
  report.append({'net':name,'ports':ports,'site':found})
Path('design/filled-via-sites.json').write_text(json.dumps(report,indent=2));print('Clear filled-via candidates:',sum(bool(r['site']) for r in report),'/',len(report));print(*report,sep='\n')