imrishabh18/rp2040-motor-controller
An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.
- Version
- 1.0.41
- License
- unset
- Stars
- 3
scripts/save-ground-pour-selection.py
"""Freeze only the ground pours belonging to the independently audited network."""
import json,hashlib,sys
from pathlib import Path
path=Path(sys.argv[1] if len(sys.argv)>1 else 'dist/revision/circuit.json')
j=json.loads(path.read_text());audit=json.loads(Path('reports/ground-copper-connectivity.json').read_text())
assert audit['circuitJsonSha256']==hashlib.sha256(path.read_bytes()).hexdigest(), 'Run the physical ground audit first'
groups=audit['groups']; main=groups[0]
assert all(all(i.startswith('pcb_copper_pour_') for i in g['elements']) for g in groups[1:]), 'A ground pad, trace or via is disconnected; fix routing first'
keep=set(main['elements']);regions=[{'geometry':{k:e[k] for k in ['layer','source_net_id','brep_shape']},'keep':e['pcb_copper_pour_id'] in keep} for e in j if e['type']=='pcb_copper_pour']
assert any(r['keep'] for r in regions)
Path('routing/ground-pour-selection.json').write_text(json.dumps({'circuitJsonSha256':audit['circuitJsonSha256'],'regions':regions},indent=2)+'\n')
print('Kept',sum(r['keep'] for r in regions),'connected pours; excluded',sum(not r['keep'] for r in regions),'floating copper fragments')
