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
    | Off

Whether the system backlight is currently on.

Commands

interaction

interaction : Cmd msg

Trigger the default interaction backlight behavior.

disable

disable : Cmd msg

Force backlight off.

enable

enable : Cmd msg

Force backlight on.

Subscriptions

onChange

onChange : (State -> msg) -> Sub msg

Receive backlight on/off transitions from the Pebble runtime.