astra/f1c100s
The code defines the physical pin layout, labels, and footprint for the F1C100S system-on-chip (SoC) component used in electronic devices.
- Version
- 0.9.2
- License
- unset
- Stars
- 0
scripts/render.tsx
import {
Circuit,
type GenericLocalAutorouter,
type SimpleRouteJson,
type SimplifiedPcbTrace,
} from "tscircuit";
import { UnroutedModule } from "../src/UnroutedModule";
import { MODULE_SIZE, type LayoutProfile } from "../src/profiles";
export async function renderProfile(
profile: LayoutProfile,
traces?: SimplifiedPcbTrace[],
) {
const factory = async (
input: SimpleRouteJson,
): Promise<GenericLocalAutorouter> => {
const handlers: Record<string, ((e: any) => void)[]> = {
complete: [],
error: [],
progress: [],
};
const router: GenericLocalAutorouter = {
input,
isRouting: false,
on(e: string, f: (e: any) => void) {
handlers[e]!.push(f);
},
start() {
router.isRouting = true;
queueMicrotask(() => {
if (!router.isRouting) return;
router.isRouting = false;
handlers.complete!.forEach((f) => f({ type: "complete", traces }));
});
},
stop() {
router.isRouting = false;
},
solveSync() {
return traces ?? [];
},
};
return router;
};
const c = new Circuit();
c.add(
<board
width={MODULE_SIZE}
height={MODULE_SIZE}
layers={4}
routingDisabled={!traces}
minTraceWidth={0.12}
minViaPadDiameter={0.45}
minViaHoleDiameter={0.2}
pcbStyle={{ viaPadDiameter: 0.45, viaHoleDiameter: 0.2 }}
autorouter={traces ? { local: true, algorithmFn: factory } : undefined}
>
<UnroutedModule layoutProfile={profile} />
</board>,
);
await c.renderUntilSettled();
const seen = new Map<string, string>();
const json = c.getCircuitJson().filter((e: any) => {
if (e.type !== "pcb_via") return true;
const k = `${e.x.toFixed(5)}:${e.y.toFixed(5)}`;
const net = e.subcircuit_connectivity_map_key;
if (seen.has(k)) {
if (seen.get(k) !== net) throw new Error(`Different-net vias at ${k}`);
return false;
}
seen.set(k, net);
return true;
});
return { circuit: c, json };
}