Firefox OS Tricorder UI
-
+
+
@@ -131,7 +133,9 @@
this.watchID = navigator.geolocation.watchPosition( - function(position) { ... }, + function(position) { + position.coords.latitude / .longitude / .accuracy / ... + }, function(error) { ... }, {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000} ); @@ -145,7 +149,7 @@Gravity Module
-@@ -187,6 +191,23 @@Accelerometer, Magnetic Compass
+Accelerometer, Magnetometer
APIs: deviceorientation, devicemotion events
Permissions: ---
@@ -206,6 +227,21 @@+ 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();@@ -225,6 +261,26 @@+ 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+ (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"; + } + }