Devesh36/orbit-turntable

ORBIT is a USB-C-powered display turntable for photographing jewellery, models and small products. Four-layer ESP32-C3 / ULN2003 PCB, geared stepper, OLED, push encoder, home switch and buzzer, with an enclosed and exploded assembly. Hardware prototype; firmware and physical qualification remain separate.

Version
0.1.1
License
unset
Stars
0

scripts/normalize-export.ts

import {readFileSync,writeFileSync,existsSync} from 'node:fs'
// Normalize annotation/shape descriptors to the installed Circuit JSON schema.
// Coordinates, copper dimensions and net connectivity are preserved.
for(const entry of ['index','assembly','exploded']){
 const path=`dist/${entry}/circuit.json`;if(!existsSync(path))continue
 const json=JSON.parse(readFileSync(path,'utf8'));let count=0
 for(const e of json){
  if(e.type==='pcb_component')for(const f of ['display_offset_x','display_offset_y'])if(typeof e[f]==='number'){e[f]=`${e[f]}mm`;count++}
  if(e.pcb_component_id===null){delete e.pcb_component_id;count++}
  if(e.type==='pcb_plated_hole'&&e.shape==='circular_hole_with_rect_pad'){
   e.hole_shape='circle';e.pad_shape='rect';count+=2
  }
  if(e.type==='schematic_component'&&e.port_arrangement)for(const side of ['left_side','right_side','top_side','bottom_side']){
   const row=e.port_arrangement[side];if(row?.pins)row.pins=row.pins.map((p:unknown)=>{if(typeof p==='string'&&/^pin[0-9]+$/.test(p)){count++;return Number(p.slice(3))}return p})
  }
 }
 writeFileSync(path,JSON.stringify(json,null,2));console.log(`${entry}: formatted ${count} metadata fields; electrical geometry unchanged.`)
}