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/apply-display-audio-routing-repairs.mjs
import fs from 'node:fs'
import crypto from 'node:crypto'
const hash=v=>crypto.createHash('sha256').update(JSON.stringify(v)).digest('hex')
const route=r=>r.map(({is_inside_copper_pour,copper_pour_id,...p})=>p)
export function repairDisplayAudio(records){
if(!records.some(x=>x.type==='source_component'&&x.name==='MIC1'))return []
const patch=JSON.parse(fs.readFileSync(new URL('./display-audio-routing-repairs.json',import.meta.url)))
const geometry=records.filter(x=>x.type==='pcb_smtpad').map(({type,pcb_smtpad_id,pcb_component_id,pcb_port_id,subcircuit_id,...p})=>p)
if(hash(geometry)!==patch.pad_fingerprint)throw Error('Display/audio pad placement changed; review copper repairs for the new layout')
const repairs=[]
for(const p of patch.traces){
const t=records.find(x=>x.type==='pcb_trace'&&x.pcb_trace_id===p.id)
if(!t)throw Error('Missing display/audio routing trace '+p.id)
const h=hash(route(t.route))
if(h===p.output_sha256)continue
if(h!==p.input_sha256)throw Error('Autorouter geometry changed; review correction for '+p.id)
t.route=structuredClone(p.route);repairs.push({trace:p.id,repair:'Reviewed clearance/short correction, terminal positions preserved'})
}
for(const p of patch.vias){
const v=records.find(x=>x.type==='pcb_via'&&x.pcb_via_id===p.id)
if(!v)throw Error('Missing reviewed via '+p.id)
if(Math.hypot(v.x-p.output.x,v.y-p.output.y)<1e-7)continue
if(Math.hypot(v.x-p.input.x,v.y-p.input.y)>1e-7)throw Error('Autorouter via geometry changed; review '+p.id)
v.x=p.output.x;v.y=p.output.y;repairs.push({via:p.id,from:p.input,to:p.output})
}
for(const v of patch.new_vias??[]){
const old=records.find(x=>x.type==='pcb_via'&&x.pcb_via_id===v.pcb_via_id)
if(!old){records.push(structuredClone(v));repairs.push({via:v.pcb_via_id,repair:'Add missing SMT terminal layer transition outside the pad'})}
else if(hash(old)!==hash(v))throw Error('Added via geometry changed; review '+v.pcb_via_id)
}
for(const p of patch.removed_vias??[]){
const i=records.findIndex(x=>x.type==='pcb_via'&&x.pcb_via_id===p.id)
if(i<0)continue
const v=records[i];if(Math.hypot(v.x-p.input.x,v.y-p.input.y)>1e-7)throw Error('Removed via geometry changed; review '+p.id)
records.splice(i,1);repairs.push({via:p.id,repair:'Remove unused via after reviewed rerouting'})
}
return repairs
}