abse/museair-usb

USB-C–powered ESP32-C3 controller board with AP63203 buck conversion, AP2112K 3.3V regulation, I²C SEN62 sensor interface, status LED, buttons, UART/I²C headers, and extensive decoupling.

Version
0.5.7
License
unset
Stars
0

scripts/verify-lightpipe.mjs

import fs from 'node:fs';import assert from 'node:assert/strict';import crypto from 'node:crypto';import {runAllChecks} from '@tscircuit/checks';
const root=new URL('../',import.meta.url);const read=p=>JSON.parse(fs.readFileSync(new URL(p,root)));const baseline=read('validation/lightpipe-baseline-fingerprints.json'),now=read('dist/index/circuit.json');const hash=v=>crypto.createHash('sha256').update(JSON.stringify(v)).digest('hex');
const pinMap=c=>{const refs=Object.fromEntries(c.filter(x=>x.type==='source_component').map(x=>[x.source_component_id,x.name]));const nets=Object.fromEntries(c.filter(x=>x.type==='source_net').map(x=>[x.subcircuit_connectivity_map_key,x.name]));return c.filter(x=>x.type==='source_port').map(x=>[refs[x.source_component_id],x.pin_number,x.name,nets[x.subcircuit_connectivity_map_key]??null]).sort((a,b)=>JSON.stringify(a).localeCompare(JSON.stringify(b)))};
assert.equal(hash(pinMap(now)),baseline.pin_map_sha256);for(const type of ['pcb_component','pcb_smtpad','pcb_plated_hole','source_component','source_net','source_trace'])assert.equal(hash(now.filter(x=>x.type===type)),baseline.types[type],type+' changed unexpectedly');
const holes=[[20.532,12.2728],[16.468,15.7272]];for(const [x,y]of holes){assert(now.some(h=>h.type==='pcb_hole'&&Math.hypot(h.x-x,h.y-y)<1e-8&&Math.abs(h.hole_diameter-.6096)<1e-8));assert(now.some(h=>h.type==='pcb_keepout'&&Math.hypot(h.center.x-x,h.center.y-y)<1e-8&&h.radius===.6048&&h.layers.includes('top')&&h.layers.includes('bottom')))}
const findings=[...now.filter(x=>x.type.includes('error')),...await runAllChecks(now)];const errors=findings.filter(x=>x.type.includes('error'));assert.equal(errors.length,0,JSON.stringify(errors));
const drc=read('validation/kicad-drc.json');assert.equal(drc.violations.length,0);assert.equal(drc.unconnected_items.length,0);
const report={native_drc_violations:0,native_unconnected_items:0,gerber_shorts:0,additional_PCB_bitmap_scan:'Unavailable in pinned CLI; native DRC and Gerber scan run',status:'pass',source_pin_net_assignments_unchanged:244,component_placements_and_imported_pads_unchanged:true,holes_mm:holes.map(([x,y])=>({x,y,drill:.6096,copper_keepout_radius:.6048})),route_widths_preserved:.2,rerouted_traces:['source_net_35_0','source_net_34_0'],circuit_error_records:0,checks_error_records:0,physical_fit_tested:false,published:false};fs.writeFileSync(new URL('validation/lightpipe-routing-review.json',root),JSON.stringify({...read('validation/lightpipe-routing-review.json'),...report},null,2));console.log(report);