Coder Social home page Coder Social logo

tipebble's Introduction

TiPebble

Build Status

Implements basic features of the Pebble iOS SDK.

Pebble Screenshot

Quick Start

Get it gitTio

Download the latest distribution ZIP-file and consult the Titanium Documentation on how install it, or simply use the gitTio CLI:

$ gittio install org.beuckman.tipebble

Usage

Add this to your <ios><plist><dict> section in tiapp.xml:

	<key>UISupportedExternalAccessoryProtocols</key>
	<array>
		<string>com.getpebble.public</string>
	</array>

You'll need your Pebble app's UUID here:

var pebble = require('org.beuckman.tipebble');

// this demo uuid is from the pebble documentation
pebble.setAppUUID("226834ae-786e-4302-a52f-6e7efc9f990b");

Respond when the Pebble app connects/disconnects:

function watchConnected(e) {
    pebble.getVersionInfo({
        success: function(e) {
            alert(e);
        },
        error: function(e) {
            alert(e);
        }
    });
}
function watchDisonnected(e) {
    alert("watchDisconnected");
}

pebble.addEventListener("watchConnected", watchConnected);
pebble.addEventListener("watchDisconnected", watchDisonnected);

Launch or kill your Pebble app:

function launchApp() {
  pebble.launchApp({
      success: function(e) {
          Ti.API.info(e);
      },
      error: function(e) {
          alert(e);
      }
  });
}

function killApp() {
  pebble.killApp({
      success: function(e) {
          Ti.API.info(e);
      },
      error: function(e) {
          alert(e);
      }
  });
}

Send messages to the app with integer keys and string or integer values:

function sendMessage() {
  pebble.sendMessage({
    message: {
      0: 123,
      1: 'TiPebble'
    },
    success: function(e) {
      Ti.API.info(e);
    },
    error : function(e) {
      Ti.API.error(e);
    }
  });
}

Send an image for display on the Pebble caution

This requires your Pebble app to implement image receiving code as appears in the example Pebble app. Images on the Pebble must have width a multiple of 32 pixels. If your image is not a multiple of 32 pixels wide, a black border will be added to the right, expanding to the next multiple of 32.

function sendImage() {

  var f = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'image.png');

  pebble.sendImage({
    image : f.read(),
    key: 2,
    success: function(e) {
      Ti.API.info(e);
    },
    error : function(e) {
      Ti.API.error(e);
    }
  });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.