Close

Command Your Pebble

Using Simply.js, you can display text on your Pebble with just JavaScript.

simply.title('Hello World!');

Or even give a short vibe.

simply.vibe('short');

Add Interactivity

Using simply.on, you can listen to button press events from the Pebble to make something interactive.

simply.on('singleClick', function(e) {
  simply.subtitle('You pressed the ' + e.button + ' button!');
});

You can also listen to long clicks which are button hold events.

simply.on('longClick', function(e) {
  simply.subtitle('You held the ' + e.button + ' button!');
});

Perform different actions depending on the button press. Here's an example of a simple Pebble counter app. It also uses localStorage to persist the counter.

var count = parseInt(localStorage.getItem('count')) || 0;

simply.on('singleClick', function(e) {
  if (e.button === 'up') {
    simply.subtitle(++count);
  } else if (e.button === 'down') {
    simply.subtitle(--count);
  }
  localStorage.setItem('count', count);
});

simply.text({ title: 'Counter', subtitle: count });

Need more than single and long clicks? You can also listen to accel tap events!

simply.on('accelTap', function(e) {
  simply.subtitle('You tapped across ' + (e.direction > 0 ? '+' : '-') + e.axis + '!');
});

Tap the Internet

Included is an ajax micro library that you can use to request content directly from the web.

ajax({ url: 'http://simplyjs.io' }, function(data){
  var headline = data.match(/<h1>(.*?)<\/h1>/)[1];
  simply.title(headline);
});

You can use your phone's geolocation to get relevant information such as the weather where you're at.

navigator.geolocation.getCurrentPosition(function(pos) {
  var coords = pos.coords;
  var weatherUrl = 'http://api.openweathermap.org/data/2.5/weather?' +
      'lat=' + coords.latitude + '&lon=' + coords.longitude + '&units=metric';
  ajax({ url: weatherUrl, type: 'json' }, function(data) {
    simply.text({ title: data.name, subtitle: data.main.temp });
  });
});

PebbleKit

And, of course, you have access to PebbleKit JavaScript.

Pebble.showSimpleNotificationOnPebble('Hello!',
  'Notifications from JavaScript? Welcome to the future!');
  

How Do I Use This?

You'll need a Pebble with OS 2.0.

  • Write a Simply.js script and host it online.
  • Download Simply.js v0.3.2 onto your Pebble.
  • Go to "My Pebble" in the new official Pebble Phone App.
  • Tap the Simply.js settings gear.
  • Place the URL to your script and hit Save.* Your script should immediately run.
  • Play with your Pebble!

* If you're hosting your script on Github, use the raw URL to your script.

Multi-file Projects

You can require additional JavaScript files if you want to rapidly prototype without concatenating your source files. You'll need to use a directory-based file host such as a web host or Github.

index.js

var controller = require('lib/controller'),
    config = require('config');
    
controller.doSomething(config.setting);

lib/controller.js

var controller = {};

controller.doSomething = function(x) {
  simply.subtitle(x);
};

module.exports = controller;

config.js

var config = {
  setting: 'Setting'
};

module.exports = config;