gokul/fieldkit-usb

USB-C-powered ESP32-S3 Wi-Fi/Bluetooth handheld with an SMD 128x32 OLED, six navigation buttons, USB-C power/data, complete checked routing, and four native schematic sheets.

Version
0.4.2
License
UNLICENSED
Stars
0

scripts/render-artifacts.ts

import { readFile, writeFile, mkdir } from "node:fs/promises"
import { Resvg } from "@resvg/resvg-js"
import {
  convertCircuitJsonToAssemblySvg,
  convertCircuitJsonToPcbSvg,
  convertCircuitJsonToSchematicSvg,
  convertCircuitJsonToStackedSchematicSheetsSvg,
} from "circuit-to-svg"

const circuit = JSON.parse(await readFile("dist/index/circuit.json", "utf8"))
await mkdir("fabrication", { recursive: true })

const save = async (name: string, svg: string) => {
  await writeFile(`fabrication/${name}.svg`, svg)
  const png = new Resvg(svg, { fitTo: { mode: "width", value: 1800 } }).render().asPng()
  await writeFile(`fabrication/${name}.png`, png)
}

await save("pcb-top", convertCircuitJsonToPcbSvg(circuit, { layer: "top", width: 1800, height: 1200 }))
await save("pcb-bottom", convertCircuitJsonToPcbSvg(circuit, { layer: "bottom", width: 1800, height: 1200 }))
await save("assembly-top", convertCircuitJsonToAssemblySvg(circuit, { width: 1800, height: 1200 }))
await save("schematic", convertCircuitJsonToStackedSchematicSheetsSvg(circuit, { width: 1800, height: 1273 }))
for (let index = 0; index < 4; index++) {
  await save(`schematic-${String(index + 1).padStart(2, "0")}`, convertCircuitJsonToSchematicSvg(circuit, {
    schematicSheetIndex: index,
    width: 1800,
    height: 1273,
    drawPorts: true,
  }))
}