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

Pebble JavaScript API

  • Pebble C API
  • Pebble JavaScript API
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • CanvasRenderingContext2D
    • TextMetrics
    • fillStyle
    • Canvas
    • strokeStyle
    • canvas
    • lineWidth
    • font
    • textAlign
    • clearRect
    • fillRect
    • strokeRect
    • fillText
    • measureText
    • beginPath
    • closePath
    • moveTo
    • lineTo
    • arc
    • rect
    • fill
    • stroke
    • save
    • restore
    • rockyFillRadial
  • console
    • log
    • warn
    • error
  • Date
    • toLocaleString
    • toLocaleTimeString
    • toLocaleDateString
  • rocky
    • RockyPostMessageErrorCallback
    • RockyPostMessageConnectedCallback
    • WatchInfo
    • watchInfo
    • RockyMemoryPressureCallback
    • RockyPostMessageDisconnectedCallback
    • UserPreferences
    • RockyDrawCallback
    • RockyMessageCallback
    • RockyTickCallback
    • userPreferences
    • on
    • addEventListener
    • removeEventListener
    • off
    • postMessage
    • requestDraw

Pebble Rocky.js API Documentation

Pebble's JavaScript API allows developers to write watchfaces in JavaScript, that are executed via the firmware's JerryScript engine. For instructions on getting started with Pebble's JavaScript API, see the JS Watchface Tutorial.

The JavaScript API is broken down into the following modules:


CanvasRenderingContext2D

console

Date

rocky


The JavaScript API also includes the following global functions:

setTimeout(fct, delay)

Calls a function after a specified delay.

var timeoutId = setTimeout(function(...){}, 10000);

Parameters

Function fct

The function to execute

Number delay

The delay (in ms)

Returns

timeoutId - The ID of the timeout

clearTimeout(timeoutId)

Clears the delay set by setTimeout.

clearTimeout(timeoutId);

Parameters

Number timeoutId

The ID of the timeout you wish to clear.

setInterval(fct, delay)

Repeatedly calls a function, with a fixed time delay between each call.

var intervalId = setInterval(function(...){}, 10000);

Parameters

Function fct

The function to execute

Number delay

The delay (in ms)

Returns

intervalId - The ID of the interval

clearInterval(intervalId)

Clears the interval set by setInterval.

clearInterval(intervalId);

Parameters

Number intervalId

The ID of the interval you wish to clear


To learn more about how to use this part of the Pebble SDK, check out the JavaScript Watchface tutorial, which also includes links to example apps.


Web API by Mozilla Contributors is licensed under CC-BY-SA 2.5.