Add motion tracking and calibration features

This commit is contained in:
Nik Rozman committed 2026-10-14 09:37:41 +02:00
1 parent 4aa369ca73
commit aab61a2b7b
13 files changed
+735 -169

No files matched your search

+16 -4
View File
@@ -4,7 +4,7 @@ A BLE HID mouse that uses the onboard IMU of a **Seeed XIAO nRF52840 Sense** to
## Features
- **6-DoF gyro + accelerometer** via LSM6DS3 with complementary filter
- **Roll-compensated pointing** - gyro + accelerometer fusion keeps the cursor level however the remote is twisted in the hand
- **Hardware tap detection** - single tap = left click, double tap = right click
- **BLE HID mouse** - works natively on Windows, macOS, Linux, Android, iOS
- **BLE Battery Service** - charge level visible in OS Bluetooth settings
@@ -13,7 +13,7 @@ A BLE HID mouse that uses the onboard IMU of a **Seeed XIAO nRF52840 Sense** to
- **Live IMU stream** - 20 Hz gyro/accel data streamed to the web UI visualiser
- **Live telemetry** - temperature, uptime, click counts, gyro bias RMS, recal count
- **Temperature compensation** - gyro drift correction by Δ temperature since last calibration
- **Auto-recalibration** - recalibrates automatically after 5 minutes of idle
- **Continuous bias tracking** - gyro bias is re-estimated whenever the remote is at rest, so the cursor does not drift
- **Configurable charge rate** - OFF / 50 mA slow / 100 mA fast via BQ25100 HICHG pin
- **Boot-loop detection** - 3 rapid reboots trigger safe mode (config service disabled, flash wiped)
@@ -48,7 +48,7 @@ Open `web/index.html` in Chrome or Edge (desktop). Requires Web Bluetooth - enab
| Parameter | Range | Description |
|---|---|---|
| Sensitivity | 100 – 1500 | Cursor speed multiplier |
| Dead zone | 0.005 – 0.2 rad/s | Noise floor; raise to reduce drift |
| Dead zone | 0 – 0.1 rad/s | Soft dead zone on smoothed speed; raise to steady the cursor while holding still |
| Accel strength | 0 – 0.5 | Pointer acceleration multiplier |
| Curve | Linear / Square / √Sqrt | Response shape for input magnitude |
| Flip X / Y | on/off | Invert horizontal or vertical axis |
@@ -59,6 +59,18 @@ Open `web/index.html` in Chrome or Edge (desktop). Requires Web Bluetooth - enab
- **Calibrate Gyro** - recalculates bias offset; hold the device still on a flat surface for ~1 s
- **Factory Reset** - wipes flash config, restores defaults
**Serial commands** (115200 baud over USB):
| Key | Action |
|---|---|
| `c` | Calibrate gyro |
| `r` | Factory reset |
| `s` | Toggle 1 Hz tracking stats (sample rate, HID reports, bias, roll, BLE interval); keeps the device awake |
| `l` | Toggle raw IMU log, one CSV line per sample; keeps the device awake |
| `d` | 10 s of roll-compensated yaw/pitch rates and roll angle |
| `t` | Synthetic sweep (right, left, down, up); moves the host cursor and prints the counts sent |
| `o` | Enter OTA DFU mode |
## Building
### Requirements
@@ -84,7 +96,7 @@ All optional features are enabled by `#define` in `source/config.h`. Comment out
#define FEATURE_IMU_STREAM // 20 Hz raw IMU stream
#define FEATURE_TAP_DETECTION // Hardware tap → click engine
#define FEATURE_TEMP_COMPENSATION // Gyro drift correction by temperature
#define FEATURE_AUTO_RECAL // Auto-recalibrate after 5 min idle
#define FEATURE_AUTO_RECAL // Continuous gyro bias tracking while at rest
#define FEATURE_BATTERY_MONITOR // ADC battery level + BLE Battery Service
#define FEATURE_BOOT_LOOP_DETECT // Crash counter → safe mode
```