Getting Accelerometer working. Beep fails for an unknown reason.

This commit is contained in:
unknown
2009-04-01 14:11:06 -07:00
parent a4bb2a276e
commit 5b32cce953
6 changed files with 127 additions and 33 deletions
+3 -3
View File
@@ -10,9 +10,9 @@
<script type="text/javascript" charset="utf-8">
var deviceInfo = function(){
document.getElementById("platform").innerHTML = Device.platform;
document.getElementById("version").innerHTML = Device.version;
document.getElementById("uuid").innerHTML = Device.uuid;
document.getElementById("platform").innerHTML = Device.getPlatform();
document.getElementById("version").innerHTML = Device.getVersion();
document.getElementById("uuid").innerHTML = Device.getUuid();
}
var getLocation = function() {
+26 -1
View File
@@ -81,7 +81,7 @@
*/
Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options) {
this.getCurrentAcceleration(successCallback, errorCallback, options);
navigator.accelerometer.getCurrentAcceleration(successCallback, errorCallback, options);
// TODO: add the interval id to a list so we can clear all watches
var frequency = (options != undefined)? options.frequency : 10000;
return setInterval(function() {
@@ -602,4 +602,29 @@ Geolocation.prototype.clearWatch = function(watchId)
Geo.stop(watchId);
}
/* Identical to the iPhone, except we have to create this in the JS */
_accel = {}
_accel.x = 0;
_accel.y = 0;
_accel.z = 0;
function gotAccel(x,y,z)
{
_accel.x = x;
_accel.y = y;
_accel.z = z;
}
Accelerometer.base_method = Accelerometer.prototype.watchAcceleration
Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options)
{
Accel.start();
Accelerometer.base_method(successCallback, errorCallback, options);
}
Accelerometer.prototype.clearWatch = function(watchId){
clearInterval(watchId);
Accel.stop();
}