pixalynx/cm5-minimal-carrier

A 4-layer Raspberry Pi CM5 carrier board routes USB‑C 5V power through an RT9742 load switch with TVS protection and capacitive filtering, while providing ESD-protected HDMI output, CM5 connectors, test points, and ground/power planes.

Version
0.1.1
License
unset
Stars
0

scripts/render.ts

import { Resvg } from '@resvg/resvg-js'
import {convertCircuitJsonToPcbSvg,convertCircuitJsonToSchematicSvg} from 'circuit-to-svg'
import type {AnyCircuitElement} from 'circuit-json'
const c:AnyCircuitElement[]=await Bun.file('dist/index/circuit.json').json()
for(const layer of ['top','inner1','inner2','bottom'] as const){
 const svg=convertCircuitJsonToPcbSvg(c,{layer,width:1500,height:1420,matchBoardAspectRatio:true,showSolderMask:false,showCourtyards:false,showPinNumbers:false,shouldDrawErrors:true,showErrorsInTextOverlay:true,backgroundColor:'#101d27'})
 await Bun.write(`output/pcb-${layer}.svg`,svg)
 await Bun.write(`output/pcb-${layer}.png`,new Resvg(svg).render().asPng())
}
for(const [i,s] of c.filter(e=>e.type==='schematic_sheet').entries()){
 const sheet=c.filter(e=>e.type!=='schematic_sheet'&&(!e.type.startsWith('schematic_')||!('schematic_sheet_id' in e)||e.schematic_sheet_id===s.schematic_sheet_id)).map(e=>{const item={...e};delete (item as any).schematic_sheet_id;return item})
 const svg=convertCircuitJsonToSchematicSvg(sheet,{width:1800,height:1400})
 const name=`${String(i+1).padStart(2,'0')}-${s.name}`
 await Bun.write(`output/schematics/${name}.svg`,svg)
 await Bun.write(`output/schematics/${name}.png`,new Resvg(svg).render().asPng())
}