Pebble.Accel

Accelerometer subscriptions for Pebble watches.

Subscribe with onData for continuous samples and onTap for shake gestures. Use Pebble.Events.batch to combine them with button or timer subscriptions.

import Pebble.Accel as Accel
import Pebble.Events as Events

type Msg
    = AccelSample Accel.Sample
    | AccelTap

subscriptions _ =
    Events.batch
        [ Accel.onData Accel.defaultConfig AccelSample
        , Accel.onTap AccelTap
        ]

For a runnable example, use the watch-demo-accel project template in the IDE.

Native Pebble C API

Types

Config

type alias Config =
    { samplesPerUpdate : Int
    , samplingRate : SamplingRate
    }

Accelerometer sampling configuration.

Sample

type alias Sample =
    { x : Int
    , y : Int
    , z : Int
    }

One accelerometer sample.

SamplingRate

type SamplingRate
    = Hz10
    | Hz25
    | Hz50
    | Hz100

Accelerometer sampling rate.

Defaults

defaultConfig

defaultConfig : Config

Default configuration for interactive apps.

Subscriptions

onData

onData : Config -> (Sample -> msg) -> Sub msg

Receive accelerometer samples.

onTap

onTap : msg -> Sub msg

Receive an accelerometer tap gesture.