Skip to content

chen-fishbein/sensors-codenameone

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

sensors-codenameone

Sensors library for Codename One, implemented on Android and iOS.

##Usage

Step 1. Get instance

#####Normal usage using default sensor speed.

SensorsManager gyroscope = SensorsManager.getSensorsManager(SensorsManager.TYPE_GYROSCOPE);
SensorsManager accelerometer = SensorsManager.getSensorsManager(SensorsManager.TYPE_ACCELEROMETER);
SensorsManager magnetic = SensorsManager.getSensorsManager(SensorsManager.TYPE_MAGNETIC);

#####Custom sensor speed (sampling rate) You can also add your desired sensor speed (in microseconds) as a second parameter. For example, if you want to receive (approximately) 10 samples/second (10 hz) you would use 1000000/10 = 100000 microseconds, like this:

SensorsManager accelerometer = SensorsManager.getSensorsManager(SensorsManager.TYPE_ACCELEROMETER, 100000);

###Step 2. Register listener (do stuff with sensor data)

if (accelerometer != null) {
    accelerometer.registerListener(new SensorListener() {
        public void onSensorChanged(long timeStamp, float x, float y, float z) {
            //do your stuff here...
        }
    });
}

About

Automatically exported from code.google.com/p/sensors-codenameone

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published