icommand.platform.nxt
Class Compass

java.lang.Object
  extended by icommand.platform.nxt.I2CSensor
      extended by icommand.platform.nxt.Compass

public class Compass
extends I2CSensor

Currently supports

Field Summary
static byte EU_MODE
           
static byte USA_MODE
           
 
Constructor Summary
Compass(Sensor s)
          Initializes a Compass using USA mode by default.
 
Method Summary
 double getDegrees()
          Returns the directional heading in degrees.
 double getRadians()
          Returns the directional heading in degrees.
 void setRegion(byte region)
          If you are using the compass in a building that uses household current, you will get better readings by setting the frequency of your power (Europe = 50Hz, USA = 60Hz).
 void startCalibration()
          Begins calibrating the compass sensor resulting in more accurate measurements.
 void stopCalibration()
           
 
Methods inherited from class icommand.platform.nxt.I2CSensor
getId, getProductID, getSensorType, getVersion
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USA_MODE

public static final byte USA_MODE
See Also:
Constant Field Values

EU_MODE

public static final byte EU_MODE
See Also:
Constant Field Values
Constructor Detail

Compass

public Compass(Sensor s)
Initializes a Compass using USA mode by default.

Method Detail

setRegion

public void setRegion(byte region)
If you are using the compass in a building that uses household current, you will get better readings by setting the frequency of your power (Europe = 50Hz, USA = 60Hz). (USA 60Hz is default)

Parameters:
region - Use Compass.USA_MODE or Compass.EU_MODE

startCalibration

public void startCalibration()
Begins calibrating the compass sensor resulting in more accurate measurements. Rotate compass at least two times, taking at least 20 seconds per rotation. Issue stopCalibration() when done. NOTE: Once the compass is calibrated, you do not have to recalibrate even when the NXT is turned off. The calibration settings are stored in internal non-volatile memory on the NXT.


stopCalibration

public void stopCalibration()
See Also:
startCalibration()

getRadians

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

Returns:
Heading in radians.

getDegrees

public double 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