4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <meta name="Author" content="KaiRo - Robert Kaiser">
6 <title>Firefox OS Tricorder</title>
7 <link rel="stylesheet" type="text/css" href="slides.css">
8 <script type="text/javascript" src="slides.js"></script>
9 <link rel="contents" href="#index" title="Overview">
10 <link rel="index" id="link-toc" href="#toc" title="Contents">
11 <link rel="start" id="link-start" href="#index" title="Start">
13 <body onload="docLoaded();">
14 <header id="header"><div id="header-text">Tricorder</div>
15 <div id="subheader-text"></div>
16 <a id="headerlogo" href="#index" title="Startseite">Mozilla</a>
19 <a href="#toc" id="nav-toc" accesskey="t">toc</a> ||
20 <a href="#index" id="nav-start" accesskey="s">start</a> ||
21 <a href="#" id="nav-prev" accesskey="p" hidden>< back</a>
22 <span id="nav-prev-nolink" class="nolink">< back</span> |
23 <a href="#" id="nav-next" id="goNext" accesskey="n" hidden>fwd ></a>
24 <span id="nav-next-nolink" class="nolink">fwd ></span>
27 <article id="toc" title="Table of Contents">
28 <h1>Table of Contents</h1>
29 <h2>Firefox OS Tricorder</h2>
31 <div class="captionedbox">
32 <p class="captionedbox-caption">The following slides are available in this presentation:</p>
33 <div class="captionedbox-content">
38 <article id="index" title="Start Page">
39 <h1>Firefox OS Tricorder</h1>
40 <h2>Reading Device Sensor Data in JavaScript</h2>
42 <div class="simplebox">
43 <mark><a href="http://home.kairo.at/">Robert Kaiser</a></mark>,
44 "KaiRo" <kairo@kairo.at>
45 <br><small>Program Manager, Mozilla QA</small>
48 <div class="captionedbox">
49 <p class="captionedbox-caption">Slides:
50 <a href="http://slides.kairo.at/fosdem2015/">http://slides.kairo.at/fosdem2015/</a></p>
51 <div class="captionedbox-content small">
54 <a href="http://fosdem.org/2015/schedule/track/mozilla/">Mozilla
55 Developer Room</a> at <a href="http://www.fosdem.org/">FOSDEM 2015</a> in
57 <li>Written in HTML 5 with CSS 3 and JavaScript.</li>
58 <li>Navigation via links on all slides, via access keys
59 (e.g. "n"/Alt+Shift+N for "next") or back/forward arrow keys</li>
60 <li><a href="#toc">Contents</a></li>
61 <li><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/at/"><img
62 alt="Licensed under CC-BY-SA," style="border-width:0;vertical-align:bottom;"
63 src="cc-by-sa-80x15.png"></a> 01/2015 Robert Kaiser -
64 "Mozilla", "Firefox" and their logos are
65 <a href="http://www.mozilla.org/foundation/trademarks/list.html">trademarks
66 of the Mozilla Foundation</a>; <a href="http://www.startrek.com/">Star Trek</a>
67 and related items are trademarks of
68 <a href="http://www.paramount.com/">Paramount Pictures</a>.</li>
74 <article id="tricorder" title="Tricorder">
75 <h1>What is a Tricorder?</h1>
77 <div class="simplebox">
78 <img src="starfleet_tricorder_2370.jpg" class="slidepic"
79 alt="Starfleet Tricorder, 2370">
80 <p>Sensor device as seen on "Star Trek"</p>
81 <p>Displays whatever data is needed at plot speeds and resolutions.</p>
82 <p class="ensurepicinbox"></p>
86 <article id="fxos-tricorder" title="Firefox OS Tricorder">
87 <h1>Firefox OS Tricorder App</h1>
89 <div class="simplebox">
90 <p>Displays data from device sensors as exposed by WebAPIs</p>
91 <p><a href="https://marketplace.firefox.com/app/tricorder/">marketplace.firefox.com/app/tricorder/</a></p>
92 <p>Code: <a href="https://github.com/KaiRo-at/tricorder">github.com/KaiRo-at/tricorder</a></p>
96 <article id="ui" title="UI">
97 <h1>Firefox OS Tricorder UI</h1>
99 <div class="simplebox cent">
100 <img src="tricorder-ui.svg"
101 alt="Tricorder UI description">
105 <article id="module" title="Module">
108 <div class="simplebox">
110 <li>HTML (switch, display)</li>
113 <li>2 Methods: activate(), deactivate()</li>
120 <article id="position" title="Position Module">
121 <h1>Position Module</h1>
123 <div class="simplebox">
124 <p>GPS, WiFi/Cell Location</p>
125 <p>API: Geolocation</p>
126 <p>Permission: geolocation</p>
130 <article id="position-code" title="Position: Code">
131 <h1>Position: Code</h1>
133 <div class="simplebox">
135 this.watchID = navigator.geolocation.watchPosition(
137 position.coords.latitude / .longitude / .accuracy / ...
139 function(error) { ... },
140 {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000}
143 navigator.geolocation.clearWatch(this.watchID);
148 <article id="gravity" title="Gravity Module">
149 <h1>Gravity Module</h1>
151 <div class="simplebox">
152 <p>Accelerometer, Magnetometer</p>
153 <p>APIs: deviceorientation, devicemotion events</p>
154 <p>Permissions: ---</p>
158 <article id="gravity-code" title="Gravity: Code">
159 <h1>Gravity: Code</h1>
161 <div class="simplebox">
163 window.addEventListener("deviceorientation", this.orientEvent, true);
164 window.addEventListener("devicemotion", this.motionEvent, true);
166 orientEvent: function(orientData) {
167 orientData.alpha / .beta / .gamma (in °)
169 motionEvent: function(event) {
170 event.accelerationIncludingGravity.x / .y / .z (in m/s²)
173 window.removeEventListener("deviceorientation", this.orientEvent, true);
174 window.removeEventListener("devicemotion", this.motionEvent, true);
179 <article id="sound" title="Sound Module">
180 <h1>Sound Module</h1>
182 <div class="simplebox">
184 <p>APIs: WebRTC(getUserMedia), WebAudio</p>
185 <p>Permissions: audio-capture</p>
189 <article id="sound-code" title="Sound: Code">
192 <div class="simplebox">
194 navigator.getUserMedia({ audio: true },
195 function(aLocalMediaStream) {
196 gModSound.mAudio.stream = aLocalMediaStream;
197 gModSound.mAudio.context = new window.AudioContext();
198 gModSound.mAudio.input = gModSound.mAudio.context.createMediaStreamSource(gModSound.mAudio.stream);
199 gModSound.mAudio.analyzer = gModSound.mAudio.context.createAnalyser();
200 gModSound.mAudio.input.connect(gModSound.mAudio.analyzer);
202 function(err) { ... }
205 // in window.requestAnimationFrame():
206 var data = new Uint8Array(gModSound.mAudio.frequencySlices);
207 gModSound.mAudio.analyzer.getByteFrequencyData(data);
208 // ... do something with data ...
210 gModSound.mAudio.stream.stop();
215 <article id="environment" title="Environment Module">
216 <h1>Environment Module</h1>
218 <div class="simplebox">
219 <p>Light, Proximity; Flashlight</p>
220 <p>APIs: devicelight, deviceproximity events; Camera API</p>
221 <p>Permissions: ---; camera (for Flash)</p>
225 <article id="environment-code" title="Environment: Code">
226 <h1>Environment: Code</h1>
228 <div class="simplebox">
230 window.addEventListener("devicelight", this.lightEvent, true);
231 window.addEventListener("deviceproximity", this.proxEvent, true);
233 lightEvent: function(lightData) {
234 lightData.value (in lux)
236 proxEvent: function(proxData) {
237 proxData.min <= .value <= .max (in cm)
240 window.removeEventListener("devicelight", this.lightEvent, true);
241 window.removeEventListener("deviceproximity", this.proxEvent, true);
243 // flash/torch code works via navigator.mozCameras.getCamera
244 // flaky and subject to change, please consult code on github
249 <article id="device" title="Device Module">
250 <h1>Device Module</h1>
252 <div class="simplebox">
255 <p>Permissions: ---</p>
259 <article id="device-code" title="Device: Code">
260 <h1>Device: Code</h1>
262 <div class="simplebox">
264 (navigator.battery.level * 100).toFixed(1) + "%";
266 if (navigator.battery.charging) {
267 if (navigator.battery.chargingTime == 0 ||
268 navigator.battery.chargingTime == Infinity) {
272 "charging, " + navigator.battery.chargingTime + "s remaining";
276 if (navigator.battery.dischargingTime == 0 ||
277 navigator.battery.dischargingTime == Infinity) {
281 navigator.battery.dischargingTime + "s usage remaining";
288 <article id="end" title="The End">
290 <div class="simplebox">
291 <h1 class="cent" style="position: relative; z-index: 3; color: #FFFFFF; font-size: 2.5em;">Questions?</h1>
292 <img src="mister_tricorder.jpg" class="sshot"
293 style="width: 100%; margin-top: -4.5em; position: relative; z-index: 1;"
294 alt="Data & Mister Tricorder">