Devesh36/clear-mouse
A transparent, right-handed wireless mouse assembly with a 44×58 mm control PCB, LiPo battery, optical sensor, click buttons, scroll encoder, DPI/middle buttons, USB‑C charging, and 3D‑printed housing/mechanical hardware.
- Version
- 0.1.5
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone Devesh36/clear-mouse # download the package files into ./clear-mouse
tsci add Devesh36/clear-mouse # add it to your project as @tsci/Devesh36.clear-mouseIn 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/check.ts
export {};
let failed = false;
// A thin route segment entirely inside an existing convex pad does not narrow
// the manufactured copper. Audit exposed segments against the board minimum.
function inside(p: any, pad: any) {
const e = 0.00001;
if (pad.shape === "rect")
return (
Math.abs(p.x - pad.x) <= pad.width / 2 + e &&
Math.abs(p.y - pad.y) <= pad.height / 2 + e
);
if (pad.shape !== "polygon") return false;
const q = pad.points;
let pos = false,
neg = false;
for (let i = 0; i < q.length; i++) {
const a = q[i],
b = q[(i + 1) % q.length];
const c = (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x);
if (c > e) pos = true;
if (c < -e) neg = true;
}
return !(pos && neg);
}
for (const board of ["index", "controls"]) {
for (const kind of [
"netlist",
"pin_specification",
"schematic-placement",
"placement",
"shorts",
"pcb-style",
]) {
const file = ["netlist", "pin_specification"].includes(kind)
? `${board}.circuit.tsx`
: `dist/${board}/circuit.json`;
console.log(`Checking ${board}: ${kind}`);
const p = Bun.spawn(
["bun", "node_modules/.bin/tsci", "check", kind, file],
{
stdout: "inherit",
stderr: "inherit",
},
);
if ((await p.exited) !== 0) failed = true;
}
}
for (const entry of ["index", "controls", "assembly", "exploded"]) {
const file = Bun.file(`dist/${entry}/circuit.json`);
if (!(await file.exists())) {
console.error(`${entry}: missing build`);
failed = true;
continue;
}
const data = await file.json();
const errors = data.filter((x: any) => x.type.endsWith("_error"));
const warnings = data.filter((x: any) => x.type.endsWith("_warning"));
const b = data.find((x: any) => x.type === "pcb_board");
const pads = data.filter((x: any) => x.type === "pcb_smtpad");
const narrow = data.filter(
(x: any) =>
x.type === "pcb_trace" &&
x.route.some((p: any, i: number) => {
const q = x.route[i + 1];
if (
p.route_type !== "wire" ||
!q ||
q.route_type !== "wire" ||
p.layer !== q.layer ||
p.width >= b.min_trace_width - 1e-6
)
return false;
return !pads.some(
(pad: any) =>
pad.layer === p.layer && inside(p, pad) && inside(q, pad),
);
}),
);
console.log(
`${entry}: ${errors.length} errors, ${warnings.length} warnings, ${narrow.length} traces with exposed copper below board minimum`,
);
if (errors.length || narrow.length) failed = true;
}
process.exit(failed ? 1 : 0);