I need read about 100 samples per second off the accelerometer on a Android, and at a fixed sample rate. The current sensormanager does or offers neither.
I've read Need to read android sensors really fast
He seems to have access to the driver code which made his life easier.
I am curious if anyone has been able to do something like this through the NDK w/o that type of knowledge.
Thanks in advance!
Open the app and tap the Diagnostic button on the home screen. Tap the individual icons to run diagnostic tests on the battery, SIM card, sensors, touch screen, flashlight, camera, microphone, speaker, Bluetooth, Wi-Fi, and more. Alternatively, tap the Test all button to perform all the tests one after the other.
There are two ways to obtain sensor information: Queried sampling to immediately read all enabled digital and analog input pins. Automatic sampling to transmit the sensor data periodically or whenever a digital pin changes.
The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.
I have taken a look at sensor.h, and the API looks very promising; however, a little howto on how to deal with the ASensorEventQueue and ASensorEventQueue_hasEvents and so forth would be -extremely- useful.
Ha! Update:
This looks a code example for what you want to do.
http://developer.android.com/reference/android/app/NativeActivity.html
Since Android SDK version 9 (for Android > 2.2) it seems to be possible to use the sensors via NDK.
See the STABLE_APIS.html file included in the docs. (Search for "sensor.h"). A mirror of that file is here.
Example from google https://github.com/googlesamples/android-ndk/tree/master/sensor-graph.Their code allow you controll SENSOR_REFRESH_RATE_HZ for the accelerometer.Written on c++ and connected to java code through the NDK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With