krishnax12/tps2553-usb-power-switch
USB‑C 5V input board with CC pull-downs feeding a TPS2553 current-limited power switch, filtered 5V output connector, external enable control, and red overcurrent/fault LED indicator.
- Version
- 1.0.0
- License
- unset
- Stars
- 0
scripts/render-previews.ts
import { Resvg } from "@resvg/resvg-js"
import type { AnyCircuitElement } from "circuit-json"
import {
convertCircuitJsonToPcbSvg,
convertCircuitJsonToSchematicSvg,
} from "circuit-to-svg"
const circuitJson: AnyCircuitElement[] = await Bun.file(
"dist/index/circuit.json",
).json()
await Bun.write(
"reports/pcb.svg",
convertCircuitJsonToPcbSvg(circuitJson, { width: 1400, height: 1400 }),
)
for (const sheet of circuitJson.filter(
(element) => element.type === "schematic_sheet",
)) {
const contentPreview = circuitJson.filter(
(element) =>
element.type !== "schematic_sheet" &&
(!element.type.startsWith("schematic_") ||
("schematic_sheet_id" in element &&
element.schematic_sheet_id === sheet.schematic_sheet_id)),
)
const svg = convertCircuitJsonToSchematicSvg(contentPreview, {
schematicSheetId: sheet.schematic_sheet_id,
width: 1400,
height: 1000,
grid: false,
})
await Bun.write(`reports/${sheet.name}.svg`, svg)
}
for (const file of new Bun.Glob("reports/*.svg").scanSync()) {
const svg = await Bun.file(file).text()
await Bun.write(
file.replace(/\.svg$/, ".png"),
new Resvg(svg).render().asPng(),
)
}