BLE HID Mouse Firmware for Puck.js
Converts Puck.js accelerometer data into Bluetooth mouse movements. Pairs as a standard HID mouse with any Bluetooth-enabled device.
graph LR
subgraph "Input"
TILT[Tilt Device]
BTN[Button Press]
end
subgraph "Processing"
ACC[Accelerometer]
HID[HID Mouse Protocol]
end
subgraph "Output"
CURSOR[Cursor Movement]
CLICK[Mouse Clicks]
SCROLL[Scroll Wheel]
end
TILT --> ACC
ACC --> HID
BTN --> HID
HID --> CURSOR
HID --> CLICK
HID --> SCROLL
| Action | Input | LED Feedback |
|---|---|---|
| Move cursor | Tilt device | - |
| Left click | Single button press | Red flash |
| Right click | Double button press | Blue flash |
| Scroll mode | Hold button + tilt | Blue flash (on enter) |
| Toggle on/off | NFC tap | Green (on) / Red (off) |
Adjustable via BLE console:
CONFIG.sensitivity = 5; // 1-10, higher = faster
CONFIG.deadzone = 500; // Ignore small movements
CONFIG.invertX = false; // Invert X axis
CONFIG.invertY = false; // Invert Y axis
CONFIG.scrollSensitivity = 2;
The firmware includes HID appearance advertising for Windows 11 compatibility. If pairing fails:
stateDiagram-v2
[*] --> Idle: Power on
Idle --> Moving: Tilt detected
Moving --> Idle: Return to neutral
Idle --> ButtonHeld: Button press
ButtonHeld --> LeftClick: Release < 300ms
ButtonHeld --> ScrollMode: Hold > 300ms
ButtonHeld --> RightClick: Double press
LeftClick --> Idle
RightClick --> Idle
ScrollMode --> Idle: Button release
Idle --> Disabled: NFC tap
Disabled --> Idle: NFC tap
Use the Firmware Loader or Espruino Web IDE:
app.jssave()