Class TrueNorthListener

  • All Implemented Interfaces:
    android.hardware.SensorEventListener
    Direct Known Subclasses:
    BearingCompassListener

    public class TrueNorthListener
    extends Object
    Compass listener for determining the direction to true north.
    • Field Detail

      • compass

        protected final Compass compass
      • valuesAccelerometer

        protected float[] valuesAccelerometer
      • valuesMagneticField

        protected float[] valuesMagneticField
      • matrixR

        protected final float[] matrixR
      • matrixI

        protected final float[] matrixI
      • matrixValues

        protected final float[] matrixValues
      • lastUpdate

        protected long lastUpdate
      • currentAccuracy

        protected int currentAccuracy
      • context

        protected final android.content.Context context
      • oldAzimuth

        protected double oldAzimuth
    • Constructor Detail

      • TrueNorthListener

        public TrueNorthListener​(Compass compass,
                                 android.content.Context context)
    • Method Detail

      • calcAzimuth

        protected double calcAzimuth​(android.location.Location myLocation)
        Calculate the Azimuth.
        Parameters:
        myLocation - Location object
        Returns:
        double
      • onAccuracyChanged

        public void onAccuracyChanged​(android.hardware.Sensor sensor,
                                      int arg1)
        Specified by:
        onAccuracyChanged in interface android.hardware.SensorEventListener
      • onSensorChanged

        public void onSensorChanged​(android.hardware.SensorEvent event)
        Specified by:
        onSensorChanged in interface android.hardware.SensorEventListener
      • smoothCompassReading

        protected double smoothCompassReading​(double azimuth,
                                              double oldAzimuth)
        Handle smoothing of the compass angle to lower jitter
        Parameters:
        azimuth - new compass bearing
        oldAzimuth - previous compass bearing
        Returns:
        double