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
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Rocky
    • 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
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

Timer

Can be used to execute some code at some point in the future.

Function Documentation

  • SDK 3
  • SDK 4
void psleep(int millis)

Waits for a certain amount of milliseconds.

Parameters

millis

The number of milliseconds to wait for

The function psleep does not exist in SDK 4.

  • SDK 3
  • SDK 4
AppTimer * app_timer_register(uint32_t timeout_ms, AppTimerCallback callback, void * callback_data)

Registers a timer that ends up in callback being called some specified time in the future.

Parameters

timeout_ms

The expiry time in milliseconds from the current time

callback

The callback that gets called at expiry time

callback_data

The data that will be passed to callback

Returns

A pointer to an AppTimer that can be used to later reschedule or cancel this timer

The function app_timer_register does not exist in SDK 4.

  • SDK 3
  • SDK 4
bool app_timer_reschedule(AppTimer * timer_handle, uint32_t new_timeout_ms)

Reschedules an already running timer for some point in the future.

Parameters

timer_handle

The timer to reschedule

new_timeout_ms

The new expiry time in milliseconds from the current time

Returns

true if the timer was rescheduled, false if the timer has already elapsed

The function app_timer_reschedule does not exist in SDK 4.

  • SDK 3
  • SDK 4
void app_timer_cancel(AppTimer * timer_handle)

Cancels an already registered timer. Once cancelled the handle may no longer be used for any purpose.

The function app_timer_cancel does not exist in SDK 4.

Typedef Documentation

  • SDK 3
  • SDK 4
typedef struct AppTimer AppTimer

The typedef AppTimer does not exist in SDK 4.

  • SDK 3
  • SDK 4
typedef void(* AppTimerCallback)(void *data)

The type of function which can be called when a timer fires. The argument will be the callback_data passed to app_timer_register().

The typedef AppTimerCallback does not exist in SDK 4.

Need some help?

Functions

  • psleep
  • app_timer_register
  • app_timer_reschedule
  • app_timer_cancel

Typedefs

  • AppTimer
  • AppTimerCallback

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!