pixalynx/nrf9151-gps-tracker

A compact 44×32 mm, 4-layer nRF9151 LTE-M/NB-IoT/GNSS tracker PCB with nPM1300 LiPo/USB-C power, nano-SIM/eSIM switching, nRF7002 Wi‑Fi scanning, accelerometer, antennas, buzzer, LEDs, SOS button, and SWD/debug connectors.

Version
0.1.4
License
unset
Stars
0

scripts/pads.py

#!/usr/bin/env python3
"""Print the pads of the named components from dist/<entry>/circuit.json in board coordinates.
Usage: python3 scripts/pads.py U3 [J5 ...] [--entry index]"""
import json, sys
args = [a for a in sys.argv[1:] if not a.startswith('--')]
entry = sys.argv[sys.argv.index('--entry') + 1] if '--entry' in sys.argv else 'index'
if '--entry' in sys.argv: args.remove(entry)
d = json.load(open(f'dist/{entry}/circuit.json'))
src = {c['source_component_id']: c['name'] for c in d if c['type'] == 'source_component'}
comp = {c['pcb_component_id']: c for c in d if c['type'] == 'pcb_component'}
ports = {c['pcb_port_id']: c for c in d if c['type'] == 'pcb_port'}
sp = {c['source_port_id']: c for c in d if c['type'] == 'source_port'}
net_of = {}
for t in d:
    if t['type'] == 'source_trace':
        for p in t.get('connected_source_port_ids', []):
            for n in t.get('connected_source_net_ids', []):
                net_of.setdefault(p, set()).add(n)
nets = {c['source_net_id']: c['name'] for c in d if c['type'] == 'source_net'}
for c in d:
    if c['type'] not in ('pcb_smtpad', 'pcb_plated_hole'): continue
    cc = comp.get(c.get('pcb_component_id'))
    if not cc or src[cc['source_component_id']] not in args: continue
    p = ports.get(c.get('pcb_port_id'))
    s = sp.get(p['source_port_id']) if p else None
    n = ','.join(nets[x] for x in net_of.get(s['source_port_id'], [])) if s else ''
    print(f"{src[cc['source_component_id']]:4} {s['name'] if s else '-':10} x={c['x']:7.3f} y={c['y']:7.3f} {c.get('layer','th'):6} {n}")