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
native/NativeBoard.tsx
import { ExactFootprint } from './ExactFootprint'
const normalizeValue=(v:string)=>v.replace(/^(\d+)([kmunp])(\d+)$/,'$1.$3$2')
export function NativeBoard({data}: {data:any}) {
const nets=[...new Set<string>(data.parts.flatMap((p:any)=>p.pins.filter((pin:any)=>pin.net&&!pin.nc).map((pin:any)=>pin.net)))]
return <board width={data.width} height={data.height} thickness={data.thickness} layers={data.layers}
autorouter={{local:true,allowViaInPad:false}} minViaEdgeToPadEdgeClearance={data.layers===4?0.4:0.2} minTraceWidth={0.15}>
{data.sections.map((s:string)=><schematicsection key={s} name={s} displayName={s.replaceAll('_',' ')} />)}
{nets.map(n=><net key={n} name={n} />)}
{data.parts.map((p:any)=>{
const footprint=<ExactFootprint part={p}/>
if(!p.pins.length)return <group key={p.name} pcbX={p.x} pcbY={p.y}>{footprint}</group>
const common:any={name:p.name,pcbX:p.x,pcbY:p.y,pcbRotation:['C24','R16','C26','C23'].includes(p.name)?180:0,layer:p.layer,footprint,schX:p.schX,schY:p.schY,schRotation:p.schRotation??0,schSectionName:p.section}
if(p.ftype==='simple_resistor'&&p.pins.length===2)return <resistor key={p.name} {...common} resistance={normalizeValue(p.value)} />
if(p.ftype==='simple_capacitor'&&p.pins.length===2)return <capacitor key={p.name} {...common} schOrientation={['C1','C34','C20'].includes(p.name)?'vertical':undefined} capacitance={normalizeValue(p.value)} />
const pinLabels=Object.fromEntries(p.pins.map((pin:any)=>[pin.selector,[pin.label.replace(/\+/g,'_PLUS').replace(/-/g,'_MINUS').replace(/[^a-zA-Z0-9_]/g,'_')]]))
const pinAttributes=Object.fromEntries(p.pins.filter((pin:any)=>pin.nc).map((pin:any)=>[pin.selector,{doNotConnect:true}]))
const half=Math.ceil(p.pins.length/2)
return <chip key={p.name} {...common} manufacturerPartNumber={p.value} pinLabels={pinLabels} pinAttributes={pinAttributes}
schWidth={p.schWidth??(p.pins.length>20?9:4)} schHeight={p.verticalPins?1:(half+1)*0.2}
schPinArrangement={p.verticalPins?{topSide:{direction:'left-to-right',pins:[p.verticalPins[0]]},bottomSide:{direction:'left-to-right',pins:[p.verticalPins[1]]}}:{leftSide:{direction:'top-to-bottom',pins:p.pins.slice(0,half).map((pin:any)=>pin.selector)},rightSide:{direction:'top-to-bottom',pins:p.pins.slice(half).map((pin:any)=>pin.selector)}}}/>
})}
{data.parts.flatMap((p:any)=>p.pins.filter((pin:any)=>pin.net&&!pin.nc).map((pin:any)=><netlabel key={`${p.name}-${pin.selector}`} connection={`.${p.name} > .${pin.selector}`} net={pin.net}/>))}
</board>
}