1

根据 android 规范,所有传感器的轴必须以相同的方式定向,如下所示:

http://developer.android.com/reference/android/hardware/SensorEvent.html

我有两部摩托罗拉手机:mb300 和摩托罗拉翻转机。

在翻盖中,磁场传感器安装正确。但是在 mb300 中,他们交换了 X 轴和 Y 轴。通过测试,我确认加速度计已正确安装在两部手机上,并且值彼此一致。但是关于磁场传感器,数值不一致,但在我对 mb300 执行以下操作后,它们开始太一致了:

(数据是数组 SensorEvent.values)

if (type == Sensor.TYPE_MAGNETIC_FIELD) { //becauseof mb300 phone
    float swap;
    swap = -data[1]; //x = -y
    data[1] = data[0]; //y = x
    data[0] = swap;
}

我已经仔细测试过了。

有没有其他人注意到这一点?

4

1 回答 1

0

Mounting of the all the sensor ICs in the same orientation is
often not possible on mobiles phones. Due to the small space
available to stuff in a lot of hardware, we often encounter
the situation which you describe.

Let me say that, there is nothing "wrong" in this.

Once you have swapped the axes properly, (in driver/HAL)
the Android framework will always get the proper data.

There will be no "side-effects" if you have swapped the axes accordingly.

Regards
CVS@2600Hertz

于 2011-03-04T16:32:29.770 回答