shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

scripts/render-schematic-sheets.mjs

import fs from "node:fs"
import path from "node:path"
import { Resvg } from "@resvg/resvg-js"
import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg"

const circuitPath = process.argv[2] ?? "dist/index/circuit.json"
const outputDir = process.argv[3] ?? "reports/schematic-sheets"
const circuit = JSON.parse(fs.readFileSync(circuitPath, "utf8"))
const selectedSheets = new Set(process.argv.slice(4))
const sheets = circuit
  .filter((element) => element.type === "schematic_sheet" && (!selectedSheets.size || selectedSheets.has(element.name)))
  .sort((a, b) => a.sheet_index - b.sheet_index)

fs.mkdirSync(outputDir, { recursive: true })
for (const sheet of sheets) {
  const basename = `${String(sheet.sheet_index).padStart(2, "0")}-${sheet.name}`
  const svg = convertCircuitJsonToSchematicSvg(circuit, {
    width: 2400,
    height: 1600,
    schematicSheetIndex: sheet.sheet_index,
    showErrorsInTextOverlay: true,
  })
  fs.writeFileSync(path.join(outputDir, `${basename}.svg`), svg)
  const png = new Resvg(svg, { fitTo: { mode: "width", value: 2400 } })
    .render()
    .asPng()
  fs.writeFileSync(path.join(outputDir, `${basename}.png`), png)
}

const outside = circuit.filter((element) =>
  element.type === "schematic_element_outside_sheet_warning"
)
console.log(JSON.stringify({
  sheets: sheets.map(({ name, display_name, sheet_index }) => ({
    name,
    displayName: display_name,
    sheetIndex: sheet_index,
  })),
  outsideSheetWarnings: outside.length,
}, null, 2))