G-sensor on Android

Source: Internet
Author: User

 

What's G-sensor?

An G-sensor (or accelerometer) is a device that measures proper acceleration, the acceleration experienced relative to freefall.

Single-and multi-axis models are available to detect magnfunctions and ction of the acceleration as a vector quantity, and can be used to sense orientation, acceleration, vibration shock, and falling. micromachined accelerometers are increasingly present in portable electronic devices and video game controllers, to detect the position of the device or provide for game input.

How it works in Linux?

Kxte9 sensor is designed for embedded system, It cocould export three kinds of data.
1) acceleration data in each axis (x, y, z ).
2) tilt data about current position.
3) Activate motion detection (wake up/back to sleep) for power saving.

For screen rotation and basic games applications, first kind of data is enough. while second kind of data is auxiliary which evolve from Axis acceleration data. as I known, third kind of data is used for power saving.

Put kxte9 chip driver to kernel/driver/input/MISC/kxte9.c and board specific gpio code to kernel/ARCH/ARM/Mach-Prima/prima_evb_kxte9.c. notice that i2c_new-device () shocould be called after I2C driver or adapter is ready, so proper sequence is considered.

Low level kxte9 driver read x/y/z axis acceleration data from Chip and report to Linux input subsystem through input_report_abs () and input_sync (), then Linux application cocould read value from/dev/input/event *.

No interrupt is used exactly but coded in driver.

How it works in Android?

For acceleration data in Android, all values are in SI units (m/s2) and measure the acceleration of the device minus the force of gravity.
X: acceleration minus Gx on the X-axis
Y: acceleration minus Gy on the y-axis
Z: acceleration minus Gz on the z-axis

Hal layer of sensor shocould be implement in Android, which shocould realize some important structure defined in Android/libhardware/include/hardware/sensors. h

Sensormanager deal with the raw data and your worientationlister calculate data to determine if screen shocould be roation, windowmanager do the specific rotation work.

Why game is not smoothly?

Some tips shocould be considered to make the best game experience.
1) ODR in sensor chip refer to time interval of data reported, more data, more smoothly application is.
2) Delay Time in Linux driver and Android also influence the performance.
3) kxte9 is less powerful than other serial of Sensor Product, maybe it will limit the performance (accuracy is low)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.