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

Light

Controlling Pebble's backlight

The Light API provides you with functions to turn on Pebble’s backlight or put it back into automatic control. You can trigger the backlight and schedule a timer to automatically disable the backlight after a short delay, which is the preferred method of interacting with the backlight.

Function Documentation

void light_enable_interaction(void)

Trigger the backlight and schedule a timer to automatically disable the backlight after a short delay. This is the preferred method of interacting with the backlight.

void light_enable(bool enable)

Turn the watch's backlight on or put it back into automatic control. Developers should take care when calling this function, keeping Pebble's backlight on for long periods of time will rapidly deplete the battery.

Parameters

enable

Turn the backlight on if true, otherwise false to put it back into automatic control.

bool light_is_on(void)

Returns

true if the backlight is currently on in any form (on, timed, or fading out). Returns false only when the backlight is fully off. Useful for apps that want to behave differently depending on whether the screen is currently lit — e.g. skipping an animation or queuing a visual cue for when the screen wakes.

void light_set_color(GColor color)

Tint the backlight LED to the given color. The color persists while the app is foregrounded and is automatically reset to the user's default (white) when the app exits or is preempted by a system notification. On platforms without a color backlight this is a no-op.

Note

GColor carries only 2 bits per channel (64 distinct tints). Use light_set_color_rgb888() if you need the full 8-bit-per-channel range that the LED hardware supports.

Parameters

color

The color to tint the backlight to.

void light_set_color_rgb888(uint32_t rgb)

Tint the backlight LED to a packed 24-bit RGB value (0x00RRGGBB). Same persistence semantics as light_set_color(): the override lasts while the app is foregrounded and is reset on app exit or system preempt. No-op on platforms without a color backlight.

Parameters

rgb

Packed 0x00RRGGBB value; 8 bits per channel. High byte ignored.

void light_set_system_color(void)

Restore the backlight to the user's default color. Rarely needed — the system resets automatically on app exit. No-op on platforms without a color backlight.

Need some help?

Functions

  • light_enable_interaction
  • light_enable
  • light_is_on
  • light_set_color
  • light_set_color_rgb888
  • light_set_system_color

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!