MustafaMulla29/wireless-mouse-pcb
A 3D-printed wireless mouse enclosure housing a 44×70 mm PCB with nRF52810 BLE control, optical sensor, USB-C LiPo charging/power circuitry, buttons, scroll encoder/wheel, and battery bay.
- Version
- 1.0.18
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone MustafaMulla29/wireless-mouse-pcb # download the package files into ./wireless-mouse-pcb
tsci add MustafaMulla29/wireless-mouse-pcb # add it to your project as @tsci/MustafaMulla29.wireless-mouse-pcbIn 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.
enclosure/dimensions.ts
import boardJson from "./reference-board.json"
// Coordinates follow the BLDC enclosure convention: PCB X/Y, and Z = 0 at the
// centre of the board thickness. Every number here is in millimetres.
const rows = boardJson as any[]
export const board = rows.find((r) => r.type === "pcb_board")!
export const mountingHoles = rows.filter(
(r) => r.type === "pcb_hole" && !r.pcb_component_id && r.hole_diameter === 2.4,
)
export const sensorCutout = rows.find((r) => r.type === "pcb_cutout")!
function source(name: string) {
const s = rows.find((r) => r.type === "source_component" && r.name === name)
if (!s) throw Error(`Missing ${name}`)
return s
}
export function component(name: string) {
const s = source(name)
const p = rows.find(
(r) => r.type === "pcb_component" && r.source_component_id === s.source_component_id,
)
if (!p) throw Error(`Missing ${name}`)
return p
}
export function cad(name: string) {
const s = source(name)
const c = rows.find(
(r) => r.type === "cad_component" && r.source_component_id === s.source_component_id,
)
// SW_SIDE1/2 carry no CAD row; their footprint centre is the model centre.
if (!c) {
const p = component(name)
return { x: p.center.x, y: p.center.y, z: board.thickness / 2 }
}
return c.position as { x: number; y: number; z: number }
}
if (board.width !== 44 || board.height !== 70 || mountingHoles.length !== 3)
throw Error("Review the enclosure: the PCB outline or mounting holes changed")
export const pcbTop = board.thickness / 2 // 0.7
export const pcbBottom = -board.thickness / 2 // -0.7
// PMW3610 datasheet: 7.40 mm from the PCB top to the tracking surface.
const surface = pcbTop - 7.4 // -6.7
const skate = { thickness: 0.8, recess: 0.2 }
const bottom = surface + skate.thickness - skate.recess // -6.1
const floorTop = bottom + 2.4 // -3.7. Same 2.4 mm floor as the BLDC base.
export const design = {
surface,
skate,
wall: 2.4,
boardClearance: 4.3, // left and right, as in the BLDC enclosure
frontClearance: 0.6, // keeps the USB-C tunnel short
rearInnerY: 74, // the rear extension holds the battery
cornerRadius: 6,
bottom,
floorTop,
seam: floorTop,
lipClearance: 0.3,
lip: { thickness: 1.2, height: 1.5 },
// Same heat-set inserts as the BLDC enclosure.
inserts: {
m2: { length: 3, diameter: 3.6, holeDiameter: 3.4 },
m3: { length: 5.7, diameter: 4.6, holeDiameter: 4.2 },
},
// The 2.4 mm PCB holes take M2. M2 x 4 through 1.4 mm PCB into an M2 x 3 insert.
pcbMount: {
radius: 3.5,
insertTop: pcbBottom - 0.1,
holeBottom: pcbBottom - 0.1 - 3 - 0.6,
screwLength: 4,
},
// Case closing: M2 x 4 from the underside into M2 x 3 inserts in lid flanges,
// identical stack to the BLDC enclosure (flange radius, head seat, hole sizes).
caseBolts: [
[-25.7, -25],
[25.7, -25],
[-23.5, 66],
[23.5, 66],
] as [number, number][],
flange: {
radius: 3.4,
bottom: floorTop + 0.15,
top: 0.5,
holeRadius: 1.2,
headRadius: 2.1,
headSeat: bottom + 1.4,
screwLength: 4,
},
// Outer roof height along Y. Low at the buttons, palm hump at y = 28.
roofStations: [
[-38, 12.5],
[-20.5, 16.8],
[-9, 17.8],
[5, 23.5],
[28, 27.5],
[52, 25],
[76.4, 13],
] as [number, number][],
// Main buttons: captive keys over the D2FC switches.
key: {
windowClearance: 0.25,
flangeMargin: 1.5,
flangeThickness: 1.2,
flangeGap: 0.2,
capProud: 0.8,
stemRadius: 2,
pad: { w: 4, d: 5, h: 0.8 },
tipGap: 0.15,
// D2FC-F-7N: 6.5 mm body, actuator top 7.55 mm above the PCB, 2.5 mm off centre (C5157566 model).
switchBody: 6.5,
actuatorHeight: 7.55,
actuatorOffsetY: -2.5,
},
keyWindows: {
SW_LEFT: { x0: -23.8, x1: -6.0, y0: -31.5, y1: -12.5 },
// The -X flange edge stays clear of the wheel encoder; +X clears the wall.
SW_RIGHT: { x0: 15.0, x1: 25.0, y0: -31.5, y1: -12.5, flangeX0: 0.5, flangeX1: 0.8 },
} as Record<string, { x0: number; x1: number; y0: number; y1: number; flangeX0?: number; flangeX1?: number }>,
// Reference plunger (BLDC) dimensions, heights set per switch.
button: {
stemRadius: 1.7,
boreRadius: 2.05,
flangeRadius: 2.35,
pocketRadius: 2.65,
guideRadius: 3.5,
tipRadius: 1.25,
flangeThickness: 0.8,
tipGap: 0.15,
proud: 1.2,
},
tactHeight: 1.5, // C79172, SW_MIDDLE and SW_DPI
// EC10E encoder (C160888 model): rotor axis 11.0 mm above the PCB, body to 14.6 mm.
encoder: { axisHeight: 11.0, top: 14.6, halfWidthX: 3.07, halfDepthY: 5.52 },
wheel: { radius: 9, x0: 1.4, x1: 6.9, axleRadius: 1.0, axleX0: -1.9, axleX1: 12.5, grooves: 30 },
wheelSlot: { x0: 0.6, x1: 7.7, margin: 0.8 },
yoke: { x0: -2.6, x1: 0.6, halfDepth: 2.4, boreRadius: 1.15, topAboveAxis: 2.2, guideClearance: 0.2, guideThickness: 1.0, guideBottom: 9 },
encoderPocket: { x0: 7.0, x1: 14.2, margin: 0.5, skin: 0.8 },
// EVQPUC02K side switches (C79174): actuator tip 2.75 mm off centre, ~0.7 mm above the PCB.
side: {
tipOffset: 2.75,
axisZ: pcbTop + 0.7,
tipGap: 0.15,
head: { w: 4.0, h: 3.2, proud: 0.9 },
window: { w: 4.4, h: 3.6 },
flange: { w: 6.0, h: 4.4, t: 1.0, gap: 0.15 },
bar: { w: 2.4, z0: pcbTop + 0.25, z1: pcbTop + 1.25 },
boardGap: 0.6,
},
// SS-12D00 slider: lever top 6.6 mm above the PCB, slides along X.
power: {
leverTop: 6.6,
leverBodyTop: 3.5,
leverWidth: 1.5,
leverTravel: 2.5,
outerWidth: 13.4,
outerDepth: 17.2,
innerWidth: 11.6,
innerDepth: 8.4,
screwY: 6.5,
screwRadius: 1.2,
insertHoleDepth: 4,
screwLength: 5,
forkWidth: 4,
forkGap: 2.5,
jawThickness: 1.4,
lowerSlotWidth: 10,
lowerSlotDepth: 5,
flangeWidth: 7.2,
flangeDepth: 7.8,
gripWidth: 6.2,
gripDepth: 5,
gripProud: 3.2,
windowWidth: 11.2,
windowDepth: 5.6,
retainerThickness: 2.1,
sliderHalfTravel: 1.75,
},
usb: { width: 12.5, height: 7.0, centerAbovePcb: 1.14 },
chargeLed: { radius: 1.0, zAbovePcb: 0.9 },
// LM18-LSI lens opening. Size not taken from the PixArt drawing; confirm before printing.
lens: { width: 19, depth: 22, radius: 2 },
battery: { x: 0, y: 56, width: 22, depth: 33, height: 6.5, wall: 1.2, cell: [20, 30, 6] as const, cableNotch: 6 },
skates: [
{ x: 0, y: -34.4, w: 30, d: 4 },
{ x: 0, y: 72.4, w: 30, d: 4 },
],
thtRelief: { depth: 1.0, margin: 1.0 },
} as const
const d = design
export const body = {
halfWidth: board.width / 2 + d.boardClearance + d.wall, // 28.7
front: board.center.y - board.height / 2 - d.frontClearance - d.wall, // -38
rear: d.rearInnerY + d.wall, // 76.4
}
export function roofOuter(y: number) {
const s = d.roofStations
if (y <= s[0][0]) return s[0][1]
for (let i = 1; i < s.length; i++) {
const [y0, z0] = s[i - 1]
const [y1, z1] = s[i]
if (y <= y1) return z0 + ((z1 - z0) * (y - y0)) / (y1 - y0)
}
return s[s.length - 1][1]
}
export const roofInner = (y: number) => roofOuter(y) - d.wall
export function range(f: (y: number) => number, y0: number, y1: number, kind: "min" | "max") {
const ys = [y0, y1, ...d.roofStations.map((s) => s[0]).filter((y) => y > y0 && y < y1)]
const zs = ys.map(f)
return kind === "min" ? Math.min(...zs) : Math.max(...zs)
}
// Switch positions taken from the reference board.
const leftC = cad("SW_LEFT"), rightC = cad("SW_RIGHT")
export const keys = [
{ ref: "SW_LEFT", name: "KEY_LEFT", x: leftC.x, y: leftC.y + d.key.actuatorOffsetY, ...d.keyWindows.SW_LEFT },
{ ref: "SW_RIGHT", name: "KEY_RIGHT", x: rightC.x, y: rightC.y + d.key.actuatorOffsetY, ...d.keyWindows.SW_RIGHT },
]
export const dpi = { ref: "SW_DPI", ...cad("SW_DPI") }
export const middle = { ref: "SW_MIDDLE", ...cad("SW_MIDDLE") }
export const wheelAxis = { y: cad("ENC_WHEEL").y, z: pcbTop + d.encoder.axisHeight }
export const encoderCenter = cad("ENC_WHEEL")
export const sideButtons = ["SW_SIDE1", "SW_SIDE2"].map((ref) => {
const c = cad(ref)
return { ref, name: `SIDE_PLUNGER_${ref}`, y: c.y, tipX: c.x - d.side.tipOffset }
})
const powerC = cad("SW_POWER")
export const power = (() => {
const p = d.power
const y0 = powerC.y - p.outerDepth / 2
const retainerTop = range(roofOuter, y0, powerC.y + p.outerDepth / 2, "min")
const retainerBottom = retainerTop - p.retainerThickness
const flangeTop = retainerBottom - 0.4
const flangeBottom = flangeTop - 0.8
const floorTop = flangeBottom - 0.2
const floorBottom = floorTop - 3.1
return {
...p,
x: powerC.x,
y: powerC.y,
retainerTop,
retainerBottom,
flangeTop,
flangeBottom,
floorTop,
floorBottom,
gripTop: retainerTop + p.gripProud,
insertTop: retainerBottom,
forkBottom: pcbTop + p.leverBodyTop + 0.8,
leverX: powerC.x - p.leverTravel / 2, // OFF/start position assumed at -X
}
})()
export const usb = { x: cad("J_USB").x, z: pcbTop + d.usb.centerAbovePcb }
export const chargeLed = { x: cad("LED_CHARGE").x, z: pcbTop + d.chargeLed.zAbovePcb }
export const sensor = { x: sensorCutout.center.x, y: sensorCutout.center.y }
export const thtParts = ["SW_LEFT", "SW_RIGHT", "ENC_WHEEL", "SW_POWER", "SW_SIDE1", "SW_SIDE2", "SW_RESET", "J_USB"]