MustafaMulla29/rp2040-bldc-motor-controller
Hardware assembly metadata and PCB geometry for a controller board with a snap-off rotary-encoder section, plus four parallel 150 µF/50 V bulk electrolytic capacitors filtering the motor supply.
- Version
- 2.0.40
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone MustafaMulla29/rp2040-bldc-motor-controller # download the package files into ./rp2040-bldc-motor-controller
tsci add MustafaMulla29/rp2040-bldc-motor-controller # add it to your project as @tsci/MustafaMulla29.rp2040-bldc-motor-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.
circuit/saved-routing.ts
import plan from "./route-plan.json"
/** The saved result is valid only for this exact routing input. Core still
* regenerates copper and runs its normal DRC on every build. */
export function canonicalRoutingInput(value: unknown): string {
const normalize = (item: any, key?: string): any => {
if (typeof item === "number") return Math.round(item * 1e8) / 1e8
if (Array.isArray(item)) {
if (key === "connectedTo" && item.every(id => typeof id === "string")) return [...new Set(item)].sort()
return item.map(value => normalize(value))
}
if (item && typeof item === "object") return Object.fromEntries(
Object.keys(item).sort().map(key => [key, normalize(item[key], key)]))
return item
}
return JSON.stringify(normalize(value))
}
const expected = canonicalRoutingInput(plan.expectedInput)
export const savedRouting = async (input: unknown) => {
if (!plan.traces.length) throw new Error("No saved routing exists. Generate and validate the routing plan first.")
if (canonicalRoutingInput(input) !== expected) throw new Error(
"PCB geometry, connections or routing rules changed. Regenerate and validate circuit/route-plan.json; do not replace expectedInput alone.")
const listeners = new Map<string, Array<(event: any) => void>>()
return {
on(name: string, callback: (event: any) => void) { listeners.set(name, [...listeners.get(name) ?? [], callback]) },
start() { for (const callback of listeners.get("complete") ?? []) callback({ traces: structuredClone(plan.traces) }) },
stop() {},
}
}