pebble as remote control

22
Pebble Watch Wrist control of your smart home Pavel Dmitriev, http://nimble.com

Upload: paul-dmitryev

Post on 17-Aug-2015

49 views

Category:

Software


0 download

TRANSCRIPT

Pebble WatchWrist control of your smart home

Pavel Dmitriev, http://nimble.com

What’s inside• Sharp 1,32" eInk display (144 × 168 pixels, 176 PPI)

• 3 x LCDs backlight

• Bluetooth 2.1 (default), 4.0 + EDR 4.0 + LE

• ARM Cortex-M3, up to 80 MHz with 512 KB

• 8 x 96 KB slots (in old Pebbles)

• 4 buttons, 3 axis accelerometer with gesture detection, magnetometer, ambient light sensor, vibro

What's the deal?• Time

• Notifications

• Activity tracker (Misfit, Runkeeper, Jawbone UP, etc.)

• Music remote

• Calendars, twitter, RSS

• Compass, timers, GoPro, etc., etc., etc.

Positive sides• eInk — visible on bright sun of Montenegro

• Allways on

• Works up to 7 days (5 days avg.)

• Inexpensive (from $99)

• Water resistant (50m for basic, 30m for Time)

Negative sides

• Slow CPU and limited resources

• Not so good system integration

• No speakerphone (Time have microphone)

• Phone required for Internet access and GPS

Only real smart WATCH

Two languages

VS

JavascriptC++

Development options

• Local SDK No so easy to set up, but fast and reliable

• Cloud IDEEasy to start, but some glitches present

Simple example

• Simple API, let’s pretend it’s smart controller API

• GET /api — get value {'val': x}

• POST /api — set value {'val': x}

• /ws — websocket API

Requirementsvar ajax = require('ajax');var UI = require('ui');var Vector2 = require('vector2');var Vibe = require('ui/vibe');

var val = 5;

Main windowvar wind = new UI.Window({ fullscreen: true, backgroundColor: 'white', action: { up: 'images/Icon Plus.png', down: 'images/Icon Minus.png', select: 'images/Icon Check.png' } });

Two text fieldsvar val_field = new UI.Text({ position: new Vector2(0, 65), size: new Vector2(114, 30), font: 'gothic-28-bold', text: '???', textAlign: 'center', color: 'black',});

Two text fieldsvar stat_field = new UI.Text({ position: new Vector2(0, 140), size: new Vector2(114, 30), font: 'gothic-14-bold', text: 'Status', textAlign: 'center', color: 'white', });

wind.add(val_field);wind.add(stat_field);

Clicks handlerfunction on_click(e) { if(e.button == 'up') { if(val < 10) { val += 1; } else { Vibe.vibrate('short'); } } else { if(val > 0) { val -= 1; } else { Vibe.vibrate('short'); } } val_field.text('Value = ' + val); console.log('Value = ' + val);}

Helper and handlers settingfunction show_status(stat_text) { stat_field.text(stat_text); stat_field.color('black'); setTimeout(function () { stat_field.color('white'); }, 1000);}

wind.on('click', 'up', on_click);wind.on('click', 'down', on_click);

Über server interactionwind.on('click', 'select', function(e) { ajax({ 'url': 'http://cleg.pagekite.me/api', 'method': 'post', 'type': 'json', 'data': {'val': val} }, function(data, status, request) { console.log('OK ' + JSON.stringify(data)); show_status('GUT !'); }, function(error, status, request) { console.log('The ajax request failed: ' + error); show_status('FAIL :('); } ); console.log('Tried to set value=' + val);});

Ask value from server (with respect)

Get initial valueajax( { url: 'http://cleg.pagekite.me/api', type: 'json' }, function(data, status, request) { val = data.val; val_field.text('Value = ' + val); }, function(error, status, request) { console.log('The ajax request failed: ' + error); });

Main magic

wind.show();

Now we see it!

Near future: Time

• 64 color screen (remember EGA? it's 4 times better)

• Microphone for spoken notes and replies

• New 3.0 SDK and timelite view

Thank you!

• https://github.com/cleg/bulb

• https://github.com/cleg/DummyServ