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
- AccelerometerService on developer.repebble.com
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
| Hz100Accelerometer sampling rate.
Defaults
defaultConfig
defaultConfig : ConfigDefault configuration for interactive apps.
Subscriptions
onData
onData : Config -> (Sample -> msg) -> Sub msgReceive accelerometer samples.
onTap
onTap : msg -> Sub msgReceive an accelerometer tap gesture.