Accelerometer on Amida

From OpenAlchemy.org

Gesture recognition technology on Amida Simputer is implemented in Accelerometer package. In this chapter the ADXL202E chip for accelerometer is discussed. Also the gesture recognition algorithm and the kernel interfaces to read from accelerometer are also presented.

Contents

ADXL202E

ADXL generates two square waves for 2D gesture recognition. In this chapter we will refer the 2D axes as X and Y respectively. Movement in X means a tilt towards right or left, whereas movement in Y means a tilt towards top or bottom. ADXL has the following properties,

  • In stable position, duty cycle of the square wave in both X and Y is around 50%.
  • If there is a movement in either X or Y, duty cycle of the corresponding axis changes.
  • If the tilt in X is towards the right then the duty cycle in X becomes more than 50% and if the tilt in X is towards the left then the duty cycle in X becomes less than 50%.
  • Similarly, if the tilt in Y is towards the top then the duty cycle in Y becomes more than 50% and if the tilt in Y is towards the bottom then the duty cycle in Y becomes less than 50%.


Kernel module: adxl.o

The kernel module adxl.o provides the interface for ADXL chip on Amida Simputer. The square waves for X and Y axes are sensed via two GPIO lines. adxl.o registers interrupt handler for both the rising and falling edge of the square wave on these GPIO lines. It computes the time from one rising edge to the next falling edge, T1 and the next rising edge T2. It then computes T = T1 * 2000/T2. For both X and Y axes, Tx and Ty, are computed this way. Tx and Ty are available to the user level applications via the character device /dev/accel.


Gesture Recognition

Gesture recognition is implemented by acceld daemon. The following algorithm describes acceld.

  • acceld polls /dev/accel once every 40ms and keeps a buffer of most recent 10 samples, Xi and Yi, for both axes.
  • Variance, Vx and Vy are computed for these Xi and Yi samples.
  • If either Vx or Vy is more than a threshold<ref>In our case we keep the threshold of 100000</ref> then acceld concludes a flick gesture, examines the sample in greater detail to find the direction of the flick and generates the appropriate flick event for the applications.
  • If all the 10 samples of either Xi or Yi are more than the extreme position settings then acceld generates extreme position events.

Gesture Events

acceld generates the following events for the 8 gestures it recognizes.

  • Alt F21, for right flick
  • Alt F22, for left flick
  • Alt F23, for top flick
  • Alt F24, for bottom flick
  • Alt F25, for right extreme
  • Alt F26, for left extreme
  • Alt F26, for top extreme
  • Alt F27, for bottom extreme

Kernel Interface for Accelerometer

Using ioctl and /proc interface applications can control the behavior of adxl.o kernel module. adxl.o module supports the following ioctls.

  • ioctl(fd,0,0)<ref>fd, is the file descriptor associated with /dev/accel</ref>, mutes the accelerometer. adxl.o module unregisters the interrupt handlers. This may be required to improve audio recording quality.
  • ioctl(fd,0,1), unmutes the accelerometer.
  • ioctl(fd,1,position), gets the current simputer extreme position. The valid positions are bextreme, textreme, rextreme, lextreme representing bottom extreme, top extreme, right extreme and left extreme respectively.
  • ioctl(fd,2,position), sets the current simputer extreme position. It is used by acceld daemon.
  • ioctl(fd,3,N), where 1 <= N <= 8, generates the Alt F2N events. Its used by acceld daemon.

adxl.o module has following /proc interface.

  • accel position, has the same role as ioctl(fd,1,..) as mentioned above.
  • accel key pressed, disables accelerometer if 0 is written to it whereas writing 1 enables accelerometer.

Pressing the accelerometer button on Amida, writes 1 to /proc/accel key pressed and thus accelerometer events are generated. It is important to note that /proc/accel key pressed does not block the universal top and bottom extreme events in simputer, i.e, the simputer screen will always flip regardless of accelerometer button pressed or not. Only way to disable accelerometer completely is to mute it with the ioctl as discussed above.

The acceld daemon registers handlers for following signals

  • SIGUSR1, used by settings application to signal the acceld of the new gesture calibration.
  • SIGUSR2, used by applications, eg golgoli, to disable the screen flip on extreme top position. To re-enable the screen flip events, SIGUSR2 is passed again.

So successive SIGUSR2 events will toggle the ability of screen flipping between enable and disable. Applications can find the process id of acceld in /tmp/accelerometer.pid.

Users

OpenAlchemy is a Free and Open Source Software project
proudly supported by
Geodesic Information Systems Limited

Comments? Feedback? Contact Us.

MediaWiki