@Override
public void onSensorChanged(SensorEvent event) {
if( event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR ){
// calculate th rotation matrix
SensorManager.getRotationMatrixFromVector(rMat, event.values);
// get the azimuth value (orientation[0]) in degree
int newAzimuth = (int) ( Math.toDegrees( SensorManager.getOrientation( rMat, orientation )[0] ) + 360 ) % 360;
//dont react to changes smaller than the filter value
if (Math.abs(mAzimuth - newAzimuth) < mFilter) {
return;
}
mAzimuth = newAzimuth;
getReactApplicationContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("HeadingUpdated", mAzimuth);
}
}
RNSimpleCompassModule.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:react-native-simple-compass
作者:
评论列表
文章目录