ShiboSoftwareDev/mspm0g3507-usb-c-dev-board

The circuit assembles a USB-C port with integrated ESD protection, power regulation, UART interface, and microcontroller (MSPM0G3507) with supporting components for USB data lines, CC termination, I2C, SPI, reset circuitry, and indicator LEDs.

Version
1.4.1
License
unset
Stars
0

scripts/export-schematic.mjs

import { readFile, writeFile } from "node:fs/promises"
import {
  convertCircuitJsonToAssemblySvg,
  convertCircuitJsonToPcbSvg,
  convertCircuitJsonToSchematicSvg,
} from "circuit-to-svg"

const circuitJsonPath = new URL("../dist/index/circuit.json", import.meta.url)
const schematicSvgPath = new URL(
  "../outputs/MSPM0G3507_USB_C_Schematic.svg",
  import.meta.url,
)
const pcbSvgPath = new URL(
  "../outputs/MSPM0G3507_USB_C_PCB.svg",
  import.meta.url,
)
const assemblySvgPath = new URL(
  "../outputs/MSPM0G3507_USB_C_Assembly.svg",
  import.meta.url,
)

const circuitJson = JSON.parse(await readFile(circuitJsonPath, "utf8"))
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson, {
  width: 1600,
  height: 1000,
  includeVersion: true,
  showErrorsInTextOverlay: true,
})

await writeFile(schematicSvgPath, schematicSvg)
await writeFile(
  pcbSvgPath,
  convertCircuitJsonToPcbSvg(circuitJson, {
    width: 1600,
    height: 700,
    matchBoardAspectRatio: true,
    includeVersion: true,
    shouldDrawErrors: true,
    shouldDrawWarnings: true,
    showErrorsInTextOverlay: true,
    showSolderMask: true,
  }),
)
const assemblySvg = convertCircuitJsonToAssemblySvg(circuitJson, {
    width: 1600,
    height: 700,
    includeVersion: true,
    showErrorsInTextOverlay: true,
  })
  .replace(/<[^>]*(?:NaN|undefined)[^>]*\/>/g, "")
  .replace(/font-size="([\d.]+)px"/g, (_, size) =>
    `font-size="${Math.min(Number(size), 12).toFixed(1)}px"`)

await writeFile(assemblySvgPath, assemblySvg)
console.log(`Exported ${schematicSvgPath.pathname}`)
console.log(`Exported ${pcbSvgPath.pathname}`)
console.log(`Exported ${assemblySvgPath.pathname}`)