lejos.nxt.addon
Class CompassMindSensor

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.CompassMindSensor
All Implemented Interfaces:
SensorConstants, DirectionFinder

public class CompassMindSensor
extends I2CSensor
implements DirectionFinder

This class supports the Mindsensors compass sensor.


Field Summary
 
Fields inherited from class lejos.nxt.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
 
Constructor Summary
CompassMindSensor(I2CPort port)
          Create a compass sensor object
CompassMindSensor(I2CPort port, int address)
          Create a compass sensor object
 
Method Summary
 float getDegrees()
          Returns the directional heading in degrees.
 float getDegreesCartesian()
          Compass readings increase clockwise from 0 to 360, but Cartesian coordinate systems increase counter-clockwise.
 void resetCartesianZero()
          Changes the current direction the compass is facing into the zero angle.
 void startCalibration()
          Starts calibration for Mindsensors.com compass.
 void stopCalibration()
          Ends calibration sequence.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompassMindSensor

public CompassMindSensor(I2CPort port,
                         int address)
Create a compass sensor object

Parameters:
port - Sensor port for the compass
address - The I2C address used by the sensor

CompassMindSensor

public CompassMindSensor(I2CPort port)
Create a compass sensor object

Parameters:
port - Sensor port for the compass
Method Detail

getDegrees

public float getDegrees()
Returns the directional heading in degrees. (0 to 359.9) 0 is due North (on Mindsensors circuit board a white arrow indicates the direction of compass). Reading increases clockwise.

Returns:
Heading in degrees. Resolution is within 0.1 degrees

getDegreesCartesian

public float getDegreesCartesian()
Compass readings increase clockwise from 0 to 360, but Cartesian coordinate systems increase counter-clockwise. This method returns the Cartesian compass reading. Also, the resetCartesianZero() method can be used to designate any direction as zero, rather than relying on North as being zero.

Specified by:
getDegreesCartesian in interface DirectionFinder
Returns:
Cartesian direction.

resetCartesianZero

public void resetCartesianZero()
Changes the current direction the compass is facing into the zero angle.

Specified by:
resetCartesianZero in interface DirectionFinder

startCalibration

public void startCalibration()
Starts calibration for Mindsensors.com compass. Must rotate *very* slowly ,taking at least 20 seconds per rotation. At least 2 full rotations. Must call stopCalibration() when done.

Specified by:
startCalibration in interface DirectionFinder

stopCalibration

public void stopCalibration()
Ends calibration sequence.

Specified by:
stopCalibration in interface DirectionFinder