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-mouse

In 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/bom.ts

export {};
const groups = new Map<string, any[]>();
for (const entry of ["index", "controls"]) {
	const data = await Bun.file(`dist/${entry}/circuit.json`).json();
	for (const c of data.filter(
		(x: any) => x.type === "source_component" && x.manufacturer_part_number,
	)) {
		const a = groups.get(c.manufacturer_part_number) ?? [];
		a.push({ ...c, __data: data, __entry: entry });
		groups.set(c.manufacturer_part_number, a);
	}
}
const rows = [
	[
		"MPN",
		"Qty",
		"References",
		"Supplier part numbers",
		"Value",
		"PCB footprint bounds, mm (not body size)",
	],
];
for (const [mpn, cs] of groups) {
	const c = cs[0];
	const pcb = c.__data.find(
		(x: any) =>
			x.type === "pcb_component" &&
			x.source_component_id === c.source_component_id,
	);
	rows.push(
		[
			"Custom elastomer battery band",
			"1",
			"BATTERY_RETENTION_BAND",
			"Assembly part",
			"3mm wide loop; fit on prototype",
		],
		[
			"0.5mm compliant sensor pad",
			"2",
			"SENSOR_RETENTION_PADS",
			"Assembly part",
			"2 x 3mm; verify retention preload",
		],
		[
			mpn,
			String(cs.length),
			cs.map((x) => `${x.__entry}:${x.name}`).join(" "),
			JSON.stringify(c.supplier_part_numbers ?? {}),
			c.display_capacitance ??
				c.display_resistance ??
				(c.inductance ? `${c.inductance}H` : ""),
			pcb ? `${pcb.width.toFixed(2)} x ${pcb.height.toFixed(2)}` : "",
		],
	);
}
rows.push(
	[
		"M2x16",
		"4",
		"CONTROL_PANEL_SCREWS",
		"Mechanical hardware",
		"Clamp angled bezel and control PCB to carrier",
	],
	[
		"Custom seven-wire JST-PH cable",
		"1",
		"CONTROL_HARNESS",
		"Cable assembly",
		"1:1 mapping, seven 28AWG wires; fit length on prototype",
	],
	[
		"Adafruit 1570",
		"1",
		"BATTERY",
		"Adafruit",
		"Protected 3.7V 100mAh; 11.5x31x3.8mm",
	],
	[
		"LM18-LSI",
		"1",
		"LENS",
		"PixArt compatible lens supplier",
		"Purchased lens required; envelope only in CAD",
	],
	[
		"103AT-2",
		"1",
		"CELL_NTC",
		"Semitec",
		"10k NTC, attach to cell; wire to J_NTC",
	],
	[
		"M2x5",
		"1",
		"WHEEL_BEARING_SCREW",
		"Mechanical hardware",
		"Bearing mounting screw",
	],
	[
		"M2x12",
		"4",
		"MOUNT_SCREWS",
		"Mechanical hardware",
		"Match plastic pilot holes during fit test",
	],
);
await Bun.write(
	"BOM.csv",
	rows
		.map((r) =>
			[...r, ...Array(Math.max(0, 6 - r.length)).fill("")]
				.map((v) => '"' + v.replaceAll('"', '""') + '"')
				.join(","),
		)
		.join("\n") + "\n",
);