How to program the Pebble smartwatch: Part 3

Update Pebble has released version 2 of its OS and this invalidates much of what follows, which was written for an earlier version of the OS.

As it stands, the app I created in Part 2 appears in the Pebble’s menu simply as a name, Ball, which is entered into the boilerplate PBL_APP_INFO created by the SDK’s create_pebble_project.py script. This also sets the app’s unique UUID, which you’ll see at the top of the file. You can also modify this to set the app’s version number and to add your name as author.

But what’s really needed is a menu icon, and you can add one by editing the resource_map.json created for you in the /resources/src folder within the project folder.

Continue reading

How to program the Pebble smartwatch: Part 2

Update Pebble has released version 2 of its OS and this invalidates much of what follows, which was written for an earlier version of the OS.

In Part 1 we got our basic Pebble app up and running, but it doesn’t do very much. Let’s add some user interaction.

To respond to button presses, Pebble OS now uses a system akin to its event handling mechanism, the better to help the coder give the user more ways to control the three-button watch. The new approach lets you directly accommodate single clicks short and long, double-clicks, and press-and-hold events, rather than simply waiting for a push on a specific button and then trying to anticipate the user’s intentions.

The Pebble SDK, then, defines a ClickConfigProvider entity which is essentially an array of function calls for specific buttons and the various ways each of them can be used. This list of calls is attached to the host window. First, we need to add the line

    window_set_click_config_provider(&window, (ClickConfigProvider)config_provider);

to the handle_init() initialisation function, and we need to run it after the app’s Window – reached using the pointer variable window – has been pushed onto the OS’s Window stack, or it will be ignored. The above line tells the window where to get its array of button configurations from, which it does by calling a second function, the config_provider passed in the first call.

Continue reading

How to program the Pebble smartwatch: Part 1

Update Pebble has released version 2 of its OS and this invalidates much of what follows, which was written for an earlier version of the OS.

Pebble didn’t invent the smartwatch, but it has done more than most to bring this new product category to the attention of the world, largely thanks to its hugely successful and well-reported Kickstarter funding campaign.

Pebble’s smartwatch – also called Pebble – remains one of the few of its kind that go beyond duplicating a host phone’s notifications and messages on its own screen. Pebble will do all that of course, but much more interesting is the SDK Pebble provides to allow C programmers to create clever new watch faces and, better still, native apps to run on the smartwatch’s 144 x 168 black-and-white screen.

Pebble

Your app will appear below the Pebble’s Settings icon

Continue reading