gokul/acoustic-guitar-tuner
This code defines the physical pin configuration and footprint layouts for the ATtiny1616 microcontroller and a matching tactile switch component, including their key hardware connection points, dimensions, and 3D models.
- Version
- 1.0.10
- License
- unset
- Stars
- 1
local-router.ts
import { AutoroutingPipelineSolver9_PreloadedTraceGraph } from "@tscircuit/capacity-autorouter"
import type { SimpleRouteJson } from "@tscircuit/props"
import savedInput from "./routing-cache/input.json"
import savedTraces from "./routing-cache/traces.json"
// Route with extra edge margin; the board's independent DRC remains at 0.3 mm.
// This adapter runs the standard tscircuit solver locally, without a cloud job.
export async function createLocalRouter(input: SimpleRouteJson) {
// Reuse only an exact input match. Any placement/net/rule edit reroutes locally.
if (JSON.stringify(input) === JSON.stringify(savedInput)) {
const callbacks: Array<(event: any) => void> = []
return {
on: (event: string, callback: (event: any) => void) => { if (event === "complete") callbacks.push(callback) },
start: () => { for (const callback of callbacks) callback({traces: savedTraces}) },
stop: () => {},
}
}
const solver = new AutoroutingPipelineSolver9_PreloadedTraceGraph({
...input,
minBoardEdgeClearance: 0.6,
})
const listeners: Record<string, Array<(event: any) => void>> = {}
let running = false
const emit = (type: string, data: object) => {
for (const listener of listeners[type] ?? []) listener({ type, ...data })
}
const cycle = async () => {
if (!running) return
try {
const started = Date.now()
while (!solver.solved && !solver.failed && Date.now() - started < 100) {
solver.step()
}
if (solver.failed) throw new Error(solver.error ?? "Local routing failed")
if (solver.solved) {
running = false
emit("complete", { traces: solver.getOutputSimplifiedPcbTraces() })
} else {
emit("progress", { progress: solver.progress, phase: solver.getCurrentPhase() })
setTimeout(cycle, 0)
}
} catch (error) {
running = false
emit("error", { error: error instanceof Error ? error : new Error(String(error)) })
}
}
return {
on: (event: string, callback: (event: any) => void) => {
(listeners[event] ??= []).push(callback)
},
start: () => { if (!running) { running = true; void cycle() } },
stop: () => { running = false },
}
}