lis302dl OUT_X&Y&Z value converted to "g" type

Andy Green andy at openmoko.com
Tue Oct 21 08:29:39 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Somebody in the thread at some point said:
| Hello all
|
| Lis302dl(also LIS331DL) generate 3 axis values in register OUT_X OUT_Y
| OUT_Z as 2's complement type.When APP layer get the value,I supose app act
| according the value in g type.So My question is how you convert the
value in
| "byte" to g?For example,when the FS bit is 0,the sensor in a steady
| state,the OUT_Z value will be 55~60.And now it's 1g.
|
| How do you perform that?

You can see the code here:

http://git.openmoko.org/?p=kernel.git;a=blob;f=drivers/input/misc/lis302dl.c;h=f743a241d87817a15bd748f0f911f7ff0a746946;hb=stable#l218

input_report_rel(lis->input_dev, REL_X, mg_per_sample * (s8)read[0]);

mg_per_sample is 18 for the default sensitivity, it just scales the
reading up before passing it to the input subsystem.

- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkj9dswACgkQOjLpvpq7dMpZPQCgipaaEtLL6WwY1eqBJsII1U7L
HhsAn0zGjm0KHMBhZ2+l1aN+Bi+hP79f
=1A90
-----END PGP SIGNATURE-----



More information about the openmoko-kernel mailing list