PDA

View Full Version : GSensor access for HTC devices


zehlein
01-24-2009, 10:39 PM
I'm currently playing around with the GSensor (acceleration sensor) of my HTC Touch Diamond using a code that was provided by Berunin in this thread (http://forums.arianesoft.ca/showthread.php?t=1554).
I changed the code a bit to have it working flawlessly and it is measuring the acceleration forces quite nicely now. You find the source in the attached file.

BERUNIN
01-25-2009, 06:12 AM
Good Work Zehlein !!
I like it .. ;)
Perfect speed !! .)

Berunin

kornalius
01-25-2009, 07:36 PM
Great stuff. Thank you very much for your efforts.

Mike Halliday
03-02-2009, 02:00 PM
This is great! - Just got my Touch Diamond and tried the code. Works like a charm.

Many thanks zehlein & berunin;

Mike.

Mike Halliday
03-02-2009, 02:18 PM
OK, I maybe doing something wrong, but i have added the code to one of my programs, and cant get my head around the movement readings;

If I hold the phone vertically with the screen facing me and move up and down I expected the Y values to increase (UP) and decrease (DOWN) - I take it that this is not how it works?

Do you have any pointers on how to read sensible data from the accelerometers? - Do I need to MODULUS the numbers or something?

Any help greatly welcome! :)

Cheers

Mike

zehlein
03-02-2009, 04:54 PM
Tilting left and right is measured by AccX, up and down movements by AccY. Lying flat, face up should result in AccX and AccY being zero.
There is something essential about the sensorpolling you should bear in mind: if you poll too frequently (say time between polls < 40ms) the sensor "freezes" and you get always the same results, even though the device is moved. The same applies if GameAPI uses too much processing time. Just play with the InitGameAPIEx values to get it to work.

Mike Halliday
03-02-2009, 05:10 PM
Hee hee,

I need eyes that work really quick for this.

I cant see what values I have on the screen when I move the phone up and down in front of me! - I need slo-mo vision I think.

Will have a re-think on this one and see if I can work out Max and Min values maybe for each axis.

Thanks for the response :)

Mike.

zehlein
03-02-2009, 05:17 PM
The values should reach from -1000 to +1000 for each axis, approximately (for just tilting). It depends a bit on the calibration of the sensor.

Mike Halliday
03-02-2009, 05:25 PM
hhhmm, could be that then. maybe I will have a go at re-calibrating the sensor :)

Mike Halliday
03-03-2009, 04:58 PM
Right, I think I have figured this out.

I re-aligned my gsensor, but the test program still jumps between numbers, I do not get a constant reading, even when the phone is laid flat on the desk.

I am going to try something a little more convention now instead of trying something that was harder than I initially thought.

Something good will be released when I have it polished! :)

M.

zehlein
03-03-2009, 07:51 PM
These "jumping values" are normal, don't worry... :)

hekk
03-05-2009, 06:11 PM
Hi guys
I wrote a small program using the g-sensor

http://www.youtube.com/watch?v=l9J6KCEcSM0

This is just a demo
I would try to use the g-sensor.
It may well be in the following projects.
If you are here the source code for PPL.

As an example of calibration and sensor noise€

Sorry for my English

http://forum.xda-developers.com/showthread.php?p=3383109

zehlein
03-05-2009, 08:05 PM
That app looks good. Nice work, hekk!

Mike Halliday
03-06-2009, 05:00 PM
Whoa!

Amazing stuff - If I had not seen the source code inthe .zip, I would not have believed it!

I will look at your code in great detail and use it as a template to polish up my own code!

Thanks for sharing.

Mike.

hekk
03-07-2009, 05:30 AM
Whoa!
Amazing stuff - If I had not seen the source code inthe .zip, I would not have believed it!
I will look at your code in great detail and use it as a template to polish up my own code!
Thanks for sharing.
Mike.

You're welcome one more source

http://www.youtube.com/watch?v=tZuA-PLagb0