Archived:How to get accelerometer data of N900 using Qt
|Line 92:||Line 92:|
myThread = new aThread();
myThread = new aThread();
connect(myThread, SIGNAL((QString, QString, QString)),
this, SLOT((QString, QString, QString))
*Then the '''
*Then the '''''' method shows the three axis information of accelerometer sensor at labels at the screen.
Revision as of 12:22, 20 April 2010
In this post, I will demonstrate how to develop a Qt Application that will to get the information of accelerometer sensor at N900 device.
An accelerometer is a device that measures proper acceleration, the acceleration experienced relative to free-fall.Single- and multi-axis models are available to detect magnitude and direction of the acceleration as a vector quantity, and can be used to sense orientation, vibration and shock. Micro-machined accelerometers are increasingly present in portable electronic devices like mobile phones and video game controllers, to detect the orientation of the device or provide for game input.
Accelerometer Data at N900
The accelerometer data is sysfs file information. Sysfs is a virtual file system provided by Linux 2.6. Sysfs exports information about devices and drivers from the kernel device model to userspace, and is also used for configuration.
The three coordinates of accelerometer sensor is in a text file provided on one line and separated by white space. This file is at path below:
The values are in mG (milli G). 1000 = 1 G. The g-force experienced by an object is its acceleration relative to free-fall like described above.
At N900 device , the values are connected to the position showed below.
- At starts, i created a QThread. This thread will read the file with data at all the time.
- At implementation of our thread , the updateCoords() method is called with 20ms interval.
connect(&timer, SIGNAL(timeout()), this, SLOT(updateCoords()));
timer.start(20); // 50 Hz update rate
- This method open the file, read and process the string found on the file.
- Then, in the processing of information, the string found is split by the white spaces creating three different strings.These strings are the X,Y,Z coordinates of accelerometer.The signal deviceOrientation() is emitted to allowing that other class can connect yours slots to this signal.
- At constructor of our superior class , i created the thread described above . Then i connected the signal deviceOrientation() of our thread with the slot showData of superior class.
- Then the showData method shows the three axis information of accelerometer sensor at labels at the screen.