rushabhcodes/wireless-split-keyboard

Wireless Split Keyboard — custom routed nRF52840 split PCBs with a printable enclosure

Version
0.4.5
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone rushabhcodes/wireless-split-keyboard  # download the package files into ./wireless-split-keyboard
tsci add rushabhcodes/wireless-split-keyboard    # add it to your project as @tsci/rushabhcodes.wireless-split-keyboard

In 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.

scripts/check-placement-review.py

"""Resolve the placement adviser's two right-side AABB overlap reports.
Use the actual rotated courtyard polygons, including the stepped Choc body.
"""
from pathlib import Path
import json,hashlib
from shapely.geometry import Polygon,box
from shapely.affinity import rotate
from shapely.ops import unary_union
root=Path(__file__).resolve().parents[1]
path=root/'outputs/right/keyboard.circuit.json'
j=json.loads(path.read_text())
sources={e['source_component_id']:e['name'] for e in j if e['type']=='source_component'}
components={sources[e['source_component_id']]:e['pcb_component_id'] for e in j if e['type']=='pcb_component'}
def courtyard(ref):
 shapes=[]
 for e in j:
  if e.get('pcb_component_id')!=components[ref] or not e['type'].startswith('pcb_courtyard'):continue
  if 'outline' in e:p=Polygon([(a['x'],a['y']) for a in e['outline']])
  else:
   c=e['center'];x,y=c['x'],c['y'];w,h=e['width'],e['height']
   p=rotate(box(x-w/2,y-h/2,x+w/2,y+h/2),e.get('ccw_rotation',0),origin=(x,y))
  shapes.append(p)
 assert shapes,ref
 return unary_union(shapes)
results=[]
for ref in ['D26','C_REG_OUT1']:
 a,b=courtyard('SW26'),courtyard(ref)
 overlap=a.intersection(b).area
 results.append({'pair':['SW26',ref],'courtyardIntersectionMm2':overlap,'courtyardGapMm':a.distance(b),'result':'No overlap of actual rotated courtyards; adviser uses axis-aligned bounds'})
 assert overlap<1e-8
report={'circuitJsonSha256':hashlib.sha256(path.read_bytes()).hexdigest(),'method':'Exact Shapely polygons from native pcb_courtyard_rect/outline; rotate rectangles by ccw_rotation','reviewedPairs':results,'limitations':'Courtyard check only; not a full physical fit certification'}
(root/'outputs/right/placement-review.json').write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(report,indent=2))