X-Git-Url: https://git-public.kairo.at/?p=slides.git;a=blobdiff_plain;f=linuxwochen2015%2Findex.html;fp=linuxwochen2015%2Findex.html;h=c3e8233183e3da41f5000c2b2d19c72d17aaa170;hp=0000000000000000000000000000000000000000;hb=2ba8be31ee9d39da65df026b51781dc85696e65a;hpb=83541b1cac59ca0fd223199be6f9eb6fcee0e272 diff --git a/linuxwochen2015/index.html b/linuxwochen2015/index.html new file mode 100755 index 0000000..c3e8233 --- /dev/null +++ b/linuxwochen2015/index.html @@ -0,0 +1,290 @@ + + + + + + Firefox OS Tricorder + + + + + + + + + + +
+

Inhalt

+

Firefox OS Tricorder

+ +
+

Folgende Folien sind in dieser Präsentation enthalten:

+
+
    +
+
+ +
+

Firefox OS Tricorder

+

Auslesen von Gerätesensoren mittels JavaScript

+ +
+Robert Kaiser, +"KaiRo" <kairo@kairo.at> +
Release Quality Manager, Mozilla +
+ +
+

Folien: + https://slides.kairo.at/linuxwochen2015/

+
+ +
+
+
+ +
+

Was ist ein Tricorder?

+ +
+Starfleet Tricorder, 2370 +

Sensorgerät wie in "Star Trek" zu sehen

+

Zeigt jegliche Daten an, die gerade benötigt werden, in Plot-Geschwindigkeit und -auflösung.

+

+
+
+ +
+

Firefox-OS-Tricorder-App

+ +
+

Zeigt Daten von Gerätesensoren an, die von WebAPIs zur Verfügung gestellt werden.

+

marketplace.firefox.com/app/tricorder/

+

Code: github.com/KaiRo-at/tricorder

+
+
+ +
+

Firefox-OS-Tricorder-Oberfläche

+ +
+Beschreibung der Tricorder-Oberfläche +
+
+ +
+

Modul

+ +
+ +
+
+ +
+

Positions-Modul

+ +
+

GPS, WLAN/Handysender-Peilung

+

API: Geolocation

+

Berechtigung: geolocation

+
+
+ +
+

Position: Code

+ +
+
+  this.watchID = navigator.geolocation.watchPosition(
+    function(position) {
+      position.coords.latitude / .longitude / .accuracy / ...
+    },
+    function(error) { ... },
+    {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000}
+  );
+
+  navigator.geolocation.clearWatch(this.watchID);
+
+
+
+ +
+

Schwerkraft-Modul ("Gravity")

+ +
+

Accelerometer, Magnetometer

+

APIs: deviceorientation-, +devicemotion-Erignisse

+

Berechtigungen: ---

+
+
+ +
+

Schwerkraft: Code

+ +
+
+  window.addEventListener("deviceorientation", this.orientEvent, true);
+  window.addEventListener("devicemotion", this.motionEvent, true);
+
+  orientEvent: function(orientData) {
+    orientData.alpha / .beta / .gamma (in °)
+  },
+  motionEvent: function(event) {
+    event.accelerationIncludingGravity.x / .y / .z (in m/s²)
+  },
+
+  window.removeEventListener("deviceorientation", this.orientEvent, true);
+  window.removeEventListener("devicemotion", this.motionEvent, true);
+
+
+
+ +
+

Schall-Modul ("Sound")

+ +
+

Mikrofon

+

APIs: WebRTC(getUserMedia), +WebAudio

+

Berechtigungen: audio-capture

+
+
+ +
+

Schall: Code

+ +
+
+  navigator.getUserMedia({ audio: true },
+    function(aLocalMediaStream) {
+      gModSound.mAudio.stream = aLocalMediaStream;
+      gModSound.mAudio.context = new window.AudioContext();
+      gModSound.mAudio.input =
+          gModSound.mAudio.context.createMediaStreamSource(gModSound.mAudio.stream);
+      gModSound.mAudio.analyzer = gModSound.mAudio.context.createAnalyser();
+      gModSound.mAudio.input.connect(gModSound.mAudio.analyzer);
+    },
+    function(err) { ... }
+  );
+
+  // in window.requestAnimationFrame():
+  var data = new Uint8Array(gModSound.mAudio.frequencySlices);
+  gModSound.mAudio.analyzer.getByteFrequencyData(data);
+  // ... do something with data ...
+
+  gModSound.mAudio.stream.stop();
+
+
+
+ +
+

Umgebungs-Modul ("Environment")

+ +
+

Licht, Entfernung; Taschenlampe

+

APIs: devicelight-, +deviceproximity-Ereignisse; +Camera API

+

Berechtigungen: ---; camera (für Lampe)

+
+
+ +
+

Umgebung: Code

+ +
+
+  window.addEventListener("devicelight", this.lightEvent, true);
+  window.addEventListener("deviceproximity", this.proxEvent, true);
+
+  lightEvent: function(lightData) {
+    lightData.value (in lux)
+  },
+  proxEvent: function(proxData) {
+    proxData.min <= .value <= .max (in cm)
+  },
+
+  window.removeEventListener("devicelight", this.lightEvent, true);
+  window.removeEventListener("deviceproximity", this.proxEvent, true);
+
+  // Taschenlampe mittels navigator.mozCameras.getCamera
+  // Funktioniert nicht immer und kann sich jederzeit ändern, bitte Code aif GitHub nachlesen.
+
+
+
+ +
+

Geräte-Modul ("Device")

+ +
+

Batterie

+

APIs: Battery Status API

+

Berechtigungen: ---

+
+
+ +
+

Gerät: Code

+ +
+
+  0 <= navigator.battery.level <= 1
+
+  .charging (true/false)
+
+  .chargingTime (in s; 0 or Infinity: unbekannt)
+
+  .dischargingTime (in s; 0 or Infinity: unbekannt)
+
+
+
+ +
+ +
+

Fragen?

+Data & Mister Tricorder +
+
+ + +