Reliable application for accelerometers?

Clemens Dörrhöfer cmd at gmx.net
Sun Dec 14 11:58:28 CET 2008


KaZeR wrote:
> Hi everyone.
> 
> I'd need to be able to record accelerometers values and graph them later.
> The measure should last around 30 minutes.
> 
> Can anyone recommend an application for that?
> 
> Thanks in advance.
> 
> _______________________________________________
> Openmoko community mailing list
> community at lists.openmoko.org
> http://lists.openmoko.org/mailman/listinfo/community
> 
the only thing you need to do is to pipe /dev/input/event2 or 
/dev/input/event3 into a file. The analysis of the data can be done 
later. You will get a lot of data though after 30 minutes.
This is a python script reading and evaluating the data. Its not mine. I 
think I got it from the wiki somewhere.
Do a hexdump /dev/input/event3 to get an impression how much data we are 
talking about first.

#!/usr/bin/python
import struct
from math import sqrt

x = 0
y = 0
z = 0
secondsensorfile = "/dev/input/event2"
#int, int, short, short, int
fmt = 'iihhi'
#open file in binary mode
in_file = open(secondsensorfile,"rb")
event = in_file.read(16)
while event:
         (time1,time2, type, code, value) = \
                 struct.unpack(fmt,event)
         time = time1 + time2 / 1000000.0

         if type == 2:
                 if code == 0:
                         x = value
                 if code == 1:
                         y = value
                 if code == 2:
                         z = value
         if type == 0 and code == 0:
                 sum = int(sqrt(x*x + y*y + z*z))
                 print x, y, z, sum
         event = in_file.read(16)
in_file.close()





More information about the community mailing list