mohan-bee/light-controller
This code defines the hardware sections and symbols for a PCB involving USB power, voltage regulation, ESP12F module, RGB outputs, I2C sensors, and debug points, along with rendering labels for test points.
- Version
- 1.0.30
- License
- unset
- Stars
- 2
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone mohan-bee/light-controller # download the package files into ./light-controller
tsci add mohan-bee/light-controller # add it to your project as @tsci/mohan-bee.light-controllerIn 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/patch-capacity-autorouter-duplicate-terminal.mjs
import { readFileSync, writeFileSync } from "node:fs"
const bundlePaths = [
"node_modules/@tscircuit/capacity-autorouter/dist/index.js",
"node_modules/tscircuit/dist/browser.min.js",
"node_modules/tscircuit/dist/webworker.min.js",
]
const duplicateTerminalThrow =
/if\(([A-Za-z_$][\w$]*)\.preserveTerminalPcbPortIds&&\1\.start\.pcb_port_id&&\1\.start\.pcb_port_id===\1\.end\.pcb_port_id\)throw new Error\(`SingleHighDensityRouteStitchSolver3 received duplicate PCB terminal "\$\{\1\.start\.pcb_port_id\}" for "\$\{\1\.connectionName\}"`\);/g
for (const bundlePath of bundlePaths) {
const original = readFileSync(bundlePath, "utf8")
let replacementCount = 0
const patched = original.replace(duplicateTerminalThrow, (match, opts) => {
replacementCount += 1
const condition = match.slice(3, match.indexOf(")throw new Error"))
return `if(${condition}){this.start=${opts}.start;this.end=${opts}.end;this.failed=!0;this.error=\`SingleHighDensityRouteStitchSolver3 received duplicate PCB terminal "\${${opts}.start.pcb_port_id}" for "\${${opts}.connectionName}"\`;return}`
})
if (replacementCount === 1) {
writeFileSync(bundlePath, patched)
console.log(`Patched duplicate-terminal stitch handling in ${bundlePath}`)
continue
}
const alreadyPatched = original.includes(
'this.failed=!0;this.error=`SingleHighDensityRouteStitchSolver3 received duplicate PCB terminal',
)
if (!alreadyPatched) {
throw new Error(
`Could not patch ${bundlePath}: expected one duplicate-terminal throw, found ${replacementCount}`,
)
}
}