0

I'm developing a C++ program on Ubuntu Touch (Nexus 4, no GUI) and I would like to read some accelerometer values in. I was hoping I could just include a library and call a function that would return the x,y,z acceleration values.

I noticed theres a qtubuntu-sensors and a libqt5sensors5 package here: http://packages.ubuntu.com/trusty/qtubuntu-android and some sample code here: http://doc-snapshot.qt-project.org/qt5-5.4/qtsensors-cpp.html but I'm confused at how to put it all together to read the sensor values into a C++ program.

Any help would be appreciated!

1 Answer 1

1

You would instantiate the QAccelerometer object in your code, and connect to the readingChanged signal on that object. The argument to that is a QAcclerometerReading object, which has x(), y(), and z() methods to read the respective values.

You will also need to include the sensors policy group in your apparmor declaration file, for the click package.

2
  • So if I install both qt-ubuntu and libqt5sensors5 packages on Nexus 4, I can just go ahead and #include <QtSensors/QAccelerometer> and use the QAccelerometer object?
    – Michael
    Dec 17, 2014 at 21:55
  • The packages are already installed. You don't need to install them on your Nexus 4. You just need to use the API and declare in the build system that you are using that module of Qt (as I don't think all of the Qt modules on the phone are added to the project build by default in the SDK).
    – dobey
    Dec 17, 2014 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .