Commit | Line | Data |
---|---|---|
b41707de RK |
1 | <!DOCTYPE html> |
2 | <html> | |
3 | <head> | |
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"> | |
12 | </head> | |
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> | |
17 | </header> | |
18 | <nav id="slidenav"> | |
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> | |
25 | </nav> | |
26 | ||
27 | <article id="toc" title="Table of Contents"> | |
28 | <h1>Table of Contents</h1> | |
29 | <h2>Firefox OS Tricorder</h2> | |
30 | ||
31 | <div class="captionedbox"> | |
32 | <p class="captionedbox-caption">The following slides are available in this presentation:</p> | |
33 | <div class="captionedbox-content"> | |
34 | <ul id="toc-list"> | |
35 | </ul> | |
36 | </article> | |
37 | ||
38 | <article id="index" title="Start Page"> | |
39 | <h1>Firefox OS Tricorder</h1> | |
40 | <h2>Reading Device Sensor Data in JavaScript</h2> | |
41 | ||
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> | |
46 | </div> | |
47 | ||
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"> | |
52 | <ul class="small"> | |
53 | <li>Created for | |
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 | |
56 | Brussels.</li> | |
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> | |
69 | </ul> | |
70 | </div> | |
71 | </div> | |
72 | </article> | |
73 | ||
74 | <article id="tricorder" title="Tricorder"> | |
75 | <h1>What is a Tricorder?</h1> | |
76 | ||
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> | |
83 | </div> | |
84 | </article> | |
85 | ||
86 | <article id="fxos-tricorder" title="Firefox OS Tricorder"> | |
87 | <h1>Firefox OS Tricorder App</h1> | |
88 | ||
89 | <div class="simplebox"> | |
a5b5cb49 | 90 | <p>Displays data from device sensors as exposed by WebAPIs</p> |
b41707de RK |
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> | |
93 | </div> | |
94 | </article> | |
95 | ||
96 | <article id="ui" title="UI"> | |
97 | <h1>Firefox OS Tricorder UI</h1> | |
98 | ||
a5b5cb49 RK |
99 | <div class="simplebox cent"> |
100 | <img src="tricorder-ui.svg" | |
101 | alt="Tricorder UI description"> | |
b41707de RK |
102 | </div> |
103 | </article> | |
104 | ||
105 | <article id="module" title="Module"> | |
106 | <h1>Module</h1> | |
107 | ||
108 | <div class="simplebox"> | |
109 | <ul> | |
110 | <li>HTML (switch, display)</li> | |
111 | <li>JS Object | |
112 | <ul> | |
113 | <li>2 Methods: activate(), deactivate()</li> | |
114 | </ul> | |
115 | </li> | |
116 | </ul> | |
117 | </div> | |
118 | </article> | |
119 | ||
120 | <article id="position" title="Position Module"> | |
121 | <h1>Position Module</h1> | |
122 | ||
123 | <div class="simplebox"> | |
124 | <p>GPS, WiFi/Cell Location</p> | |
125 | <p>API: Geolocation</p> | |
126 | <p>Permission: geolocation</p> | |
127 | </div> | |
128 | </article> | |
129 | ||
130 | <article id="position-code" title="Position: Code"> | |
131 | <h1>Position: Code</h1> | |
132 | ||
133 | <div class="simplebox"> | |
134 | <pre> | |
135 | this.watchID = navigator.geolocation.watchPosition( | |
a5b5cb49 RK |
136 | function(position) { |
137 | position.coords.latitude / .longitude / .accuracy / ... | |
138 | }, | |
b41707de RK |
139 | function(error) { ... }, |
140 | {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000} | |
141 | ); | |
142 | ||
143 | navigator.geolocation.clearWatch(this.watchID); | |
144 | </pre> | |
145 | </div> | |
146 | </article> | |
147 | ||
148 | <article id="gravity" title="Gravity Module"> | |
149 | <h1>Gravity Module</h1> | |
150 | ||
151 | <div class="simplebox"> | |
a5b5cb49 | 152 | <p>Accelerometer, Magnetometer</p> |
b41707de RK |
153 | <p>APIs: deviceorientation, devicemotion events</p> |
154 | <p>Permissions: ---</p> | |
155 | </div> | |
156 | </article> | |
157 | ||
158 | <article id="gravity-code" title="Gravity: Code"> | |
159 | <h1>Gravity: Code</h1> | |
160 | ||
161 | <div class="simplebox"> | |
162 | <pre> | |
163 | window.addEventListener("deviceorientation", this.orientEvent, true); | |
164 | window.addEventListener("devicemotion", this.motionEvent, true); | |
165 | ||
166 | orientEvent: function(orientData) { | |
167 | orientData.alpha / .beta / .gamma (in °) | |
168 | }, | |
169 | motionEvent: function(event) { | |
170 | event.accelerationIncludingGravity.x / .y / .z (in m/s²) | |
171 | }, | |
172 | ||
173 | window.removeEventListener("deviceorientation", this.orientEvent, true); | |
174 | window.removeEventListener("devicemotion", this.motionEvent, true); | |
175 | </pre> | |
176 | </div> | |
177 | </article> | |
178 | ||
179 | <article id="sound" title="Sound Module"> | |
180 | <h1>Sound Module</h1> | |
181 | ||
182 | <div class="simplebox"> | |
183 | <p>Microphone</p> | |
184 | <p>APIs: WebRTC(getUserMedia), WebAudio</p> | |
185 | <p>Permissions: audio-capture</p> | |
186 | </div> | |
187 | </article> | |
188 | ||
189 | <article id="sound-code" title="Sound: Code"> | |
190 | <h1>Sound: Code</h1> | |
191 | ||
192 | <div class="simplebox"> | |
193 | <pre> | |
a5b5cb49 RK |
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); | |
201 | }, | |
202 | function(err) { ... } | |
203 | ); | |
204 | ||
205 | // in window.requestAnimationFrame(): | |
206 | var data = new Uint8Array(gModSound.mAudio.frequencySlices); | |
207 | gModSound.mAudio.analyzer.getByteFrequencyData(data); | |
208 | // ... do something with data ... | |
209 | ||
210 | gModSound.mAudio.stream.stop(); | |
b41707de RK |
211 | </pre> |
212 | </div> | |
213 | </article> | |
214 | ||
215 | <article id="environment" title="Environment Module"> | |
216 | <h1>Environment Module</h1> | |
217 | ||
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> | |
222 | </div> | |
223 | </article> | |
224 | ||
225 | <article id="environment-code" title="Environment: Code"> | |
226 | <h1>Environment: Code</h1> | |
227 | ||
228 | <div class="simplebox"> | |
229 | <pre> | |
a5b5cb49 RK |
230 | window.addEventListener("devicelight", this.lightEvent, true); |
231 | window.addEventListener("deviceproximity", this.proxEvent, true); | |
232 | ||
233 | lightEvent: function(lightData) { | |
234 | lightData.value (in lux) | |
235 | }, | |
236 | proxEvent: function(proxData) { | |
237 | proxData.min <= .value <= .max (in cm) | |
238 | }, | |
239 | ||
240 | window.removeEventListener("devicelight", this.lightEvent, true); | |
241 | window.removeEventListener("deviceproximity", this.proxEvent, true); | |
242 | ||
243 | // flash/torch code works via navigator.mozCameras.getCamera | |
244 | // flaky and subject to change, please consult code on github | |
b41707de RK |
245 | </pre> |
246 | </div> | |
247 | </article> | |
248 | ||
249 | <article id="device" title="Device Module"> | |
250 | <h1>Device Module</h1> | |
251 | ||
252 | <div class="simplebox"> | |
253 | <p>Battery</p> | |
254 | <p>APIs: Battery</p> | |
255 | <p>Permissions: ---</p> | |
256 | </div> | |
257 | </article> | |
258 | ||
259 | <article id="device-code" title="Device: Code"> | |
260 | <h1>Device: Code</h1> | |
261 | ||
262 | <div class="simplebox"> | |
263 | <pre> | |
a5b5cb49 RK |
264 | (navigator.battery.level * 100).toFixed(1) + "%"; |
265 | ||
266 | if (navigator.battery.charging) { | |
267 | if (navigator.battery.chargingTime == 0 || | |
268 | navigator.battery.chargingTime == Infinity) { | |
269 | "charging"; | |
270 | } | |
271 | else { | |
272 | "charging, " + navigator.battery.chargingTime + "s remaining"; | |
273 | } | |
274 | } | |
275 | else { | |
276 | if (navigator.battery.dischargingTime == 0 || | |
277 | navigator.battery.dischargingTime == Infinity) { | |
278 | "discharging"; | |
279 | } | |
280 | else { | |
281 | navigator.battery.dischargingTime + "s usage remaining"; | |
282 | } | |
283 | } | |
b41707de RK |
284 | </pre> |
285 | </div> | |
286 | </article> | |
287 | ||
288 | <article id="end" title="The End"> | |
289 | ||
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"> | |
295 | </div> | |
296 | </article> | |
297 | ||
298 | </body> | |
299 | </html> |