app
Codex
Public Made by Adomby adom
Codex in Adom Hydrogen: ecosystem setup, dock dashboard and live engineering demos.
main
John Lauer
Corrected Astra ESC routing: native zero-open result, full accounting and voiceover handoff
a80479d
23d ago
from planner import *
import ast
source=Path('repair2.py').read_text().replace('width/2-.04','width/2-.005')
exec(compile(ast.Module(body=[n for n in ast.parse(source).body if isinstance(n,ast.FunctionDef)],type_ignores=[]),'repair-functions','exec'),globals())
import planner as m
m.copper.clear()
old=json.load(open('plan-repair2.json'))
priority=['/TIM1_CH1_INHC','/SWCLK','/SWDIO','/nRST','/COMP1_INM_IO1_BEMF_B','/COMP1_INM_IO2_BEMF_C','/DRV_SHA','/DRV_SHB','/DRV_SHC','+VBAT']
plans=[]
for n in priority+[p['net'] for p in old if p['net'] not in priority and p['net'] not in ['GND','+3V3']]:
width=.5 if n in ['+VBAT','GND_OUT','/DRV_SHA','/DRV_SHB','/DRV_SHC'] else .25
plan=dict(net=n,width=width,paths=[]);plans.append(plan)
gr=groups(n);tried=set()
while len(gr)>1:
pairs=sorted((math.hypot(p['x']-q['x'],p['y']-q['y']),i,j,p,q) for i,pp in enumerate(gr) for j,qq in enumerate(gr[:i]) for p in pp for q in qq)
found=False
for dist,i,j,p,q in pairs:
key=(p['name'],q['name'])
if key in tried:continue
tried.add(key)
route=search2(masks(n,width),p,(q['x'],q['y']),[(0,t['g']) for t in gr[j]],width)
if route:
register(n,route,width);plan['paths'].append(route);found=True;break
if not found:break
gr=groups(n)
print(n,'groups',len(gr),'paths',len(plan['paths']),flush=True)
Path('replan.json').write_text(json.dumps(plans,indent=2))
# place individual plane stubs after reserving signal escapes
for n,layer in [('GND','In1.Cu'),('+3V3','In2.Cu')]:
plan=dict(net=n,width=.25,paths=[]);plans.append(plan)
for p in sorted(by[n],key=lambda p:p['g'].area):
if p['type']=='thru_hole':continue
route=search2(masks(n,.25),p,(p['x'],p['y']),[],plane=True)
if route:
e=route[-1];route.append(dict(x=e[0],y=e[1],layer=layer));register(n,route,.25);plan['paths'].append(route)
else:print('PLANE FAIL',n,p['name'],flush=True)
print(n,len(plan['paths']),flush=True)
Path('replan.json').write_text(json.dumps(plans,indent=2))