Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

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

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

AccelerometerAPI

From 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 05:43.
126 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.

×