Class DexterCompassSensor

    • Constructor Detail

      • DexterCompassSensor

        public DexterCompassSensor​(I2CPort port)
        Constructor for the driver.
        Parameters:
        port -
      • DexterCompassSensor

        public DexterCompassSensor​(Port port)
    • Method Detail

      • getMagneticMode

        public SampleProvider getMagneticMode()
        Dexter Industries dCompass sensor, magnetic mode
        Measures the strength of the magnetic field over three axes

        Size and content of the sample
        The sample contains 3 elements. Each element gives the strength of the magnetic field (in Gueass). Axis order is X, Y, Z.

        Configuration
        By default the sensor is configured for a range of 5.6 Gauss and an update frequency of 30 Hertz.
        The sensor can be tested using the test method.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders See Sensor datasheet
      • init

        protected void init()
      • getMeasurementMode

        protected int getMeasurementMode()
        Returns:
        Returns the measurement mode of the sensor (normal, positive bias or negative bias).

        positive and negative bias mode should only be used for testing the sensor.

      • getOperatingMode

        protected int getOperatingMode()
        Returns:
        The operating mode of the sensor (single measurement, continuous or Idle)
      • getMaximumRange

        public float getMaximumRange()
        Returns:
        The dynamic range of the sensor.
      • newDataAvailable

        protected boolean newDataAvailable()
        Reads the new data ready bit of the status register of the sensor.
        Returns:
        True if new data available
      • setMeasurementMode

        protected void setMeasurementMode​(int measurementMode)
        Parameters:
        measurementMode - Sets the measurement mode of the sensor.
      • setOperatingMode

        protected void setOperatingMode​(int operatingMode)
        Sets the operating mode of the sensor
        Parameters:
        operatingMode - Continuous is normal mode of operation

        SingleMeasurement can be used to conserve energy or to increase maximum measurement rate

        Idle is to stop the sensor and conserve energy

      • setRange

        public void setRange​(int range)
        Sets the dynamic range of the sensor (1.3 Gauss is default).
        Parameters:
        range -
      • test

        public boolean[] test()
        Self-test routine of the sensor.
        Returns:
        An array of boolean values. A true indicates the sensor axis is working properly.
      • setSampleRate

        public void setSampleRate​(float rate)
      • getSampleRates

        public float[] getSampleRates()
      • start

        public void start()
      • stop

        public void stop()
      • getSampleRate

        public float getSampleRate()
      • setRange

        public void setRange​(float range)
      • getRanges

        public float[] getRanges()