hrithik18k/punck-tscircuit-recreation
A four-layer Eurorack drum/sampler controller PCB built around an STM32H743, dual QSPI flash, PCM5100 stereo DAC, TL074 analog audio circuitry, input clamps, 12V-to-3.3V power regulation, MIDI/USB/SWD connectors, controls, LEDs, and trigger/audio I/O.
- Version
- 1.0.3
- License
- unset
- Stars
- 0
scripts/prepare.ts
import fs from 'node:fs'
import { source_port } from 'circuit-json'
fs.mkdirSync('prepared',{recursive:true})
for(const name of ['components','controls','panel']) {
const json = JSON.parse(fs.readFileSync(`boards/${name}.pcb.circuit.json`,'utf8'))
const changes:any[]=[]
if(name==='panel') {
// This passive panel has only KiCad net-0 decorative copper, no ports.
// Group that intentionally touching artwork for the connectivity checker.
json.push({type:'source_net',source_net_id:'panel_artwork_net',name:'PANEL_COPPER_ARTWORK',member_source_group_ids:[]})
for(const e of json.filter((e:any)=>e.type==='pcb_copper_pour')) e.source_net_id='panel_artwork_net'
changes.push({note:'Grouped netless mechanical panel copper as PANEL_COPPER_ARTWORK; no electrical ports or traces exist on this panel.'})
}
for(const e of json) {
if(e.type==='pcb_copper_pour' && e.net_name) {
const net=json.find((n:any)=>n.type==='source_net' && n.name===e.net_name)
if(net){e.source_net_id=net.source_net_id;changes.push({id:e.pcb_copper_pour_id,source_net_id:e.source_net_id})}
}
if(e.type==='source_port' && typeof e.pin_number==='string') {
changes.push({id:e.source_port_id,removedInvalidPinNumber:e.pin_number})
// Preserve the real alphanumeric pin in name/id; pin_number is optional numeric metadata.
delete e.pin_number
source_port.parse(e)
}
}
fs.writeFileSync(`prepared/${name}.circuit.json`,JSON.stringify(json,null,2))
fs.writeFileSync(`evidence/${name}-repairs.json`,JSON.stringify(changes,null,2))
}