Skip to content

Motion over IIO sensors - #16

Merged
colemancda merged 17 commits into
masterfrom
feature/motion
Nov 22, 2026
Merged

colemancda merged 17 commits into
masterfrom
feature/motion

Conversation

@colemancda

Copy link
Copy Markdown
Member

Implements the Motion contracts on Linux, and the Device contract's orientation and proximity.

Why not iio-sensor-proxy for everything. iio-sensor-proxy exposes only an orientation string plus light, proximity and compass, never raw vectors. So:

  • MotionManager and Altimeter read the kernel's IIO sensors in sysfs directly (/sys/bus/iio/devices/iio:deviceN). Accelerometer, gyroscope and magnetometer values have each device's mount matrix applied. Pressure is turned into relative altitude.
  • Device motion is a Mahony filter over the accelerometer and gyroscope. It gives attitude, gravity and user acceleration.
  • Readings are polled off the main thread on one serial queue and handed to the main loop. Polling is capped at 100 Hz or the driver's fastest rate. Timestamps use CLOCK_BOOTTIME. A busy driver skips a reading. Any other read failure stops the sensor and reports it once.
  • Pedometer and ActivityRecognizer are registered as unavailable: Linux has no step counter or activity classifier to read.
  • LinuxDevice takes orientation and proximity from iio-sensor-proxy on the system bus. It claims and releases the sensor as updates turn on and off.
  • The packager now accepts the motion contracts and the motion capability. NFC is the only domain left.

Plan.md gains §13 Motion. Later sections are renumbered.

Testing. Tests run against fake IIO devices under a temporary root and a fake sensor proxy. The full suite passes on Linux (Debian trixie, aarch64, Swift 6.4.2). Nothing has run on real sensor hardware yet.

@colemancda colemancda mentioned this pull request Nov 22, 2026
@colemancda
colemancda merged commit c2379d3 into master Nov 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant