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/export-review.mjs

import fs from 'node:fs'
const j=JSON.parse(fs.readFileSync('dist/index/circuit.json','utf8'))
const quote=v=>'"'+String(v??'').replaceAll('"','""')+'"'
const csv=rows=>rows.map(r=>r.map(quote).join(',')).join('\n')+'\n'
const val=s=>s.resistance!==undefined?s.resistance+' ohm':s.capacitance!==undefined?s.capacitance+' F':s.inductance!==undefined?s.inductance+' H':s.manufacturer_part_number||s.ftype
const sources=j.filter(e=>e.type==='source_component')
const byId=new Map(sources.map(s=>[s.source_component_id,s]))
const pcb=j.filter(e=>e.type==='pcb_component')
const bom=[['Reference','Value or part','Manufacturer part number','Supplier candidates','Populate','Notes']]
const pnp=[['Designator','Mid X (mm)','Mid Y (mm)','Layer','Rotation (deg)','Status']]
for(const p of pcb){const s=byId.get(p.source_component_id);if(!s)continue;const tp=s.name.startsWith('TP');const dnp=p.do_not_place||s.do_not_place;const status=tp?'COPPER ONLY':dnp?'DNP':'POPULATE';bom.push([s.name,val(s),s.manufacturer_part_number,JSON.stringify(s.supplier_part_numbers||{}),status,'Review footprint, ratings, sourcing and orientation']);if(!tp&&!dnp)pnp.push([s.name,p.center.x.toFixed(4),p.center.y.toFixed(4),p.layer,p.rotation,status])}
fs.writeFileSync('bom.csv',csv(bom));fs.writeFileSync('pick-and-place.csv',csv(pnp))
console.log('Wrote review BOM and populated-part placement CSV. Coordinates use board center as origin; rotations are native PCB rotations, not supplier-corrected.')