pixalynx/pixal-gps

These files define two separate printed circuit boards: a small, two-layer battery cartridge with protection circuitry and contact pads for a pouch cell, and a larger, two-layer wireless charging dock featuring USB-C input, a resonant coil, and wireless power transmission components.

Version
0.1.2
License
unset
Stars
0

scripts/audit-copper.py

#!/usr/bin/env python3
"""Audit a built circuit.json: every pcb_trace/pcb_via must join ports of one source net only,
and report which source nets have no copper at all. Usage: audit-copper.py dist/<board>/circuit.json"""
import json, sys, collections
d = json.load(open(sys.argv[1]))
ports = {p['pcb_port_id']: p for p in d if p['type'] == 'pcb_port'}
sports = {p['source_port_id']: p for p in d if p['type'] == 'source_port'}
comps = {c['source_component_id']: c['name'] for c in d if c['type'] == 'source_component'}
key_of = {}
for pid, p in ports.items():
    sp = sports.get(p.get('source_port_id'))
    if sp: key_of[pid] = (sp.get('subcircuit_connectivity_map_key'), f"{comps.get(sp['source_component_id'],'?')}.{sp.get('name')}")
bad = 0
for t in d:
    if t['type'] != 'pcb_trace': continue
    keys = set(); names = []
    for pt in t['route']:
        for k in ('start_pcb_port_id', 'end_pcb_port_id'):
            pid = pt.get(k)
            if pid and pid in key_of:
                keys.add(key_of[pid][0]); names.append(key_of[pid][1])
    if len(keys) > 1:
        bad += 1; print('MIXED-NET TRACE', t.get('pcb_trace_id'), names, keys)
nets = collections.Counter()
traced = set(t.get('source_trace_id') for t in d if t['type'] == 'pcb_trace')
missing = [e for e in d if e['type'] in ('pcb_port_not_connected_error', 'pcb_trace_missing_error')]
print(f"pcb_traces={sum(1 for t in d if t['type']=='pcb_trace')} vias={sum(1 for t in d if t['type']=='pcb_via')} mixed={bad} unconnected_reports={len(missing)}")
for e in missing[:12]: print('  ', e['message'][:110])
errs = collections.Counter(e['type'] for e in d if e['type'].endswith('_error') and e['type'].startswith('pcb'))
print('pcb errors:', dict(errs))