What's going on?

This example demonstrates how you can create wrappers on top of Pebble's existing C-Style API to extend functionality and write code that "looks" more like JavaScript. There are 2 important files to look at to fully understand this example.

js/rocky-extended.js

The code in espruino-compat.js wraps and extends the available functionality to include a Window class similar to Pebble's standard Window object, and a TimerService similar to Pebble's TickTimerService.

In addition to creating new objects for the developer to use, the Window constructor extends the context parameter passed into the rocky.update_proc callback to simplify a variety of graphics related API calls.

js/tictoc.js

The code in tictoc.js implements the TicToc watchface using the extended API defined in rocky-extended.js.

Fork me on GitHub