Module accel: Accelerator Measurements
| || |
|Compatibility of module accel|
|Sony Ericsson phones and Nokia S60 2nd Edition phones lack this module.||Module not found|
|Selected Nokia S60 3rd Edition phones and Nokia S60 5th Edition phones devices with builtin acceleration sensor.||ok|
This module returns the measurements of the builtin acceleration sensor. Please note that only a few devices have a such a sensor.
Each measurement corresponds to a vector in three dimensional space. Unfortunately the meaning of the values returned varies between devices, in particular the sign of the z component.
On the N95-8GB, we found the following:
| Key||Meaning||Type |
| x||Parallel to the screen, negative to the left, positive to the right.||Number |
|y||Parallel to the screen, negative to the bottom, positive to the top.||Number |
|z||Orthogonal to the screen, negative away from the viewer, positive towards the viewer.||Number |
| Vector directions on the N95-8GB|
If the device is still, the acceleration corresponds to the gravitation and thus allows to determine the rotation of the device. For instance, if the device lies flat on a table with the screen facing up, the z component will have a large value (gravitation pulling "down"). If the device is flipped over, the z component will change its sign.
The maximum magnitude of the measurements seems to be about 370 for gravitation only. Some devices return higher values for short time acceleration, e.g. when tapping on the device.
• function get() → Array
Gets the current acceleration vector.
// Check whether the N95-8GB is face up or down|
• function new(mindelta=20, timeout=-1) → Array|null
Waits until any component of the acceleration vector changes by at least mindelta, then returns the current vector. If timeout>=0 and timeout milliseconds have passed without any change, null is returned.
The following example draws a blue line in perpendicular direction:
// compute the center and radius|
cx=s/2; cy=s/2; r=cx;
if cy<r then r=cy end;
// compute the scale factor
// initially there is no line
// erase the old line
graph.line(cx, cy, cx+dx, cy+dy);
// compute the new line
// draw the new line
graph.line(cx, cy, cx+dx, cy+dy)
// until the device is flipped
Next: Module compass: Magnetometer Measurements
© 2004-2011 airbit AG, CH-8008 Zürich