astra/nema17-stepper-motor-controller-spring-clamp-rp2040

A 4-layer RP2040 controller board that negotiates USB‑C PD motor power and drives a NEMA17 stepper via a DRV8825, with current sensing, thermal shutdown, RGB status LED, buzzer alarm, optional AS5600 encoder, protection/filtering, and test points.

Version
1.4.0
License
unset
Stars
0

tests/ground-pour-selection.test.ts

import { expect, test } from "bun:test";
import { installGroundPourFinalization, selectConnectedGroundPours } from "../routing/ground-pour-selection";

const pour = (id: string, x: number) => ({
  type: "pcb_copper_pour", pcb_copper_pour_id: id, layer: "top", source_net_id: "ground",
  brep_shape: { outer_ring: {vertices: [{x,y:0},{x:x+1,y:0},{x,y:1}]}, inner_rings: [] },
});

test("only the independently audited floating copper is removed", () => {
  const connected= pour("connected",0), floating=pour("floating",3);
  const regions=[{geometry:connected,keep:true},{geometry:floating,keep:false}];
  expect(selectConnectedGroundPours([floating,connected],regions)).toEqual(["floating"]);
  expect(selectConnectedGroundPours([{...connected,pcb_copper_pour_id:"new-id"},floating],regions)).toEqual(["floating"]);
});

test("changed copper geometry, layer, net or count requires a fresh ground audit", () => {
  const original=pour("connected",0), regions=[{geometry:original,keep:true}];
  for(const changed of [pour("connected",0.01),{...original,layer:"bottom"},{...original,source_net_id:"other"}]) {
    expect(()=>selectConnectedGroundPours([changed],regions)).toThrow("Ground pour geometry changed");
  }
  expect(()=>selectConnectedGroundPours([],regions)).toThrow();
  expect(()=>selectConnectedGroundPours([original,pour("extra",3)],regions)).toThrow();
});

test("placement-only CLI renders still run normal DRC without applying a routed-pour selection", () => {
  let checked=false;
  const board={
    root:{pcbDisabled:false,pcbRoutingDisabled:true,db:{toArray(){throw new Error("Placement has no routed pours");}}},
    doInitialPcbDesignRuleChecks(){checked=true;},
  };
  installGroundPourFinalization(board);
  board.doInitialPcbDesignRuleChecks();
  expect(checked).toBe(true);
});