增加安卓加速度计的范围

3
这个问题已经有一些问法,但是还没有得出结论。
我正在尝试找出Android手机上加速度计的最大范围。一些论坛声称为+-2Gs,而另一些则为+-3.5Gs。
加速度计硬件(LSM330,位于S4上)具有更高的范围,高达16Gs。 http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00059856.pdf 我编写了一个应用程序来实际找出这个范围,并将其加载到S4上。下图显示了读数。 显然,每个方向的最大范围为2Gs。 Application Readings 以下是需要回答的问题:
  1. 是否有办法增加此范围?如果可以,请说明方法。
  2. 是否有人在其他Android手机上发现了更大的默认范围?
对于那些感兴趣的人,这是我的代码部分:
public class MainActivity extends Activity implements SensorEventListener{

Sensor accelerometer;
SensorManager sm;

TextView maxValue;
TextView realTimeValues;
TextView realTimeResultant;
TextView maxValues;
TextView maxResultant;

float x = 0;
float y = 0;
float z = 0;
float res = 0;
float xMax = 0;
float yMax = 0;
float zMax = 0;
float resMax = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sm = (SensorManager)getSystemService(SENSOR_SERVICE);
    accelerometer = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    sm.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST);

    maxValue = (TextView)findViewById(R.id.MaxValue);
    realTimeValues = (TextView)findViewById(R.id.RealTimeValues);
    realTimeResultant = (TextView)findViewById(R.id.RealTimeResultant);
    maxValues = (TextView)findViewById(R.id.maxValues);
    maxResultant = (TextView)findViewById(R.id.maxResultant);


    float max = accelerometer.getMaximumRange();
    maxValue.setText("Max range: "+ max);           
}

@Override
public void onSensorChanged(SensorEvent event) {

    if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
        return;

    x = event.values[0];
    y = event.values[1];
    z = event.values[2];
    res = (float) Math.sqrt( x*x + y*y + z*z);

    realTimeValues.setText("X: " + x + "\nY: " + y + "\nZ: " + z);
    realTimeResultant.setText(res + " m/s^2");

    if (Math.abs(x) > Math.abs(xMax))
        xMax = x;
    if (Math.abs(y) > Math.abs(yMax))
        yMax = y;
    if (Math.abs(z) > Math.abs(zMax))
        zMax = z;
    if (res > resMax)
        resMax = res;

    maxValues.setText("X: " + xMax + "\nY: " + yMax + "\nZ: " + zMax);
    maxResultant.setText(resMax + " m/s^2");    
}
}

补充信息:我意识到关于3.5Gs的帖子可能是所有三个轴的加速度之和= sqrt(2 ^ 2 + 2 ^ 2 + 2 ^ 2)。仍需要帮助…… - ace
希望这能帮到你:https://dev59.com/zGnWa4cB1Zd3GeqPyTkM(如果你还没有看过的话 :/) - ejavice
谢谢@user2493429,我已经看到了。似乎没有人在“我会查一下”的帖子后继续讨论该话题 :/ - ace
1个回答

0

看起来做这件事情似乎是不可能的。

需要注意的是,线性加速度计实际上不能增加加速度读数的范围,即使其值高达3G(在某些手机上)。这种增加的原因仅是由于线性加速度计的计算方式(基本上是使用滤波器),有时候会在方向快速切换时产生高于2G的值。

请参见此处以获取线性加速度计的计算方法:http://developer.android.com/guide/topics/sensors/sensors_motion.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接