Java android中加速度计的模拟数据到数字数据转换?
我在android应用程序中使用了加速计传感器,并将SensorEventListener应用于我的acctivityJava android中加速度计的模拟数据到数字数据转换?,java,android,analog-digital-converter,Java,Android,Analog Digital Converter,我在android应用程序中使用了加速计传感器,并将SensorEventListener应用于我的acctivity public void onSensorChanged(SensorEvent event) { //acceleration.x,.y,.z is the input from the sensor //result.x,.y,.z is the filtered result //high pass filter to eliminate g
public void onSensorChanged(SensorEvent event) {
//acceleration.x,.y,.z is the input from the sensor
//result.x,.y,.z is the filtered result
//high pass filter to eliminate gravity
accel[0]= event.values[0]*kFilteringFactor+accel[0]*(1.0f-kFilteringFactor);
accel[1]= event.values[1]*kFilteringFactor+accel[1]*(1.0f-kFilteringFactor);
accel[2]= event.values[2]*kFilteringFactor+accel[2]*(1.0f-kFilteringFactor);
X=event.values[0]-accel[0];
Y=event.values[1]-accel[1];
Z=event.values[2]-accel[2];
accel[0]=X;
accel[1]=Y;
accel[2]=Z;
double result=X+Y+Z;
readingData.setText("Data :"+ result);
}
我得到的是模拟波形的数据,我想要的是数字形式的数据。如何将这些数据转换成,如果有振动,我画出数据,那么图形应该是方波形式
谢谢。您想要的工作原理与计步器类似,计步器根据用户的动作计算步数,您可以使用这里使用的相同概念 您需要为加速度计幅值(x、y、z值的笛卡尔和)以及幅值超过阈值时设置阈值。您可以将该值设置为“1”,即处于运动状态,否则为零。在计步器中,我们只使用z轴读数来跟踪沿z轴的运动 我用这些做过室内定位系统。请在此处找到室内跟踪应用程序: 可在此处找到相关出版物
希望这有帮助加速计数据是根据传感器频率参数进行频繁轮询的。我认为您很困惑。加速计数据永远不会是方波。它不是周期性信号。从单个加速度事件中,您将看到正弦衰减信号。退后一步,解释一下你到底想做什么。我实现了这个东西,但如果有任何数学函数存在,请让我知道。