seveibar/pedometer
This hardware setup integrates a Type-C connector, battery, display, and RF antenna connected through a microcontroller, USB interface, charging and fuel gauge ICs, along with associated passive components, enabling power management, data communication, and signal processing.
- Version
- 0.4.4
- License
- unset
- Stars
- 1
scripts/render-views.mjs
import fs from 'node:fs'
import {convertCircuitJsonToPcbSvg,convertCircuitJsonToSchematicSvg} from 'circuit-to-svg'
import {Resvg} from '@resvg/resvg-js'
const json=JSON.parse(fs.readFileSync('dist/index/circuit.json','utf8'))
const pcb=convertCircuitJsonToPcbSvg(json,{width:1600,height:1050})
fs.writeFileSync('dist/index/pcb.svg',pcb)
const sheets=json.filter(e=>e.type==='schematic_sheet').sort((a,b)=>a.sheet_index-b.sheet_index)
let body=''
for(const [i,sheet] of sheets.entries()){
// Reading views omit oversized paper frames; electrical content is unchanged.
const data=json.filter(e=>e.type!=='schematic_sheet'&&(!e.schematic_sheet_id||e.schematic_sheet_id===sheet.schematic_sheet_id))
const svg=convertCircuitJsonToSchematicSvg(data,{width:1800,height:850})
fs.writeFileSync(`dist/index/${sheet.name}-schematic.svg`,svg)
body+=`<g transform="translate(0 ${i*925})"><rect width="1800" height="925" fill="#f7f4ef"/><text x="35" y="45" font-family="sans-serif" font-size="28" fill="#14595c">${sheet.display_name}</text>`+svg.replace('<svg ','<svg y="65" ')+`</g>`
}
const schematic=`<svg xmlns="http://www.w3.org/2000/svg" width="1800" height="${sheets.length*925}" viewBox="0 0 1800 ${sheets.length*925}">${body}</svg>`
fs.writeFileSync('dist/index/schematic.svg',schematic)
for(const [name,svg] of [['pcb',pcb],['schematic',schematic]])fs.writeFileSync(`dist/index/${name}.png`,new Resvg(svg,{background:'white'}).render().asPng())
console.log('Refreshed PCB and compact schematic reading views from raw JSON.')