Devesh36/bench-eight
Eight-channel 0–10 V measurement and control console: dual ADS1115 ADCs, buffered inputs, Pico controller, microSD, RTC, RS-485, four protected low-voltage outputs and a separate OLED/encoder panel in a tscircuit assembly.
- Version
- 0.1.3
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone Devesh36/bench-eight # download the package files into ./bench-eight
tsci add Devesh36/bench-eight # add it to your project as @tsci/Devesh36.bench-eightIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
scripts/build-system.ts
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
import { Resvg } from "@resvg/resvg-js";
const proc = Bun.spawn(
[
"bun",
"node_modules/.bin/tsci",
"build",
"system-overview.circuit.tsx",
"--ignore-config",
"--disable-parts-engine",
"--svgs",
],
{ stdout: "inherit", stderr: "inherit" },
);
if ((await proc.exited) !== 0) process.exit(1);
const json = await Bun.file("dist/system-overview/circuit.json").json();
const pages = json.filter(
(item: { type: string }) => item.type === "system_block_page",
);
const errors = json.filter((item: { type: string }) =>
item.type.endsWith("_error"),
);
if (pages.length !== 2 || errors.length) {
throw new Error(
`Expected two valid system pages; found ${pages.length} pages and ${errors.length} errors`,
);
}
await mkdir("assets", { recursive: true });
for (const name of ["overview", "power"]) {
const source = `dist/system-overview/system-${name}.svg`;
await copyFile(source, `assets/system-${name}.svg`);
const svg = await readFile(source, "utf8");
const png = new Resvg(svg, { fitTo: { mode: "width", value: 1900 } })
.render()
.asPng();
await writeFile(`assets/system-${name}.png`, png);
}
console.log("System diagrams and README previews generated.");