| 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="Überblick"> |
| 10 | <link rel="index" id="link-toc" href="#toc" title="Inhalt"> |
| 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">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> |
| 25 | </nav> |
| 26 | |
| 27 | <article id="toc" title="Inhalt"> |
| 28 | <h1>Inhalt</h1> |
| 29 | <h2>Firefox OS Tricorder</h2> |
| 30 | |
| 31 | <div class="captionedbox"> |
| 32 | <p class="captionedbox-caption">Folgende Folien sind in dieser Präsentation enthalten:</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>Auslesen von Gerätesensoren mittels 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>Release Quality Manager, Mozilla</small> |
| 46 | </div> |
| 47 | |
| 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"> |
| 52 | <ul class="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> |
| 68 | </ul> |
| 69 | </div> |
| 70 | </div> |
| 71 | </article> |
| 72 | |
| 73 | <article id="tricorder" title="Tricorder"> |
| 74 | <h1>Was ist ein Tricorder?</h1> |
| 75 | |
| 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> |
| 82 | </div> |
| 83 | </article> |
| 84 | |
| 85 | <article id="fxos-tricorder" title="Firefox OS Tricorder"> |
| 86 | <h1>Firefox-OS-Tricorder-App</h1> |
| 87 | |
| 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> |
| 92 | </div> |
| 93 | </article> |
| 94 | |
| 95 | <article id="ui" title="UI"> |
| 96 | <h1>Firefox-OS-Tricorder-Oberfläche</h1> |
| 97 | |
| 98 | <div class="simplebox cent"> |
| 99 | <img src="tricorder-ui.svg" |
| 100 | alt="Beschreibung der Tricorder-Oberfläche"> |
| 101 | </div> |
| 102 | </article> |
| 103 | |
| 104 | <article id="module" title="Modul"> |
| 105 | <h1>Modul</h1> |
| 106 | |
| 107 | <div class="simplebox"> |
| 108 | <ul> |
| 109 | <li>HTML (Schalter, Anzeige)</li> |
| 110 | <li>JS-Objekt |
| 111 | <ul> |
| 112 | <li>2 Methoden: activate(), deactivate()</li> |
| 113 | </ul> |
| 114 | </li> |
| 115 | </ul> |
| 116 | </div> |
| 117 | </article> |
| 118 | |
| 119 | <article id="position" title="Positions-Modul"> |
| 120 | <h1>Positions-Modul</h1> |
| 121 | |
| 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> |
| 126 | </div> |
| 127 | </article> |
| 128 | |
| 129 | <article id="position-code" title="Position: Code"> |
| 130 | <h1>Position: Code</h1> |
| 131 | |
| 132 | <div class="simplebox"> |
| 133 | <pre> |
| 134 | this.watchID = <a href="https://developer.mozilla.org/en-US/docs/Web/API/Geolocation.watchPosition">navigator.geolocation.watchPosition</a>( |
| 135 | function(position) { |
| 136 | position.coords.latitude / .longitude / .accuracy / ... |
| 137 | }, |
| 138 | function(error) { ... }, |
| 139 | {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000} |
| 140 | ); |
| 141 | |
| 142 | navigator.geolocation.clearWatch(this.watchID); |
| 143 | </pre> |
| 144 | </div> |
| 145 | </article> |
| 146 | |
| 147 | <article id="gravity" title="Schwerkraft-Modul"> |
| 148 | <h1>Schwerkraft-Modul ("Gravity")</h1> |
| 149 | |
| 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> |
| 155 | </div> |
| 156 | </article> |
| 157 | |
| 158 | <article id="gravity-code" title="Schwerkraft: Code"> |
| 159 | <h1>Schwerkraft: Code</h1> |
| 160 | |
| 161 | <div class="simplebox"> |
| 162 | <pre> |
| 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); |
| 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="Schall-Modul"> |
| 180 | <h1>Schall-Modul ("Sound")</h1> |
| 181 | |
| 182 | <div class="simplebox"> |
| 183 | <p>Mikrofon</p> |
| 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> |
| 187 | </div> |
| 188 | </article> |
| 189 | |
| 190 | <article id="sound-code" title="Schall: Code"> |
| 191 | <h1>Schall: Code</h1> |
| 192 | |
| 193 | <div class="simplebox"> |
| 194 | <pre> |
| 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); |
| 203 | }, |
| 204 | function(err) { ... } |
| 205 | ); |
| 206 | |
| 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 ... |
| 211 | |
| 212 | gModSound.mAudio.stream.stop(); |
| 213 | </pre> |
| 214 | </div> |
| 215 | </article> |
| 216 | |
| 217 | <article id="environment" title="Umgebungs-Modul"> |
| 218 | <h1>Umgebungs-Modul ("Environment")</h1> |
| 219 | |
| 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> |
| 226 | </div> |
| 227 | </article> |
| 228 | |
| 229 | <article id="environment-code" title="Umgebung: Code"> |
| 230 | <h1>Umgebung: Code</h1> |
| 231 | |
| 232 | <div class="simplebox"> |
| 233 | <pre> |
| 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); |
| 236 | |
| 237 | lightEvent: function(lightData) { |
| 238 | lightData.value (in lux) |
| 239 | }, |
| 240 | proxEvent: function(proxData) { |
| 241 | proxData.min <= .value <= .max (in cm) |
| 242 | }, |
| 243 | |
| 244 | window.removeEventListener("devicelight", this.lightEvent, true); |
| 245 | window.removeEventListener("deviceproximity", this.proxEvent, true); |
| 246 | |
| 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. |
| 249 | </pre> |
| 250 | </div> |
| 251 | </article> |
| 252 | |
| 253 | <article id="device" title="Geräte-Modul"> |
| 254 | <h1>Geräte-Modul ("Device")</h1> |
| 255 | |
| 256 | <div class="simplebox"> |
| 257 | <p>Batterie</p> |
| 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> |
| 260 | </div> |
| 261 | </article> |
| 262 | |
| 263 | <article id="device-code" title="Gerät: Code"> |
| 264 | <h1>Gerät: Code</h1> |
| 265 | |
| 266 | <div class="simplebox"> |
| 267 | <pre> |
| 268 | 0 <= <a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator.battery">navigator.battery</a>.level <= 1 |
| 269 | |
| 270 | .charging (true/false) |
| 271 | |
| 272 | .chargingTime (in s; 0 or Infinity: unbekannt) |
| 273 | |
| 274 | .dischargingTime (in s; 0 or Infinity: unbekannt) |
| 275 | </pre> |
| 276 | </div> |
| 277 | </article> |
| 278 | |
| 279 | <article id="end" title="Ende"> |
| 280 | |
| 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"> |
| 286 | </div> |
| 287 | </article> |
| 288 | |
| 289 | </body> |
| 290 | </html> |