Search documentation of mob

# Mob.Motion (mob v0.6.18)

Copy Markdown View Source

Accelerometer and gyroscope sensor data.

No permission required.

Updates arrive at `handle_info` at the requested interval:

    handle_info({:motion, %{
      accel:     {ax, ay, az},   # m/s² (gravity included)
      gyro:      {gx, gy, gz},   # rad/s
      timestamp: unix_ms
    }}, socket)

If you only request one sensor, the other tuple will be `{0.0, 0.0, 0.0}`.

iOS: `CMMotionManager`. Android: `SensorManager`.

## Summary

### Types

sensor()

### Functions

start(socket, opts \\ [])

Start sensor updates.

stop(socket)

Stop sensor updates.

## Types

# sensor()

    @type sensor() :: :accelerometer | :gyro

## Functions

# start(socket, opts \\ [])

    @spec start(
      Mob.Socket.t(),
      keyword()
    ) :: Mob.Socket.t()

Start sensor updates.

Options:

- `sensors: [:accelerometer] | [:gyro] | [:accelerometer, :gyro]` (default both)

- `interval_ms: integer` — update interval in milliseconds (default `100`)

# stop(socket)

    @spec stop(Mob.Socket.t()) :: Mob.Socket.t()

Stop sensor updates.