×
Namespaces

Variants
Actions
Revision as of 08:43, 20 October 2011 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

AccelerometerAPI

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: Diego Soares Lopes (09 Feb 2009)
Last edited: hamishwillee (20 Oct 2011)

The AccelerometerAPI was developed to facilitate access to acceleromenter sensor of Symbian OS devices, without the Symbian/C++ code conventions. It's very useful for Qt and Open C/C++ programmers.

Header

 //AccelerometerApi header
#include "AccelerometerApiIntf.h"
 
class Example: public AccelerometerObserver
{
public:
 
/**
* C++ default constructor
*/

Example();
 
/**
* Example virtual destructor
*/

virtual ~Example();
 
/**
* callback function for receiving data events,
* Inherited from AccelerometerObserver interface
*/

void accelInfoUpdater(AccelerationInfo aAcelInfo,
SensorInfo aSensorInfo);
 
private: //ATRIBUTES
 
AccelerometerApi* iSensorApi; //AccelerometerApi pointer thats provide
//an access to Accelerometer
 
};

Source

//CPP FILE
 
//Example header file
#include "Example.h"
 
Example::Example()
{
vector sensorInfoArray;
 
/**
* static function that find the availble sensors in device
*/

AccelerometerApi::findSensors(sensorInfoArray);
 
//Test if exist an available sensor in sensorInfoArray
if(sensorInfoArray.size() == 0)
{
//Creating iSensorApi with one sensor from sensorInfoArray
iSensorApi->create(sensorInfoArray[1]);
//Using setDataObserver to register a newObserver
//that colect data from sensors.
iSensorApi->setDataObserver(this);
}
}
 
Example::~Example()
{
if(iSensorApi)
{
delete iSensorApi; //delete iSensorApi pointer
iSensorApi = NULL;
}
}
This page was last modified on 20 October 2011, at 08:43.
80 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×