shibosoftwaredev/f1c100s-linux-nema17-stepper-controller
A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.
- Version
- 0.4.56
- License
- unset
- Stars
- 0
tests/usb-top-placement.test.ts
import {test,expect} from "bun:test"
import fs from "node:fs"
const c=JSON.parse(fs.readFileSync("dist/index/circuit.json","utf8")) as any[]
const source=(name:string)=>c.find(e=>e.type==="source_component"&&e.name===name)
const placed=(name:string)=>c.find(e=>e.type==="pcb_component"&&e.source_component_id===source(name).source_component_id)
test("unchanged USB-C types share the north edge and top assembly face",()=>{
const a=placed("J_USB_DATA"),b=placed("J_USB_PWR")
expect([a.layer,b.layer]).toEqual(["top","top"])
expect([a.center.x,b.center.x]).toEqual([-7,7])
expect(a.center.y).toBeCloseTo(b.center.y,8)
expect([a.rotation,b.rotation]).toEqual([180,180])
for(const n of ["J_USB_DATA","J_USB_PWR"]){
expect(source(n).manufacturer_part_number).toBe("TYPE-C-31-M-12")
expect(source(n).supplier_part_numbers.jlcpcb).toEqual(["C165948"])
const p=placed(n)
expect(c.filter(e=>e.type==="pcb_smtpad"&&e.pcb_component_id===p.pcb_component_id).every(e=>e.layer==="top")).toBe(true)
}
})
test("both USB housings render above the top surface without a bottom flip",()=>{
for(const n of ["J_USB_DATA","J_USB_PWR"]){
const model=c.find(e=>e.type==="cad_component"&&e.source_component_id===source(n).source_component_id)
expect(model.position.z).toBeCloseTo(.8,8)
expect(model.rotation.y).toBe(0)
expect(model.model_obj_url).toContain("C165948")
}
})
test("same motor-sized four-layer outline and four screw centers are retained",()=>{
const b=c.find(e=>e.type==="pcb_board")
expect([b.width,b.height,b.num_layers,b.thickness]).toEqual([42.3,42.3,4,1.6])
expect(["MH1","MH2","MH3","MH4"].map(n=>placed(n).center)).toEqual([
{x:-15.5,y:-15.5},{x:-15.5,y:15.5},{x:15.5,y:-15.5},{x:15.5,y:15.5}
])
})
test("seven underside passives retain the reviewed local positions",()=>{
const expected:Record<string,[number,number]>={C_D67:[6.5,14],C_D71:[5.4,14],C_D73:[4.3,12.4],C_VRA1:[1.2,12.3],R_VRA1:[4.3,16.45],C_TV_VRP:[8.8,17.9],C_B_VCC_USB:[9.4,15.95]}
for(const [n,[x,y]] of Object.entries(expected)){
const p=placed(n)
expect(p.layer).toBe("bottom")
expect(p.center.x).toBeCloseTo(x,8);expect(p.center.y).toBeCloseTo(y,8)
const paste=c.filter(e=>e.type==="pcb_solder_paste"&&e.pcb_component_id===p.pcb_component_id)
expect(paste.length).toBe(2)
expect(paste.every(e=>e.layer==="bottom")).toBe(true)
}
})