gokul/lora-device

A compact LoRa/GNSS device PCB integrating an SX1262 radio, GNSS module, USB/UART interface, 1.5 µH inductor, LiPo battery connector with NTC, and supporting passives.

Version
0.1.6
License
unset
Stars
0

validation/reproductions/internal-connections-repro.tsx.txt

import { Circuit } from '@tscircuit/core'
import { AutoroutingPipelineSolver9_PreloadedTraceGraph } from '@tscircuit/capacity-autorouter'
import type { SimpleRouteJson } from '@tscircuit/capacity-autorouter'

async function captureAndRoute(input: SimpleRouteJson) {
 await Bun.write('work/jlc-usb/internal-connections.routing-input.json',JSON.stringify(input,null,2))
 const solver = new AutoroutingPipelineSolver9_PreloadedTraceGraph(input,{effort:1})
 let complete: ((event: {traces: ReturnType<typeof solver.getOutputSimplifiedPcbTraces>}) => void) | undefined
 return {
  on(event: string, handler: typeof complete) { if(event==='complete') complete=handler },
  start() {
   for(let i=0;!solver.solved && !solver.failed && i<100000;i++) solver.step()
   if(!solver.solved) throw new Error(solver.error ?? 'Solver did not finish')
   complete?.({traces:solver.getOutputSimplifiedPcbTraces()})
  },
  stop() {},
 }
}
const circuit=new Circuit(); circuit.schematicDisabled=true
circuit.add(<board width={24} height={12} layers={2} autorouter="auto_local" routeRemaining={false}>
 <net name="SIGNAL" routingPhaseIndex={0} />
 <chip name="U1" pcbX={0} pcbY={0} pinLabels={{pin1:['IN'],pin2:['OUT']}} internallyConnectedPins={[["IN","OUT"]]} connections={{IN:'net.SIGNAL',OUT:'net.SIGNAL'}} footprint={<footprint><smtpad shape="rect" pcbX={-2} pcbY={0} width={1} height={1} portHints={['pin1']}/><smtpad shape="rect" pcbX={2} pcbY={0} width={1} height={1} portHints={['pin2']}/></footprint>}/>
 <resistor name="R1" pcbX={-7} resistance="1k" footprint="0603" connections={{pin2:'net.SIGNAL'}}/>
 <resistor name="R2" pcbX={7} resistance="1k" footprint="0603" connections={{pin1:'net.SIGNAL'}}/>
 <autoroutingphase name="Route" phaseIndex={0} autorouter="auto_local" algorithmFn={captureAndRoute}/>
</board>)
await circuit.renderUntilSettled()
const entries=circuit.getCircuitJson()
await Bun.write('work/jlc-usb/internal-connections.circuit.json',JSON.stringify(entries,null,2))
console.log(JSON.stringify(entries.filter(e=>e.type==='source_component'||e.type==='pcb_trace'||e.type.includes('error')),null,2))