Class BearingCompassListener

  • All Implemented Interfaces:
    android.hardware.SensorEventListener

    public class BearingCompassListener
    extends TrueNorthListener
    Listener for simple bearing compass.
    • Field Detail

      • destLocation

        protected android.location.Location destLocation
      • 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

      • BearingCompassListener

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

      • calcAzimuth

        protected double calcAzimuth​(android.location.Location myLocation)
        Calculate the Azimuth.
        Overrides:
        calcAzimuth in class TrueNorthListener
        Parameters:
        myLocation - Location object
        Returns:
        double
      • setDestLocation

        public void setDestLocation​(android.location.Location loc)
        Sets the destination location we are pointing too
        Parameters:
        loc - Destination location object
      • 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