altering the real world with javascript - framsia

41
altering the real world with JavaScript Jan Jongboom Framsia 23-09-2015

Upload: jan-jongboom

Post on 09-Jan-2017

726 views

Category:

Internet


4 download

TRANSCRIPT

Page 1: Altering the real world with JavaScript - Framsia

altering the real worldwith JavaScript

Jan Jongboom Framsia 23-09-2015

Page 2: Altering the real world with JavaScript - Framsia

@janjongboom

Telenor R&D

Mozilla things

Page 3: Altering the real world with JavaScript - Framsia

I hate JavaScript!

Page 4: Altering the real world with JavaScript - Framsia

VBScript <3 <3 <3

Page 5: Altering the real world with JavaScript - Framsia
Page 6: Altering the real world with JavaScript - Framsia
Page 7: Altering the real world with JavaScript - Framsia

BORING!

Page 8: Altering the real world with JavaScript - Framsia
Page 9: Altering the real world with JavaScript - Framsia

AccelerometerReal purpose: Turn to mute

Page 10: Altering the real world with JavaScript - Framsia

Juggling visualizerMeasure z-forces on device

Plot it in graph over time

Juggle with multiple devices

Page 11: Altering the real world with JavaScript - Framsia

Juggling visualizer

1 window.addEventListener('devicemotion', function(e) { 2 var serie = getGraphSerieForDevice(e.data.deviceId); 3 serie.addPoint([ e.data.timestamp, Math.abs(e.data.z) ]); 4 });

Page 12: Altering the real world with JavaScript - Framsia

Weight scale

Page 13: Altering the real world with JavaScript - Framsia

Computer generated

music

Page 14: Altering the real world with JavaScript - Framsia
Page 15: Altering the real world with JavaScript - Framsia

http://gibber.mat.ucsb.edu/

Page 16: Altering the real world with JavaScript - Framsia

1 a = Drums('x*o*x*o-')

Gibber

Page 17: Altering the real world with JavaScript - Framsia

Gibber 1 a = Drums('x*o*x*o-') 2 a.pitch = 0.5

Page 18: Altering the real world with JavaScript - Framsia

Gibber 1 a = Drums('x*o*x*o-') 2 3 speak = Speak({ pitch: 70, wordgap:5 }) 4 .say.seq( 5 ['Mu', 'nich', 'Mu', 'Mu', 'nich'], 6 [1/2, 1/2, 1/4, 1/4, 1/2] 7 ) 8 9 speak.pitch.seq( [1,.8,1.2].rnd() ) 10 Clock.bpm = 120;

Page 19: Altering the real world with JavaScript - Framsia

Gibber 1 a = Drums('x*o*x*o-') 2 3 speak = Speak({ pitch: 70, wordgap:5 }) 4 .say.seq( 5 ['Mu', 'nich'], 6 [1/4, 1/4, 1/4, 1/2].rnd() 7 ) 8 9 speak.pitch.seq( [1,.8,1.2].rnd() ) 10 Clock.bpm = 120;

Page 20: Altering the real world with JavaScript - Framsia

Gibber 1 a = Drums('x*o*x*o-') 2 3 speak = Speak({ pitch: 70, wordgap:5 }) 4 .say.seq( 5 ['Mu', 'nich'], 6 [1/4, 1/4, 1/4, 1/2].rnd() 7 ) 8 9 speak.pitch.seq( [1,.8,1.2].rnd() ) 10 Clock.bpm = 120;

Page 21: Altering the real world with JavaScript - Framsia

So much phones!

Page 22: Altering the real world with JavaScript - Framsia
Page 23: Altering the real world with JavaScript - Framsia

Gibber

Page 24: Altering the real world with JavaScript - Framsia

Gibber 1 a = Drums('x*o*x*o-') 2 a.pitch = Phone.X

https://github.com/janjongboom/jsconf-us/blob/master/gibber/gibber-phone.js

Page 25: Altering the real world with JavaScript - Framsia

Getting data out of thereal world

Page 26: Altering the real world with JavaScript - Framsia

iBeaconsBroadcasting their existence

Page 27: Altering the real world with JavaScript - Framsia

iBeaconsLong battery life

Cheap Unique identifier

Page 28: Altering the real world with JavaScript - Framsia

Coming to a web browser near youhttps://bugzilla.mozilla.org/show_bug.cgi?id=1063444

Page 29: Altering the real world with JavaScript - Framsia

Scanning beacons 1 var adapter = navigator.mozBluetooth.defaultAdapter 2 adapter.startLeScan([]).then(handle => { 3 handle.ondevicefound = e => { 4 // handle e.scanRecord 5 } 6 7 setTimeout(() => { 8 adapter.stopLeScan(handle) 9 }, 5000) 10 }, err => console.error(err))

Page 30: Altering the real world with JavaScript - Framsia

JavaScript baby monitorTag your baby with a phone

Get three beacons Some math

Page 31: Altering the real world with JavaScript - Framsia
Page 32: Altering the real world with JavaScript - Framsia

Physical WebWalk up and use anything

Page 33: Altering the real world with JavaScript - Framsia

Physical Web beacon

http://goo.gl/a1b4cd

Page 34: Altering the real world with JavaScript - Framsia
Page 35: Altering the real world with JavaScript - Framsia

http://rollingspider.xyz/aa73bc21

Page 36: Altering the real world with JavaScript - Framsia

Drone Web AppPhysical Web to discover

Web App gets reference to device Connect using WebBluetooth

Fly!

Page 37: Altering the real world with JavaScript - Framsia

10 // Set up the connection 11 e.device.gatt.connect().then(() => { 12 return e.device.gatt.discoverServices(); 13 }).then(() => { 14 // devices have services, and services have characteristics 15 var services = e.device.gatt.services; 16 console.log('services', services); 17 18 // find the characteristic that handles flying the drone 19 var c = services.reduce((curr, f) => curr.concat(f.characteristics), []) 20 .filter(c => c.uuid === '9a66fa0b-0800-9191-11e4-012d1540cb8e')[0]; 21 22 // take off instruction! 23 var buffer = new Uint8Array(0x04, counter++, 0x02, 0x00, 0x01, 0x00]); 24 c.writeValue(buffer).then(() => { 25 console.log('take off successful!'); 26 }); 27 });

Page 38: Altering the real world with JavaScript - Framsia

-

Page 39: Altering the real world with JavaScript - Framsia
Page 40: Altering the real world with JavaScript - Framsia

Get hacking!Grab a phone and use sensor data

Take beacon or Nordic dev kit

WebBluetooth is coming! Be prepared!

Page 41: Altering the real world with JavaScript - Framsia

Thank you!@janjongboom

https://github.com/janjongboom/(jsconf-asia|jsconf-us) https://hacks.mozilla.org/?p=29166