shibosoftwaredev/f1c100s-linux-nema17-stepper-controller
A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.
- Version
- 0.4.56
- License
- unset
- Stars
- 0
scripts/continue-usb-top.py
"""Continue from checked candidate copper to reconnect a displaced monitor branch."""
from route_geometry import *
c=load_circuit("routing/usb-top-placement.circuit.json");root=connectivity(c)
m=json.loads(Path("routing/net-map.json").read_text())["roots"]
sources={e["source_trace_id"]:e for e in c if e["type"]=="source_trace"}
by_net={}
for s in sources.values():
ids=s.get("connected_source_port_ids",[])+s.get("connected_source_net_ids",[])
if ids:by_net.setdefault(m[root(ids[0])],s)
cu=json.loads(Path(os.environ.get("PHYSICAL_INPUT","routing/usb-top-physical-candidate.json")).read_text())
retained=[]
for w in cu["wires"]:
s=by_net[w["net"]]
retained.append(dict(type="pcb_trace",source_trace_id=s["source_trace_id"],route=[dict(route_type="wire",layer=w["layer"],width=w["width"],x=x,y=y) for x,y in w["points"]]))
for v in cu["vias"]:
s=by_net[v["net"]]
retained.append(dict(type="pcb_trace",source_trace_id=s["source_trace_id"],route=[dict(route_type="via",x=v["x"],y=v["y"],from_layer="top",to_layer="bottom",via_diameter=.45,via_hole_diameter=.3)]))
s=next(s for s in sources.values() if s.get("name")==os.environ.get("SOURCE_NAME","PD_ADC_RAW_INPUT"))
p={e["source_port_id"]:e for e in c if e["type"]=="pcb_port"}
endpoint=lambda e:{k:e[k] for k in ["x","y","layers","pcb_port_id"]}
jobs=[dict(source=s["source_trace_id"],start=endpoint(p[s["connected_source_port_ids"][0]]),target={**endpoint(p[s["connected_source_port_ids"][1]]),"connected_tree":True},constraints={"min_trace_thickness":.35})]
Path("routing/usb-top-final-retained.json").write_text(json.dumps(retained,indent=2)+"\n")
Path("routing/usb-top-final-plan.json").write_text(json.dumps(dict(prefix="usb-top-final",placement="routing/usb-top-placement.circuit.json",retained="routing/usb-top-final-retained.json",extent=[-4,-2,20.9,20.9],jobs=jobs),indent=2)+"\n")