gokul/macro-six-usbc
A six-key macro keyboard PCB paired with a separate physical enclosure.
- Version
- 0.1.16
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone gokul/macro-six-usbc # download the package files into ./macro-six-usbc
tsci add gokul/macro-six-usbc # add it to your project as @tsci/gokul.macro-six-usbcIn 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.
manufacturing/check-usb-routing.py
"""Record local USB routing geometry; this is not a signal-integrity certification."""
import sys,json,math
from pathlib import Path
sys.argv=['check',sys.argv[1] if len(sys.argv)>1 else 'outputs/release/board.circuit.json']
exec(Path('manufacturing/check-copper.py').read_text().split('errors=[];min_gap=10')[0])
names={e['source_component_id']:e['name'] for e in j if e['type']=='source_component'}
sp={e['source_port_id']:e for e in j if e['type']=='source_port'}
def port(component,hint):
return next(e['pcb_port_id'] for e in j if e['type']=='pcb_port' and names[sp[e['source_port_id']]['source_component_id']]==component and hint in sp[e['source_port_id']].get('port_hints',[]))
def trace_at(pid):
return next(e for e in j if e['type']=='pcb_trace' and (e['route'][0].get('start_pcb_port_id')==pid or e['route'][-1].get('end_pcb_port_id')==pid))
report={'sections':[], 'controlled_impedance_verified':False,'physical_usb_tested':False}
for name in ['R_DM','R_DP']:
for pin,section in [('pin1','ESD to series resistor'),('pin2','series resistor to MCU')]:
t=trace_at(port(name,pin));r=t['route'];vias=sum(a['route_type']=='via' for a in r)
length=sum(math.hypot(a['x']-b['x'],a['y']-b['y']) for a,b in zip(r,r[1:]))
assert vias<=(2 if pin=='pin1' else 0),(name,section,vias)
report['sections'].append({'resistor':name,'section':section,'vias':vias,'length_mm':round(length,4)})
ground=next(e['source_net_id'] for e in j if e['type']=='source_net' and e['name']=='GND')
g=unary_union([f['geometry'] for f in features if f['layer']=='top' and f['net']==ground])
# Shared parallel section, excluding endpoint pad/via fan-outs. Full projected copper width.
centre=LineString([(25.8,25.3),(29,25.3),(31,23.3),(31,17),(33,15),(34.7,13.98)])
reference=centre.buffer(.325,cap_style=2,join_style=2)
missing=reference.difference(g).area
report['parallel_section_mm']=round(centre.length,4)
report['parallel_section_projected_copper_without_top_ground_mm2']=round(missing,6)
report['fanout_reference_limit']='Pad/via fan-outs have local plane openings; no controlled-impedance or measured USB compliance claim.'
assert missing<.001,missing
Path('outputs/release/usb-routing-validation.json').write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(report,indent=2))