pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Moddable API (Alloy)
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • Alloy
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BacklightService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
      • TouchService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • Speaker
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

The APIs on this page will only work with SDK 4.9+.

BacklightService

Notifies your app when the backlight turns on or off.

The BacklightService lets your app react to the backlight turning on. The handler is invoked whenever the backlight transitions between off and on (any non-off state — fully on, on with timeout, or fading out is treated as "on"). This means you get a single edge per wake, not one event per fade step.

Function Documentation

void backlight_service_subscribe(BacklightHandler handler)

Subscribe to the backlight event service. Once subscribed, the handler is called every time the backlight transitions between off and on.

Parameters

handler

A callback to be executed on backlight on/off events.

void backlight_service_unsubscribe(void)

Unsubscribe from the backlight event service. Once unsubscribed, the previously registered handler will no longer be called.

To read the current backlight state at any time, use light_is_on().

Typedef Documentation

typedef void(* BacklightHandler)(bool on)

Callback type for backlight on/off events.

Parameters

on

true when the backlight has just turned on, false when it has just turned fully off.

Need some help?

Functions

  • backlight_service_subscribe
  • backlight_service_unsubscribe

Typedefs

  • BacklightHandler

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can join us on the Discord!