I had a good laugh at this one. I could be wrong, but often when
complex arithmetic code involving physical units fail and the code
originates from the US it usually means one thing.. hint: Mars Climate
Orbiter disaster (http://en.wikipedia.org/wiki/Mars_Climate_Orbiter).

The figure you mention (30) is consistent with g in Ye Olde Imperial
Units of feet per micro-fortnight squared :-)

J.


On Jun 29, 2:58 pm, "House n @ MIT" <[email protected]> wrote:
> Hello,
> I've been doing some testing on the accelerometer, specifically with
> the old SensorListener and new SensorEventListener versions available
> as of Cupcake.
>
> Using SensorListener, I've been getting normal acceleration values as
> expected according to the documentation - around 9.8 on the axis in
> line with gravity when sitting still. When I upgraded the code to
> SensorEventListener, that number jumped to around 30, which is not
> consistent with the documentation. I've tried sampling at different
> rates, but generally I've been using game mode, since that's the rate
> I ultimately intend to use.
>
> I'd be interested to hear if anyone has seen this behavior, has any
> ideas about it, or sees an issue with the code below. Give it a test
> run yourself. It might be relevant to note that the
> SensorEvent.accuracy is SENSOR_STATUS_ACCURACY_HIGH.
>
> When I run this code with the phone sitting flat on a table, screen,
> up, I get values like these:
>
> x: 12.5625      y: 20.8125      z: -16.4375
>
> ////////////////////////////////////////////////////////////////////
>
> package edu.accel;
>
> import java.io.File;
> import java.io.FileNotFoundException;
> import java.io.FileOutputStream;
> import java.io.PrintWriter;
> import java.util.List;
>
> import android.app.Activity;
> import android.content.Context;
> import android.hardware.Sensor;
> import android.hardware.SensorEvent;
> import android.hardware.SensorEventListener;
> import android.hardware.SensorManager;
> import android.os.Bundle;
>
> public class AccelTest extends Activity {
>
>         private SensorManager mSensorManager;
>
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>                 // Set up the accelerometer reading
>       mSensorManager = (SensorManager)getSystemService
> (Context.SENSOR_SERVICE);
>       // Get the list of all sensors, and find the accelerometer
> within
>       List<Sensor> sensorList = mSensorManager.getSensorList
> (SensorManager.SENSOR_ACCELEROMETER);
>
>       mSensorManager.registerListener(mSensorListener,
>                   sensorList.get(0),
>                   SensorManager.SENSOR_DELAY_UI);
>
>     }
>
>         //Accelerometer
>   private final SensorEventListener mSensorListener = new
> SensorEventListener() {
>
>         private PrintWriter mCurrentFile;
>
>         boolean never = true;
>         String comma = new String(",");
>
>         public void runOnce()
>         {
>                 //Creating a file to print the data into
>
>         String nameStr = new String("/sdcard/10 second trials.xls");
>                 File outputFile = new File(nameStr);
>                 mCurrentFile = null;
>                 try {
>                         mCurrentFile = new PrintWriter(new 
> FileOutputStream(outputFile));
>                 } catch (FileNotFoundException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>
>         }
>
>                 @Override
>                 public void onAccuracyChanged(Sensor sensor, int accuracy) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>                 @Override
>                 public void onSensorChanged(SensorEvent event) {
>
>                         if (never)
>                 {
>                         never = false;
>                         runOnce();
>                 }
>                         StringBuffer buff = new StringBuffer();
>                         buff.append(String.valueOf(event.values[0]));
>                         buff.append(comma);
>                         buff.append(String.valueOf(event.values[1]));
>                         buff.append(comma);
>                         buff.append(String.valueOf(event.values[2]));
>                         mCurrentFile.println(buff.toString());
>                 }
>   };
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to