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

RockyJS API (deprecated)

  • Pebble C API
  • Moddable API (Alloy)
  • 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

Rocky.js API Documentation

The RockyJS API allows developers to write watchfaces in JavaScript, that are executed via the firmware's JerryScript engine. For instructions on getting started with the RockyJS API, see the JS Watchface Tutorial.
Note that RockyJS is deprecated and is not recommended for new development. For new development we recommend Alloy.

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.