Pebble.Light
Backlight controls.
Use interaction for the default tap-to-light behavior, enable / disable to force the backlight on or off, and onChange to observe transitions.
import Pebble.Light as Light
type Msg
= TurnOn
| LightChanged Light.State
update msg model =
case msg of
TurnOn ->
( model, Light.enable )
LightChanged Light.On ->
( { model | backlight = True }, Cmd.none )
LightChanged Light.Off ->
( { model | backlight = False }, Cmd.none )
subscriptions _ =
Light.onChange LightChanged
For a runnable example, use the watch-demo-light project template in the IDE.
Native Pebble C API
- Light on developer.repebble.com
Union Types
State
type State
= On
| OffWhether the system backlight is currently on.
Commands
interaction
interaction : Cmd msgTrigger the default interaction backlight behavior.
disable
disable : Cmd msgForce backlight off.
enable
enable : Cmd msgForce backlight on.
Subscriptions
onChange
onChange : (State -> msg) -> Sub msgReceive backlight on/off transitions from the Pebble runtime.