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 magnitude and direction 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 could 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/Backto 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() should 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 could 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 should be implement in Android, which should realize some important structure defined in Android/libhardware/include/hardware/sensors.h

SensorManagerdeal with the raw data andWindowOrientationListercalculate data to determine if screen should be roation,WindowManagerdo the specific rotation work.

Why game is not smoothly?

Some tips should 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)

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android9.0 P 电源管理&android各版本电
  2. Android 简单快捷高效的屏幕适配
  3. 微软收购Android锁屏应用Echo 两华人创办
  4. 第七章 ARM 反汇编基础(一)(Android 与 ARM
  5. Android studio安装配置常见问题及其解决
  6. 安卓开发基础介绍
  7. 手机QQ桌面2.0(Android)发布:新增主题模式
  8. Android(安卓)ListView一些应该知道的事
  9. android利用post方式与web服务器通信
  10. Android中通过gradle脚本做的一些小事情