Fixing up the accelerometer. Weird issue with where zero is

This commit is contained in:
Joe Bowser 2010-06-04 11:42:12 -07:00
parent cd5788c3ce
commit c1e628f44c
3 changed files with 11 additions and 5 deletions

View File

@ -38,21 +38,26 @@ Accelerometer.prototype.getCurrentAcceleration = function(successCallback, error
if (typeof successCallback == "function") {
if(this.lastAcceleration)
successCallback(accel);
else
{
watchAcceleration(this.gotCurrentAcceleration, this.fail);
}
}
}
Accelerometer.prototype.gotAccel = function(key, x, y, z)
{
var a = Acceleration(x,y,z);
console.log('we won');
var a = new Acceleration(x,y,z);
a.x = x;
a.y = y;
a.x = z;
a.win = accelListener[key].win;
a.fail = accelListener[key].fail;
a.win = accelListeners[key].win;
a.fail = accelListeners[key].fail;
this.timestamp = new Date().getTime();
this.lastAcceleration = a;
accelListener[key] = a;
accelListeners[key] = a;
if (typeof a.win == "function") {
a.win(a);
}

View File

@ -20,6 +20,7 @@ public class AccelBroker {
public String start(int freq, String key)
{
AccelListener listener = new AccelListener(key, freq, mCtx, mAppView);
listener.start(freq);
accelListeners.put(key, listener);
return key;
}

View File

@ -40,7 +40,7 @@ public class AccelListener implements SensorEventListener{
if (list.size() > 0)
{
this.mSensor = list.get(0);
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_FASTEST);
}
else
{