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="Überblick">
10 <link rel="index" id="link-toc" href="#toc" title="Inhalt">
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">Inhalt</a> ||
20 <a href="#index" id="nav-start" accesskey="s">Start</a> ||
21 <a href="#" id="nav-prev" accesskey="p" hidden>< zurück</a>
22 <span id="nav-prev-nolink" class="nolink">< zurück</span> |
23 <a href="#" id="nav-next" id="goNext" accesskey="n" hidden>weiter ></a>
24 <span id="nav-next-nolink" class="nolink">weiter ></span>
27 <article id="toc" title="Inhalt">
29 <h2>Firefox OS Tricorder</h2>
31 <div class="captionedbox">
32 <p class="captionedbox-caption">Folgende Folien sind in dieser Präsentation enthalten:</p>
33 <div class="captionedbox-content">
38 <article id="index" title="Start Page">
39 <h1>Firefox OS Tricorder</h1>
40 <h2>Auslesen von Gerätesensoren mittels 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>Release Quality Manager, Mozilla</small>
48 <div class="captionedbox">
49 <p class="captionedbox-caption">Folien:
50 <a href="https://slides.kairo.at/linuxwochen2015/">https://slides.kairo.at/linuxwochen2015/</a></p>
51 <div class="captionedbox-content small">
53 <li>Erstellt für einen
54 <a href="https://cfp.linuxwochen.at/de/LWW15/public/events/283">Vortrag</a>
55 auf den <a href="http://www.linuxwochen.at/">Linuxwochen 2015</a> in Wien.</li>
56 <li>Geschrieben in HTML 5 mit CSS 3 und JavaScript.</li>
57 <li>Navigation mit Links auf allen Folien, mit Accesskeys
58 (z.B. "n"/Alt+Umschalt+N für "next"/weiter) oder vor/zurück-Pfeilasten</li>
59 <li><a href="#toc">Inhalt</a></li>
60 <li><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/at/"><img
61 alt="Lizenziert unter CC-BY-SA," style="border-width:0;vertical-align:bottom;"
62 src="cc-by-sa-80x15.png"></a> 04/2015 Robert Kaiser -
63 "Mozilla", "Firefox" und deren Logos sind
64 <a href="http://www.mozilla.org/foundation/trademarks/list.html">Handelsmarken
65 der Mozilla Foundation</a>; <a href="http://www.startrek.com/">Star Trek</a>
66 und zugehörige Elemente sind Warenzeichen von
67 <a href="http://www.paramount.com/">Paramount Pictures</a>.</li>
73 <article id="tricorder" title="Tricorder">
74 <h1>Was ist ein Tricorder?</h1>
76 <div class="simplebox">
77 <img src="starfleet_tricorder_2370.jpg" class="slidepic"
78 alt="Starfleet Tricorder, 2370">
79 <p>Sensorgerät wie in "Star Trek" zu sehen</p>
80 <p>Zeigt jegliche Daten an, die gerade benötigt werden, in Plot-Geschwindigkeit und -auflösung.</p>
81 <p class="ensurepicinbox"></p>
85 <article id="fxos-tricorder" title="Firefox OS Tricorder">
86 <h1>Firefox-OS-Tricorder-App</h1>
88 <div class="simplebox">
89 <p>Zeigt Daten von Gerätesensoren an, die von WebAPIs zur Verfügung gestellt werden.</p>
90 <p><a href="https://marketplace.firefox.com/app/tricorder/">marketplace.firefox.com/app/tricorder/</a></p>
91 <p>Code: <a href="https://github.com/KaiRo-at/tricorder">github.com/KaiRo-at/tricorder</a></p>
95 <article id="ui" title="UI">
96 <h1>Firefox-OS-Tricorder-Oberfläche</h1>
98 <div class="simplebox cent">
99 <img src="tricorder-ui.svg"
100 alt="Beschreibung der Tricorder-Oberfläche">
104 <article id="module" title="Modul">
107 <div class="simplebox">
109 <li>HTML (Schalter, Anzeige)</li>
112 <li>2 Methoden: activate(), deactivate()</li>
119 <article id="position" title="Positions-Modul">
120 <h1>Positions-Modul</h1>
122 <div class="simplebox">
123 <p>GPS, WLAN/Handysender-Peilung</p>
124 <p>API: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Geolocation">Geolocation</a></p>
125 <p>Berechtigung: geolocation</p>
129 <article id="position-code" title="Position: Code">
130 <h1>Position: Code</h1>
132 <div class="simplebox">
134 this.watchID = <a href="https://developer.mozilla.org/en-US/docs/Web/API/Geolocation.watchPosition">navigator.geolocation.watchPosition</a>(
136 position.coords.latitude / .longitude / .accuracy / ...
138 function(error) { ... },
139 {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000}
142 navigator.geolocation.clearWatch(this.watchID);
147 <article id="gravity" title="Schwerkraft-Modul">
148 <h1>Schwerkraft-Modul ("Gravity")</h1>
150 <div class="simplebox">
151 <p>Accelerometer, Magnetometer</p>
152 <p>APIs: <a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent">deviceorientation</a>-,
153 <a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent">devicemotion</a>-Erignisse</p>
154 <p>Berechtigungen: ---</p>
158 <article id="gravity-code" title="Schwerkraft: Code">
159 <h1>Schwerkraft: Code</h1>
161 <div class="simplebox">
163 window.addEventListener("<a href="https://developer.mozilla.org/en-US/docs/Web/Events/deviceorientation">deviceorientation</a>", this.orientEvent, true);
164 window.addEventListener("<a href="https://developer.mozilla.org/en-US/docs/Web/Events/devicemotion">devicemotion</a>", 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="Schall-Modul">
180 <h1>Schall-Modul ("Sound")</h1>
182 <div class="simplebox">
184 <p>APIs: <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a>(getUserMedia),
185 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API">WebAudio</a></p>
186 <p>Berechtigungen: audio-capture</p>
190 <article id="sound-code" title="Schall: Code">
191 <h1>Schall: Code</h1>
193 <div class="simplebox">
195 <a href="https://developer.mozilla.org/en-US/docs/NavigatorUserMedia.getUserMedia">navigator.getUserMedia</a>({ audio: true },
196 function(aLocalMediaStream) {
197 gModSound.mAudio.stream = aLocalMediaStream;
198 gModSound.mAudio.context = new <a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioContext">window.AudioContext</a>();
199 gModSound.mAudio.input =
200 gModSound.mAudio.context.createMediaStreamSource(gModSound.mAudio.stream);
201 gModSound.mAudio.analyzer = gModSound.mAudio.context<a href="https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode">.createAnalyser</a>();
202 gModSound.mAudio.input.connect(gModSound.mAudio.analyzer);
204 function(err) { ... }
207 // in window.requestAnimationFrame():
208 var data = new Uint8Array(gModSound.mAudio.frequencySlices);
209 gModSound.mAudio.analyzer<a href="https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode.getByteFrequencyData">.getByteFrequencyData</a>(data);
210 // ... do something with data ...
212 gModSound.mAudio.stream.stop();
217 <article id="environment" title="Umgebungs-Modul">
218 <h1>Umgebungs-Modul ("Environment")</h1>
220 <div class="simplebox">
221 <p>Licht, Entfernung; Taschenlampe</p>
222 <p>APIs: <a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceLightEvent">devicelight</a>-,
223 <a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceProximityEvent">deviceproximity</a>-Ereignisse;
224 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Camera_API">Camera API</a></p>
225 <p>Berechtigungen: ---; camera (für Lampe)</p>
229 <article id="environment-code" title="Umgebung: Code">
230 <h1>Umgebung: Code</h1>
232 <div class="simplebox">
234 window.addEventListener("<a href="https://developer.mozilla.org/en-US/docs/Web/Events/devicelight">devicelight</a>", this.lightEvent, true);
235 window.addEventListener("<a href="https://developer.mozilla.org/en-US/docs/Web/Events/deviceproximity">deviceproximity</a>", this.proxEvent, true);
237 lightEvent: function(lightData) {
238 lightData.value (in lux)
240 proxEvent: function(proxData) {
241 proxData.min <= .value <= .max (in cm)
244 window.removeEventListener("devicelight", this.lightEvent, true);
245 window.removeEventListener("deviceproximity", this.proxEvent, true);
247 // Taschenlampe mittels <a href="https://developer.mozilla.org/en-US/docs/Web/API/CameraManager.getCamera">navigator.mozCameras.getCamera</a>
248 // Funktioniert nicht immer und kann sich jederzeit ändern, bitte Code aif GitHub nachlesen.
253 <article id="device" title="Geräte-Modul">
254 <h1>Geräte-Modul ("Device")</h1>
256 <div class="simplebox">
258 <p>APIs: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API">Battery Status API</a></p>
259 <p>Berechtigungen: ---</p>
263 <article id="device-code" title="Gerät: Code">
266 <div class="simplebox">
268 0 <= <a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator.battery">navigator.battery</a>.level <= 1
270 .charging (true/false)
272 .chargingTime (in s; 0 or Infinity: unbekannt)
274 .dischargingTime (in s; 0 or Infinity: unbekannt)
279 <article id="end" title="Ende">
281 <div class="simplebox">
282 <h1 class="cent" style="position: relative; z-index: 3; color: #FFFFFF; font-size: 2.5em;">Fragen?</h1>
283 <img src="mister_tricorder.jpg" class="sshot"
284 style="width: 100%; margin-top: -4.5em; position: relative; z-index: 1;"
285 alt="Data & Mister Tricorder">