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.

index.circuit.tsx

PCBPCB preview for index.circuit.tsx
SchematicSchematic preview for index.circuit.tsx
import { SMF5_0A as UsbTvs } from "./imports/SMF5_0A";
import { PZ127_1_06_Z as ProgrammingHeader } from "./imports/PZ127_1_06_Z";
import { ControlConnector, controlConnections } from "./control-connector";
import { compactOutline } from "./layout";
import { Fragment } from "react";
import type { BoardProps } from "@tscircuit/props";
import {
	Mcu,
	Sensor,
	Charger,
	Regulator,
	SensorLdo,
	Click,
	Encoder,
	PowerSwitch,
	BatteryConnector,
	Button,
	GreenLed,
	RedLed,
	Sheets,
	S,
	R,
	C,
} from "./parts";
export default function ClearMouse(props: BoardProps) {
	return (
		<board
			name="CLEAR_MOUSE"
			width={50}
			height={90}
			outline={compactOutline}
			borderRadius={8}
			thickness={1.6}
			layers={2}
			solderMaskColor="black"
			autorouter="auto_local"
			minTraceWidth={0.15}
			minTraceToPadEdgeClearance={0.127}
			minPadEdgeToPadEdgeClearance={0.15}
			minViaEdgeToPadEdgeClearance={0.2}
			minTraceToHoleEdgeClearance={0.25}
			minBoardEdgeClearance={0.25}
			minViaHoleDiameter={0.3}
			minViaPadDiameter={0.6}
			schTraceAutoLabelEnabled
			{...props}
		>
			<Sheets />
			<copperpour
				connectsTo="net.GND"
				layer="bottom"
				clearance={0.2}
				boardEdgeMargin={0.3}
				cutoutMargin={0.3}
			/>
			{["VBUS", "USB5V", "VBAT", "VSYS", "V3V0", "V1V9"].map((n) => (
				<Fragment key={n}>
					<net
						name={n}
						isPowerNet
						nominalTraceWidth={n === "V1V9" ? 0.35 : 0.5}
					/>
				</Fragment>
			))}
			<net name="GND" isGroundNet nominalTraceWidth={0.35} />
			{["SENSOR_CP", "SENSOR_CN", "SENSOR_VCP"].map((n) => (
				<Fragment key={n}>
					<net name={n} nominalTraceWidth={0.55} />
				</Fragment>
			))}
			{[
				[-22, 41],
				[22, 41],
				[-22, -26],
				[22, -26],
			].map(([x, y], i) => (
				<Fragment key={i}>
					<hole name={`H${i + 1}`} pcbX={x} pcbY={y} diameter={2.4} />
				</Fragment>
			))}
			{/* Routing buffers around mechanical openings; copper must clear the milled edge. */}
			<keepout
				shape="rect"
				pcbX={-0.9989452}
				pcbY={0}
				width={17.56}
				height={9.2}
				layers={["top", "bottom"]}
				excludeRefs={[".U_SENSOR"]}
			/>
			<keepout
				shape="rect"
				pcbX={0}
				pcbY={-35.86}
				width={50}
				height={10.28}
				layers={["top", "bottom"]}
				excludeRefs={[".U_MCU"]}
			/>
			<connector
				name="J_USB"
				standard="usb_c"
				schWidth={1.771}
				manufacturerPartNumber="TYPE-C-31-M-12"
				supplierPartNumbers={{ jlcpcb: ["C165948"] }}
				pcbX={0}
				pcbY={45.25}
				pcbRotation={180}
				{...S("POWER", -16, 10)}
				noConnect={["DP1", "DP2", "DM1", "DM2", "SBU1", "SBU2"]}
				connections={{
					VBUS1: "net.VBUS",
					VBUS2: "net.VBUS",
					GND1: "net.GND",
					GND2: "net.GND",
					SHELL1: "net.GND",
					SHELL2: "net.GND",
					SHELL3: "net.GND",
					SHELL4: "net.GND",
					CC1: "net.CC1",
					CC2: "net.CC2",
				}}
			/>
			<R
				name="R_CC1"
				rot={180}
				x={-10}
				y={45}
				s="POWER"
				sx={-16}
				sy={3}
				a="CC1"
				v="5.1k"
			/>
			<R
				name="R_CC2"
				x={10}
				y={45}
				s="POWER"
				sx={-11}
				sy={3}
				a="CC2"
				v="5.1k"
			/>
			<fuse
				name="F_USB"
				currentRating="500mA"
				footprint="1206"
				manufacturerPartNumber="1206L050YR"
				pcbX={-9}
				pcbY={42}
				{...S("POWER", -8, 10)}
				connections={{ pin1: "net.VBUS", pin2: "net.USB5V" }}
			/>
			<UsbTvs
				name="D_USB"
				schRotation={-90}
				pcbX={-15}
				pcbY={43}
				{...S("POWER", -3, 5)}
				connections={{ pin2: "net.GND", pin1: "net.USB5V" }}
			/>
			<Charger
				name="U_CHARGE"
				pcbX={-17}
				pcbY={20}
				{...S("POWER", 0, 10)}
				noConnect={["TMR", "ITERM"]}
				connections={{
					IN: "net.USB5V",
					OUT1: "net.VSYS",
					OUT2: "net.VSYS",
					BAT1: "net.VBAT",
					BAT2: "net.VBAT",
					VSS: "net.GND",
					EP: "net.GND",
					N_CE: "net.GND",
					EN1: "net.USB5V",
					EN2: "net.GND",
					ILIM: "net.ILIM",
					ISET: "net.ISET",
					TS: "net.BAT_TS",
					N_CHG: "net.CHARGING",
					N_PGOOD: "net.POWER_GOOD",
				}}
			/>
			<R
				name="R_ISET"
				x={-21}
				y={17}
				s="POWER"
				sx={5}
				sy={10}
				a="ISET"
				v="17.8k"
			/>
			<R
				name="R_ILIM"
				x={-13}
				y={17}
				s="POWER"
				sx={2}
				sy={-3}
				a="ILIM"
				v="4.42k"
			/>
			<C
				name="C_USB"
				direct
				maxLen={3}
				x={-16.25}
				y={24.3}
				s="POWER"
				sx={-7}
				sy={16}
				a="USB5V"
				v="10uF"
				rot={90}
			/>
			<C
				name="C_BAT"
				x={-21.3}
				y={20}
				s="POWER"
				sx={10}
				sy={15}
				a="VBAT"
				v="10uF"
				rot={180}
			/>
			<C
				name="C_SYS"
				x={-12.7}
				y={20}
				s="POWER"
				sx={15}
				sy={15}
				a="VSYS"
				v="10uF"
				rot={0}
			/>
			<BatteryConnector
				name="J_BAT"
				pcbX={15}
				pcbY={21.175}
				pcbRotation={0}
				{...S("POWER", 12, 8)}
				noConnect={["pin3", "pin4"]}
				connections={{ pin1: "net.VBAT", pin2: "net.GND" }}
			/>
			<connector
				name="J_NTC"
				schPinArrangement={{
					topSide: { pins: ["pin1"], direction: "left-to-right" },
					bottomSide: { pins: ["pin2"], direction: "left-to-right" },
				}}
				footprint="pinrow2_p2.54mm_id1mm_od1.8mm"
				manufacturerPartNumber="TSW-102-07-G-S"
				pcbX={20}
				pcbY={8}
				{...S("POWER", 12, 0)}
				connections={{ pin1: "net.BAT_TS", pin2: "net.GND" }}
			/>
			<R
				name="R_PGOOD"
				x={-23}
				y={12}
				s="POWER"
				sx={-6}
				sy={14}
				a="USB5V"
				b="POWER_GOOD"
				v="100k"
			/>
			<R
				name="R_CHG"
				x={-19}
				y={12}
				s="POWER"
				sx={-7}
				sy={-1}
				a="USB5V"
				b="CHARGING"
				v="100k"
			/>
			<Regulator
				name="U_REG"
				pcbX={-17}
				pcbY={-15}
				{...S("RAILS", 0, 8)}
				noConnect={["NC"]}
				connections={{
					IN: "net.VSYS",
					OUT: "net.V3V0",
					GND: "net.GND",
					EN: "net.EN_REG",
				}}
				pcbRotation={180}
			/>

			<C
				name="C_REG_IN"
				direct
				maxLen={3}
				x={-20.9}
				y={-14.05}
				s="RAILS"
				sx={-8}
				sy={13}
				a="VSYS"
				v="10uF"
				rot={180}
			/>

			<C
				name="C_REG_OUT1"
				direct
				maxLen={3}
				x={-13.1}
				y={-14.05}
				s="RAILS"
				sx={8}
				sy={13}
				a="V3V0"
				v="10uF"
				rot={0}
			/>

			<PowerSwitch
				name="SW_POWER"
				pcbX={-21}
				pcbY={-5}
				layer="bottom"
				pcbRotation={90}
				{...S("RAILS", -10, 3)}
				connections={{
					pin1: "net.VSYS",
					pin2: "net.EN_REG",
					pin3: "net.GND",
					pin4: "net.GND",
				}}
			/>
			<R
				name="R_EN_REG"
				x={-23}
				y={-10}
				s="RAILS"
				sx={-9}
				sy={-3}
				a="EN_REG"
				v="100k"
			/>
			<SensorLdo
				name="U_SENSOR_LDO"
				pcbX={16}
				pcbY={3}
				{...S("RAILS", 0, -13)}
				noConnect={["NC"]}
				connections={{
					IN: "net.V3V0",
					EN: "net.V3V0",
					GND: "net.GND",
					OUT: "net.V1V9",
				}}
			/>
			<C
				name="C_LDO_IN"
				direct
				maxLen={3}
				x={19.7}
				y={2.05}
				s="RAILS"
				sx={-6}
				sy={-18}
				a="V3V0"
				v="1uF"
				rot={0}
			/>
			<C
				name="C_LDO_OUT"
				direct
				maxLen={3}
				x={12.3}
				y={2.05}
				s="RAILS"
				sx={6}
				sy={-18}
				a="V1V9"
				v="1uF"
				rot={180}
			/>
			<Mcu
				name="U_MCU"
				pcbX={0}
				pcbY={-28}
				pcbRotation={180}
				{...S("MCU", 0, 0)}
				schHeight={3.2}
				schWidth={2.2}
				noConnect={[
					"P0_09",
					"P0_10",
					"P0_01",
					"P0_00",
					"P0_03",
					"P0_11",
					"DCC",
				]}
				connections={{
					GND1: "net.GND",
					GND2: "net.GND",
					GND3: "net.GND",
					GND4: "net.GND",
					VDD: "net.V3V0",
					DEC4: "net.MCU_DEC4",
					RESET: "net.RESET",
					SWDCLK: "net.SWD_CLK",
					SWDIO: "net.SWD_IO",
					P0_20: "net.SDIO",
					P0_16: "net.SENSOR_CLK",
					P0_15: "net.SENSOR_CS",
					P0_14: "net.MOTION",
					P0_12: "net.LEFT",
					P0_08: "net.RIGHT",
					P0_06: "net.ENC_A",
					P0_04: "net.SYS_ADC",
					P0_30: "net.ENC_B",
					P0_29: "net.PAIR",
					P0_28: "net.MIDDLE",
					P0_25: "net.DPI",
					P0_02: "net.STATUS",
				}}
			/>
			<C
				name="C_DEC4"
				x={-5}
				y={-26.625}
				rot={180}
				s="MCU"
				sx={7}
				sy={8}
				a="MCU_DEC4"
				v="1uF"
			/>

			<C
				name="C_MCU1"
				x={-7}
				y={-23}
				s="MCU"
				sx={-10}
				sy={10}
				a="V3V0"
				v="10uF"
			/>
			<C
				name="C_MCU2"
				x={-4.3}
				y={-23.5}
				rot={180}
				s="MCU"
				sx={-7.1}
				sy={10}
				a="V3V0"
			/>
			<R
				name="R_RESET"
				x={8}
				y={-25}
				s="MCU"
				sx={-12}
				sy={3}
				a="V3V0"
				b="RESET"
			/>
			<C
				name="C_RESET"
				x={8}
				y={-28}
				s="MCU"
				sx={-12}
				sy={-2}
				a="RESET"
				v="100nF"
				rot={180}
			/>
			<ProgrammingHeader
				name="J_SWD"
				pcbX={-15}
				pcbY={-20}
				{...S("MCU", 14, 2)}
				connections={{
					pin1: "net.GND",
					pin2: "net.V3V0",
					pin3: "net.SWD_IO",
					pin4: "net.SWD_CLK",
					pin5: "net.RESET",
					pin6: "net.PAIR",
				}}
			/>
			<R
				name="R_PAIR"
				x={-8}
				y={-18}
				s="MCU"
				sx={-10}
				sy={0}
				a="V3V0"
				b="PAIR"
				rot={180}
			/>
			<R
				name="R_BAT_TOP"
				x={12}
				y={-23}
				s="MCU"
				sx={8}
				sy={-1}
				a="EN_REG"
				b="SYS_ADC"
				v="220k"
			/>
			<R
				name="R_BAT_LOW"
				x={14}
				y={-27}
				s="MCU"
				sx={8}
				sy={-6}
				a="SYS_ADC"
				v="100k"
			/>
			<C name="C_ADC" x={18} y={-25} s="MCU" sx={12} sy={-6} a="SYS_ADC" />
			<Sensor
				name="U_SENSOR"
				pcbX={0}
				pcbY={0}
				{...S("OPTICS", 0, 0)}
				schHeight={1.8}
				schWidth={2.4}
				noConnect={["NC"]}
				connections={{
					VDD: "net.V1V9",
					VDDIO: "net.V3V0",
					GND: "net.GND",
					SDIO: "net.SDIO",
					SCLK: "net.SENSOR_CLK",
					NCS: "net.SENSOR_CS",
					NRESET: "net.RESET",
					MOTION: "net.MOTION",
					CP: "net.SENSOR_CP",
					CN: "net.SENSOR_CN",
					VCP: "net.SENSOR_VCP",
					PASS_T: "net.LASER_POS",
					VCSEL_POS: "net.LASER_POS",
					VCSEL_NEG: "net.LASER_NEG",
					XYLASER: "net.LASER_NEG",
				}}
			/>
			<C
				name="C_VCP"
				direct
				maxLen={5}
				x={4.5}
				y={8}
				s="OPTICS"
				sx={10}
				sy={-8}
				a="SENSOR_VCP"
				v="10uF"
				rot={90}
			/>
			<C
				name="C_VCP_HF"
				direct
				maxLen={5}
				x={7}
				y={8}
				s="OPTICS"
				sx={12.9}
				sy={-8}
				a="SENSOR_VCP"
				v="10nF"
				rot={90}
			/>
			<C
				name="C_CP"
				x={0.4}
				y={8}
				s="OPTICS"
				sx={10}
				sy={0}
				a="SENSOR_CP"
				b="SENSOR_CN"
				rot={180}
			/>
			<C
				name="C_LASER"
				x={-6.7}
				y={8}
				s="OPTICS"
				sx={10}
				sy={7}
				a="LASER_POS"
				v="10nF"
				rot={90}
			/>
			<C
				name="C_SENSOR_BULK"
				x={-5}
				y={11}
				s="OPTICS"
				sx={-10}
				sy={9}
				a="V1V9"
				v="3.3uF"
			/>
			<C
				name="C_SENSOR"
				direct
				maxLen={3}
				x={-2.2491192}
				y={8}
				s="OPTICS"
				sx={-13.5}
				sy={9}
				a="V1V9"
				rot={90}
			/>
			<C
				name="C_SENSOR_IO"
				direct
				maxLen={3}
				x={2.2009608}
				y={-8}
				s="OPTICS"
				sx={-10}
				sy={-8}
				a="V3V0"
				rot={270}
			/>
			<R
				name="R_CS"
				x={0}
				y={-11}
				s="OPTICS"
				sx={-15}
				sy={-8}
				a="V3V0"
				b="SENSOR_CS"
			/>
			<ControlConnector
				name="J_CONTROL"
				pcbX={0}
				pcbY={30}
				{...S("INPUTS", -8, 3)}
				noConnect={["pin8", "pin9"]}
				connections={controlConnections}
			/>
			<Button
				name="SW_PAIR"
				schRotation={-90}
				pcbX={18}
				pcbY={-29}
				layer="bottom"
				{...S("INPUTS", 0, -11)}
				connections={{ pin1: "net.PAIR", pin2: "net.GND" }}
			/>
			{[
				["LEFT", -6, 22, -18, 9],
				["RIGHT", -3, 22, -18, 3],
				["ENC_A", 0, 22, 8, 12],
				["ENC_B", 3, 22, 8, 7],
				["MIDDLE", 6, 22, 8, 1],
				["DPI", 9, 22, 8, -5],
			].map(([n, x, y, sx, sy]) => (
				<R
					key={n}
					name={`R_${n}`}
					x={Number(x)}
					y={Number(y)}
					s="INPUTS"
					sx={Number(sx)}
					sy={Number(sy)}
					a="V3V0"
					b={String(n)}
					rot={n === "ENC_B" ? 180 : 0}
				/>
			))}
			<R
				name="R_LED"
				x={22}
				y={20}
				s="INPUTS"
				sx={21}
				sy={8}
				a="STATUS"
				b="LED_A"
				v="1k"
			/>
			<GreenLed
				name="LED_STATUS"
				schRotation={-90}
				pcbX={22}
				pcbY={23}
				{...S("INPUTS", 21, 3)}
				connections={{ pin2: "net.LED_A", pin1: "net.GND" }}
			/>
			<R
				name="R_CHARGE_LED"
				x={-23}
				y={26}
				s="POWER"
				sx={-15}
				sy={-3}
				a="USB5V"
				b="CHG_LED_A"
				v="1k"
			/>
			<RedLed
				name="LED_CHARGE"
				schRotation={-90}
				pcbX={-23}
				pcbY={28}
				{...S("POWER", -15, -8)}
				connections={{ pin2: "net.CHG_LED_A", pin1: "net.CHARGING" }}
			/>
			<silkscreentext
				text="SWD 1:GND"
				pcbX={-15}
				pcbY={-17.5}
				fontSize={0.65}
			/>
			{/* Local return vias keep decoupling loops tied to the bottom ground plane. */}
			{[
				["C_USB", -16.25, 26.3],
				["C_REG_IN", -22.9, -14.05],
				["C_REG_OUT1", -11.1, -14.05],
				["C_LDO_IN", 21.5, 2.05],
				["C_LDO_OUT", 10.5, 2.05],
				["C_SENSOR", -2.2491192, 9.5],
				["C_SENSOR_IO", 2.2009608, -9.5],
			].map(([ref, x, y]) => (
				<Fragment key={ref}>
					<via
						name={`GND_${ref}`}
						pcbX={Number(x)}
						pcbY={Number(y)}
						fromLayer="top"
						toLayer="bottom"
						outerDiameter={0.6}
						holeDiameter={0.3}
						connectsTo="net.GND"
					/>
					<trace
						from={`.${ref} > .pin2`}
						to={`.GND_${ref} > .top`}
						thickness={0.35}
						pcbPath={[`.${ref} > .pin2`, `.GND_${ref} > .top`]}
					/>
				</Fragment>
			))}
			{/* Supply capacitors face the associated IC pins; short top-layer feeds. */}
			{[
				[".U_REG > .IN", ".C_REG_IN > .pin1"],
				[".U_REG > .OUT", ".C_REG_OUT1 > .pin1"],
				[".U_SENSOR_LDO > .IN", ".C_LDO_IN > .pin1"],
				[".U_SENSOR_LDO > .OUT", ".C_LDO_OUT > .pin1"],
				[".U_CHARGE > .IN", ".C_USB > .pin1"],
				[".U_SENSOR > .VDD", ".C_SENSOR > .pin1"],
				[".U_SENSOR > .VDDIO", ".C_SENSOR_IO > .pin1"],
			].map(([from, to], i) => (
				<Fragment key={i}>
					<trace
						name={`LOCAL_SUPPLY_${i}`}
						from={from}
						to={to}
						thickness={0.35}
						pcbPath={[from, to]}
					/>
				</Fragment>
			))}
			{/* Short, wide charge-pump connections from PixArt's application guidance. */}
			<trace
				name="CP_DIRECT"
				from=".U_SENSOR > .CP"
				to=".C_CP > .pin1"
				thickness={0.55}
				pcbPath={[".U_SENSOR > .CP", ".C_CP > .pin1"]}
			/>
			<trace
				name="CN_DIRECT"
				from=".U_SENSOR > .CN"
				to=".C_CP > .pin2"
				thickness={0.55}
				pcbPath={[".U_SENSOR > .CN", ".C_CP > .pin2"]}
			/>
			<trace
				name="VCP_DIRECT"
				from=".U_SENSOR > .VCP"
				to=".C_VCP > .pin1"
				thickness={0.55}
				pcbPath={[".U_SENSOR > .VCP", ".C_VCP > .pin1"]}
			/>
			<trace
				name="VCP_HF_DIRECT"
				maxLength={5}
				from=".U_SENSOR > .VCP"
				to=".C_VCP_HF > .pin1"
				thickness={0.55}
				pcbPath={[".U_SENSOR > .VCP", ".C_VCP_HF > .pin1"]}
			/>
			<trace
				name="VCP_HF_GROUND"
				from=".C_VCP_HF > .pin2"
				to=".C_VCP > .pin2"
				thickness={0.55}
				maxLength={5}
				pcbPath={[".C_VCP_HF > .pin2", ".C_VCP > .pin2"]}
			/>
			<trace
				name="VCP_GROUND_DIRECT"
				from=".U_SENSOR > .GND"
				to=".C_VCP > .pin2"
				thickness={0.55}
				pcbPath={[".U_SENSOR > .GND", { x: 3.1, y: 8.9125 }, ".C_VCP > .pin2"]}
			/>
			<silkscreentext
				text="tscircuit / CLEAR MOUSE"
				pcbX={0}
				pcbY={-15}
				fontSize={0.9}
			/>
			<silkscreentext
				text="USB-C 5V / CHARGE"
				pcbX={0}
				pcbY={40}
				fontSize={0.65}
			/>
			<silkscreentext text="BAT + / -" pcbX={15} pcbY={16} fontSize={0.65} />
			<silkscreentext text="NTC 10K" pcbX={20} pcbY={11} fontSize={0.65} />
			<silkscreentext
				text="BLE / KEEP CLEAR"
				pcbX={0}
				pcbY={-36}
				fontSize={0.7}
			/>
		</board>
	);
}