项目作者: majidgolshadi

项目描述 :
Android Sensor Orientation Library helps you to get more accurate vector values of orientation, using all available device sensors.
高级语言: Java
项目地址: git://github.com/majidgolshadi/Android-Orientation-Sensor.git
创建时间: 2014-09-22T14:57:44Z
项目社区:https://github.com/majidgolshadi/Android-Orientation-Sensor

开源协议:MIT License

下载


Android Arsenal
The MIT License

Android-Orientation-Sensor

Android Sensor Orientation Library helps you to get more accurate vector values of orientation, using all available device sensors.

Overview

In one of my project (parallax library for android application) ,i need to use orientaion sensor values but they are too noisy so I decided to create a native library for android plateform to return these values with less noise.
My purpose for sharing this code in public is to solve anybody who has this problem like me.
To do this I use Accelerometer, Gyroscope, Magnetic and Orientation sensors values.

Usage

to use this library you can add codes to your project and easily use it.

Create it’s object

  1. Orientation orientationSensor = new Orientation(this.getApplicationContext(), this);

this stands for a class who implements OrientationSensorInterface class

Turn sensor ON

  1. //------Turn Orientation sensor ON-------
  2. // set tolerance for any directions
  3. orientationSensor.init(1.0, 1.0, 1.0);
  4. // set output speed and turn initialized sensor on
  5. // 0 Normal
  6. // 1 UI
  7. // 2 GAME
  8. // 3 FASTEST
  9. orientationSensor.on(0);

first it must be initialized. You can set delta value for any direction you want(e.g 1.0).
you can control your sensor pooling speed when you turn your sensor on

Turn sensor OFF

  1. orientationSensor.off();

if my introduction was not completely you can see TestActivity class that i put it in this project as a library usage sample.
I hope to this library helpful for any body that use it.
I’m realy happy to people who can help me to improve this code.