<h1>Firefox OS Tricorder App</h1>
<div class="simplebox">
-<p>Displays sensor data</p>
+<p>Displays data from device sensors as exposed by WebAPIs</p>
<p><a href="https://marketplace.firefox.com/app/tricorder/">marketplace.firefox.com/app/tricorder/</a></p>
<p>Code: <a href="https://github.com/KaiRo-at/tricorder">github.com/KaiRo-at/tricorder</a></p>
</div>
<article id="ui" title="UI">
<h1>Firefox OS Tricorder UI</h1>
-<div class="simplebox">
+<div class="simplebox cent">
+<img src="tricorder-ui.svg"
+ alt="Tricorder UI description">
</div>
</article>
<div class="simplebox">
<pre>
this.watchID = navigator.geolocation.watchPosition(
- function(position) { ... },
+ function(position) {
+ position.coords.latitude / .longitude / .accuracy / ...
+ },
function(error) { ... },
{enableHighAccuracy: true, maximumAge: 10000, timeout: 60000}
);
<h1>Gravity Module</h1>
<div class="simplebox">
-<p>Accelerometer, Magnetic Compass</p>
+<p>Accelerometer, Magnetometer</p>
<p>APIs: deviceorientation, devicemotion events</p>
<p>Permissions: ---</p>
</div>
<div class="simplebox">
<pre>
+ 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();
</pre>
</div>
</article>
<div class="simplebox">
<pre>
+ 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);
+
+ // flash/torch code works via navigator.mozCameras.getCamera
+ // flaky and subject to change, please consult code on github
</pre>
</div>
</article>
<div class="simplebox">
<pre>
+ (navigator.battery.level * 100).toFixed(1) + "%";
+
+ if (navigator.battery.charging) {
+ if (navigator.battery.chargingTime == 0 ||
+ navigator.battery.chargingTime == Infinity) {
+ "charging";
+ }
+ else {
+ "charging, " + navigator.battery.chargingTime + "s remaining";
+ }
+ }
+ else {
+ if (navigator.battery.dischargingTime == 0 ||
+ navigator.battery.dischargingTime == Infinity) {
+ "discharging";
+ }
+ else {
+ navigator.battery.dischargingTime + "s usage remaining";
+ }
+ }
</pre>
</div>
</article>