imrishabh18/rp2040-motor-controller
An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.
- Version
- 1.0.42
- License
- unset
- Stars
- 3
tests/outer-motor-power.test.tsx
import {expect, test} from "bun:test";
import {readFileSync} from "node:fs";
import {Circuit} from "tscircuit";
import Board from "../index.circuit";
import {assertOuterMotorPower} from "./helpers/assertOuterMotorPower";
test("motor supply, winding and regulation-return copper stays on outer layers", async () => {
let json;
if (process.env.CIRCUIT_JSON_PATH) json=JSON.parse(readFileSync(process.env.CIRCUIT_JSON_PATH,"utf8"));
else {const c=new Circuit();c.add(<Board/>);await c.renderUntilSettled();json=c.getCircuitJson();}
const result=assertOuterMotorPower(json);
expect(result.status).toBe("pass");
const bad=structuredClone(json);
const t=bad.find((e:any)=>e.type==="pcb_trace" && e.pcb_trace_id===result.checkedTraceIds[0]);
t.route.find((p:any)=>p.route_type==="wire").layer="inner1";
expect(()=>assertOuterMotorPower(bad)).toThrow("Motor-current copper on inner layer");
},600000);
