Calibrator Sensor

Additional

Language
Java
Version
N/A
Created
Apr 20, 2017
Updated
May 8, 2017 (Retired)
Owner
Xenione (xenione)
Contributor
Xenione (xenione)
1
Activity
Badge
Generate
Download
Source code

Show card

Calibrator - Sensor

Widget to calibrate sensors (Orientation). This Calibrator can be embedded in your own App.

App available on google play

Add it on your project:

Gradle:

compile 'com.xenione.libs:sensor-calibrator:1.0.1'

Add calibrator sensor in your layout.

 <com.xenione.libs.calibrator.CalibratorView
        android:id="@+id/calibrator"
        android:padding="10dp"
        android:layout_width="match_parent"
        android:layout_height="300dp" />

In your code:

     protected void onCreate(Bundle savedInstanceState) {
        ...
     
        calibratorView = (CalibratorView) findViewById(R.id.calibrator);
        calibratorView.setOnCalibrationListener(new CalibratorView.CalibrationListener() {
            @Override
            public void onCalibrationComplete(int percentage) {
             // set threshold 70% 
                if (percentage > 70) {
                    // do your staff calibration is done
                }
            }
        });
        // set orientation service
        mOrientationService = new OrientationService(this);
        // register listener.
        mOrientationService.registerUpdateListener(mOrientationListener);
        // sample time, takes 1 sample every 100 ms
        mOrientationService.start(100);
        // add filter if you want to filter signal
        mOrientationService.setFilterX(new FIRFilter());
    }

     // Listeners give you back orientation from device
      private OrientationService.OrientationListener mOrientationListener = new OrientationService.OrientationListener() {
        @Override
        public void onOrientationChanged(float[] orientation) {
         // pass through calibrator widget azimuth orientation
            calibratorView.setOrientation(orientation[0]);
        }
    };

Develop by

Eugeni Josep Senent i Gabriel - @xenione

xenione@gmail.com

www.xenione.com